Browse Source

Add ability to restart the level. Fixes #9.

GitOrigin-RevId: e7a0cdcdde
master
Colin McMillen 4 years ago
parent
commit
e2ea2e1d3f
  1. 8
      Shared/Input.cs
  2. 16
      Shared/SneakGame.cs

8
Shared/Input.cs

@ -10,6 +10,7 @@ namespace SemiColinGames {
public bool Pause;
public bool Debug;
public bool Exit;
public bool Restart;
public bool FullScreen;
public Input(GamePadState gamePad, KeyboardState keyboard) {
@ -24,10 +25,15 @@ namespace SemiColinGames {
(gamePad.IsButtonDown(Buttons.LeftShoulder) &&
gamePad.IsButtonDown(Buttons.RightShoulder) &&
gamePad.IsButtonDown(Buttons.Start));
FullScreen = keyboard.IsKeyDown(Keys.F12) || keyboard.IsKeyDown(Keys.OemPlus) ||
Restart = keyboard.IsKeyDown(Keys.F5) ||
(gamePad.IsButtonDown(Buttons.LeftShoulder) &&
gamePad.IsButtonDown(Buttons.RightShoulder) &&
gamePad.IsButtonDown(Buttons.Back));
FullScreen = keyboard.IsKeyDown(Keys.F12) || keyboard.IsKeyDown(Keys.OemPlus) ||
(gamePad.IsButtonDown(Buttons.LeftShoulder) &&
gamePad.IsButtonDown(Buttons.RightShoulder) &&
gamePad.IsButtonDown(Buttons.Y));
Debug = gamePad.IsButtonDown(Buttons.LeftShoulder) || keyboard.IsKeyDown(Keys.OemMinus);
Pause = gamePad.IsButtonDown(Buttons.Start) || keyboard.IsKeyDown(Keys.Pause);

16
Shared/SneakGame.cs

@ -37,7 +37,7 @@ namespace SemiColinGames {
Player player;
World world;
LinesOfSight linesOfSight;
readonly Camera camera = new Camera();
Camera camera = new Camera();
public SneakGame() {
graphics = new GraphicsDeviceManager(this) {
@ -83,12 +83,16 @@ namespace SemiColinGames {
base.LoadContent();
spriteBatch = new SpriteBatch(GraphicsDevice);
font = Content.Load<SpriteFont>("font");
player = new Player(Content.Load<Texture2D>("Ninja_Female"));
world = new World(Content.Load<Texture2D>("grassland"), Levels.ONE_ONE);
linesOfSight = new LinesOfSight(GraphicsDevice);
grasslandBg1 = Content.Load<Texture2D>("grassland_bg1");
grasslandBg2 = Content.Load<Texture2D>("grassland_bg2");
LoadLevel();
}
private void LoadLevel() {
camera = new Camera();
player = new Player(Content.Load<Texture2D>("Ninja_Female"));
world = new World(Content.Load<Texture2D>("grassland"), Levels.ONE_ONE);
}
// Called once per game. Unloads all game content.
@ -116,6 +120,10 @@ namespace SemiColinGames {
display.SetFullScreen(fullScreen);
}
if (input[0].Restart && !input[1].Restart) {
LoadLevel();
}
Debug.Clear(paused);
if (input[0].Debug && !input[1].Debug) {
Debug.Enabled = !Debug.Enabled;

Loading…
Cancel
Save