/// <summary> /// Allows the game to run logic such as updating the world, /// checking for collisions, gathering input, and playing audio. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Update(GameTime gameTime) { // Allows the game to exit if (GamePad.GetState(PlayerIndex.One).Buttons.Back == Microsoft.Xna.Framework.Input.ButtonState.Pressed) { this.Exit(); } // TODO: Add your update logic here /* HANDLE INPUT HERE: */ UpdateInput(); /* MOVE THE GHOST: */ ghost.move(TILE_WIDTH, TILE_HEIGHT); if (ghost.hasChangedTiles) { DepthSortedEntity tmp = _theList.EntityList.Find(a => (a.tileType == 7)); tmp.x = ghost.pos.PosXMatrix; tmp.y = ghost.pos.PosYMatrix; tmp.z = _gamemap.getHeight(ghost.pos.PosXMatrix, ghost.pos.PosYMatrix); _theList.SortList(); } /* Adjust the camera: */ _cam.x += _cam.dx; _cam.y += _cam.dy; base.Update(gameTime); }
public TileList(Gmap gamemap, Unit ghost) { EntityList = new List<DepthSortedEntity>(); DepthSortedEntity tmp = null; /* Get the tiles (DIAMOND SHAPE !): */ for (int i = 0; i < gamemap.height; i++) { for (int j = 0; j < i+1; j++) { tmp = new DepthSortedEntity( j, i-j, gamemap.getHeight(j, i-j), gamemap.tileType(j, i-j), 0F ); EntityList.Add(tmp); } } for (int i = 1; i < gamemap.height+1; i++) { for (int j = 0; j < gamemap.width-i; j++) { tmp = new DepthSortedEntity(i + j, gamemap.width - j - 1, gamemap.getHeight(i + j, gamemap.width - j - 1), gamemap.tileType(i + j, gamemap.width - j - 1), 0F); EntityList.Add(tmp); } } /* Add the ghost (HIS INDEX IS 7 FROM NOW ON !!!!): */ tmp = new DepthSortedEntity(ghost.pos.PosXMatrix, ghost.pos.PosYMatrix, gamemap.getHeight(ghost.pos.PosXMatrix, ghost.pos.PosYMatrix), 7, 0F); EntityList.Add(tmp); this.SortList(); }
public TileList(Gmap gamemap, Unit ghost) { EntityList = new List <DepthSortedEntity>(); DepthSortedEntity tmp = null; /* Get the tiles (DIAMOND SHAPE !): */ for (int i = 0; i < gamemap.height; i++) { for (int j = 0; j < i + 1; j++) { tmp = new DepthSortedEntity(j, i - j, gamemap.getHeight(j, i - j), gamemap.tileType(j, i - j), 0F); EntityList.Add(tmp); } } for (int i = 1; i < gamemap.height + 1; i++) { for (int j = 0; j < gamemap.width - i; j++) { tmp = new DepthSortedEntity(i + j, gamemap.width - j - 1, gamemap.getHeight(i + j, gamemap.width - j - 1), gamemap.tileType(i + j, gamemap.width - j - 1), 0F); EntityList.Add(tmp); } } /* Add the ghost (HIS INDEX IS 7 FROM NOW ON !!!!): */ tmp = new DepthSortedEntity(ghost.pos.PosXMatrix, ghost.pos.PosYMatrix, gamemap.getHeight(ghost.pos.PosXMatrix, ghost.pos.PosYMatrix), 7, 0F); EntityList.Add(tmp); this.SortList(); }