/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); debugTiles = Content.Load<Texture2D>("debugTiles"); wall = Content.Load<Texture2D>("Wall"); player1 = Content.Load<Texture2D>("player"); target = Content.Load<Texture2D>("target"); text = Content.Load<SpriteFont>("font"); enemy1 = Content.Load<Texture2D>("enemy"); pathTile = Content.Load<Texture2D>("pathTile"); normTiles = Content.Load<Texture2D>("normTiles"); turret1Image = Content.Load<Texture2D>("turret1"); bullet1Image = Content.Load<Texture2D>("bullet1"); healthBar = Content.Load<Texture2D>("HealthBar"); gridBoundX = GraphicsDevice.Viewport.Height; gridBoundY = GraphicsDevice.Viewport.Width; grid = new Tiles[(GraphicsDevice.Viewport.Height)][]; //creating the game grid for (int i = 0; i < (GraphicsDevice.Viewport.Height); i++) { grid[i] = new Tiles[(GraphicsDevice.Viewport.Width)]; for (int j = 0; j < (GraphicsDevice.Viewport.Width); j++) { grid[i][j] = new Tiles(new Vector2((j * 50) + 25, i * 50 + 25), blocked, new Rectangle(j * 50, i * 50, 50, 50), normTiles, i, j); } } grid[3][15].ifTarget(true, target, debugTiles); targetExist = true; targetX = (int)grid[3][15].center.Y / 50; targetY = (int)grid[3][15].center.X / 50; }
public void setupTiles(int backgroundX, int backgroundY, int tileWidth, int tileHeigh, int screenWidth, int screenHeight) { for (int i = 0; i < tileArraySize; i++) { if (i == 0 || count == 0) { if (i == 0) { //Plus 5 is to spawn a little off the edge of the tile currentTileX = backgroundX + 5; currentTileY = backgroundY + (tileWidth - 5); } Tiles tile = new Tiles(); tile.height = 100; tile.width = 100; tile.x = currentTileX; tile.y = currentTileY; tileArray[row, arrayColum] = tile; row += 1; count += 1; } else if (row < 8) { currentTileX += tileWidth; Tiles tile = new Tiles(); tile.height = 100; tile.width = 100; tile.x = currentTileX; tile.y = currentTileY; tileArray[row, arrayColum] = tile; row += 1; count += 1; } else if (row == 8) { currentTileX += tileWidth; Tiles tile = new Tiles(); tile.height = 100; tile.width = 100; tile.x = currentTileX; tile.y = currentTileY; tileArray[row, arrayColum] = tile; row = 0; arrayColum += 1; currentTileY += tileHeigh; currentTileX = backgroundX; count = 0; } } }