Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Game1 : Microsoft.Xna.Framework.Game
- {
- GraphicsDeviceManager graphics;
- SpriteBatch spriteBatch;
- Tile tl = new Tile();
- public Game1()
- {
- graphics = new GraphicsDeviceManager(this);
- Content.RootDirectory = "Content";
- graphics.PreferredBackBufferWidth = 1280;
- graphics.PreferredBackBufferHeight = 960;
- //graphics.IsFullScreen = true;
- }
- protected override void Initialize()
- {
- // TODO: Add your initialization logic here
- base.Initialize();
- }
- protected override void LoadContent()
- {
- spriteBatch = new SpriteBatch(GraphicsDevice);
- Content.RootDirectory = "Content";
- }
- protected override void UnloadContent()
- {
- // TODO: Unload any non ContentManager content here
- }
- protected override void Update(GameTime gameTime)
- {
- // Allows the game to exit
- if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
- this.Exit();
- // TODO: Add your update logic here
- base.Update(gameTime);
- }
- /// <summary>
- /// This is called when the game should draw itself.
- /// </summary>
- /// <param name="gameTime">Provides a snapshot of timing values.</param>
- ///
- inputForm iForm = new inputForm();
- bool[,] centerPiece = new bool[,] { { false, true, false }, { true, true, true }, { false, true, false } };
- bool[,] cornerPiece = new bool[,] { { false, true, false }, { true, true, false }, { false, false, false } };
- bool[,] stairPiece = new bool[,] { { false, true, false }, { true, true, true }, { false, false, false } };
- bool[,] straightPiece = new bool[,] { { false, true, false }, { false, true, false }, { false, true, false } };
- protected override void Draw(GameTime gameTime)
- {
- GraphicsDevice.Clear(Color.White);
- // Draw the sprite.
- spriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.AlphaBlend);
- //Draw centerPiece
- tl.centerPiece(spriteBatch, centerPiece);
- spriteBatch.End();
- base.Draw(gameTime);
- //iForm.Show();
- }
- }
- public class Tile : Microsoft.Xna.Framework.Game
- {
- GraphicsDeviceManager graphics;
- public float spacing = 32f;
- public Texture2D squareTex;
- public Vector2 IMGCenter()
- {
- Vector2 imageCenter = new Vector2(4 / 2f, 4 / 2f);
- return imageCenter;
- }
- public Vector2 screenView()
- {
- Viewport viewport = GraphicsDevice.Viewport;
- Vector2 screenCenter = new Vector2(viewport.Width / 2f, viewport.Height / 2f);
- return screenCenter;
- }
- public Tile()
- {
- }
- public void centerPiece(SpriteBatch batch, bool[,] squareCombo)
- {
- for (int x = 0; x < squareCombo.GetLength(0); x++)
- {
- for (int y = 0; y < squareCombo.GetLength(1); y++)
- {
- if (squareCombo[x, y] == true)
- {
- Vector2 offset = new Vector2(x, y) * spacing;
- Vector2 position = IMGCenter() + offset;
- batch.Draw(squareTex, screenView(), null, Color.White, 0f, position, 1f, SpriteEffects.None, 0f);
- }
- }
- }
- }
- }
- Viewport viewport = GraphicsDevice.Viewport;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement