/// <summary> /// The main entry point for the application. /// </summary> static void Main(string[] args) { using (Sprint4 game = new Sprint4()) { game.Run(); } }
public void Update(Sprint4 game, IPlayer mario) { //todo: convert to switch case //need to test this somehow // quit if (GamePad.GetState(PlayerIndex.One).Buttons.Start == ButtonState.Pressed) { game.Exit(); } // up else if (GamePad.GetState(PlayerIndex.One).DPad.Up == ButtonState.Pressed) { command = new JumpCommand(mario); command.Execute(); } // left else if (GamePad.GetState(PlayerIndex.One).DPad.Left == ButtonState.Pressed) { command = new LeftCommand(mario); command.Execute(); } // right else if (GamePad.GetState(PlayerIndex.One).DPad.Right == ButtonState.Pressed) { command = new RightCommand(mario); command.Execute(); } // down else if (GamePad.GetState(PlayerIndex.One).DPad.Down == ButtonState.Pressed) { command = new CrouchCommand(mario); command.Execute(); } else if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed) { game.Reset(); } else { command = new StandCommand(mario); command.Execute(); } }
public void Update(Sprint4 game, IPlayer mario) { bool aKeyIsPressed = false; Sprint4.GameState gameState = game.getGameState(); KeyboardState curr = Keyboard.GetState(); foreach (KeyValuePair<Keys, PossibleCommands> key in keymap) { if (keyPressed(key.Key, curr)) { aKeyIsPressed = true; //let these in even if mario is dead/hit switch (gameState) { case Sprint4.GameState.MainMenu: switch (key.Value) { case PossibleCommands.quit: game.Exit(); break; case PossibleCommands.oneplayer: game.setGameState(Sprint4.GameState.OnePlayer); break; case PossibleCommands.twoplayer: game.setGameState(Sprint4.GameState.TwoPlayer); break; } break; case Sprint4.GameState.Pause: switch (key.Value) { case PossibleCommands.unpause: game.UnPause(); break; case PossibleCommands.mainmenu: game.Reset(); game.setGameState(Sprint4.GameState.MainMenu); break; case PossibleCommands.quit: game.Exit(); break; } break; case Sprint4.GameState.OnePlayer: // nothign to do here break; case Sprint4.GameState.TwoPlayer: switch (key.Value) { case PossibleCommands.pause: game.Pause(); break; case PossibleCommands.reset: game.Reset(); break; default: if (marioCanMove(mario)) { switch (key.Value) { case PossibleCommands.left: new LeftCommand(mario).Execute(); break; case PossibleCommands.right: new RightCommand(mario).Execute(); break; case PossibleCommands.run: new RunCommand(mario).Execute(); break; case PossibleCommands.jump: new JumpCommand(mario).Execute(); break; case PossibleCommands.crouch: new CrouchCommand(mario).Execute(); break; case PossibleCommands.fireball: new FireballCommand(mario).Execute(); break; } } break; } break; } } } if (!aKeyIsPressed && marioCanMove(mario)) new StandCommand(mario).Execute(); //prev = curr; //if we want to do this we'll need to update command logic accordingly. I'm all for it and think it will make things less glitchy, but I'll leave it alone for now. }