private bool Move(KeyboardState cur_state) { old_position = position; bool is_moving = false; if (cur_time - old_time > 7 && cur_state.IsKeyDown(Keys.W) && !grid.IsGridSpotFull(position.X, position.Y - 1)) { position.Y--; src_rect = new Rectangle(32, 32, 32, 32); cur_time = 0; old_time = 0; is_moving = true; } else if (cur_time - old_time > 7 && cur_state.IsKeyDown(Keys.A) && !grid.IsGridSpotFull(position.X - 1, position.Y)) { position.X--; src_rect = new Rectangle(32, 0, 32, 32); cur_time = 0; old_time = 0; is_moving = true; } if (cur_time - old_time > 7 && cur_state.IsKeyDown(Keys.S) && !grid.IsGridSpotFull(position.X, position.Y + 1)) { position.Y++; src_rect = new Rectangle(0, 32, 32, 32); cur_time = 0; old_time = 0; is_moving = true; } else if (cur_time - old_time > 7 && cur_state.IsKeyDown(Keys.D) && !grid.IsGridSpotFull(position.X + 1, position.Y)) { position.X++; src_rect = new Rectangle(0, 0, 32, 32); cur_time = 0; old_time = 0; is_moving = true; } cur_time += 1; return is_moving; } // Move
/// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// </summary> protected override void Initialize() { // TODO: Add your initialization logic here grid = new Grid(); inventory = new Inventory(); player = new Player(grid, inventory); // Whew, avoided circular dependencies! inventory.SetPlayer(player); Creature.grid_position wand_pos = new Creature.grid_position(); wand_pos.X = 8; wand_pos.Y = 8; wand = new TeleportWand(grid, wand_pos, player); //creature = new Creature(grid); wall = new Wall(grid); room_gen = new RoomGen(); room_gen.Initialize(); base.Initialize(); }