public void Update(GameTime gameTime) { int pointMod = maxPoints - minPoints + 1; KeyboardState kbs = Keyboard.GetState(); if (oldKbs.IsKeyDown(Keys.Right) && kbs.IsKeyUp(Keys.Right)) { cursor = (cursor + 1) % maps.Count; } if (oldKbs.IsKeyDown(Keys.Left) && kbs.IsKeyUp(Keys.Left)) { cursor = (cursor + maps.Count - 1) % maps.Count; } if (oldKbs.IsKeyDown(Keys.Up) && kbs.IsKeyUp(Keys.Up)) { pointsToWin = (pointsToWin - minPoints + 1) % pointMod + minPoints; } if (oldKbs.IsKeyDown(Keys.Down) && kbs.IsKeyUp(Keys.Down)) { pointsToWin = (pointsToWin - minPoints + pointMod - 1) % pointMod + minPoints; } if (oldKbs.IsKeyDown(Keys.Enter) && kbs.IsKeyUp(Keys.Enter)) { Globals.SetState(new MainGame(maps[cursor], pointsToWin)); } oldKbs = kbs; }
/// <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() { Globals.random = new Random(); base.Initialize(); //Globals.SetState(new MainGame()); Globals.SetState(new Menu()); }
public void Update(GameTime gameTime) { KeyboardState kbs = Keyboard.GetState(); if (kbs.IsKeyDown(Keys.Space)) { Globals.SetState(new Menu()); } }
private void Restart() { Sprite.SpriteList.Clear(); Explosion.ExplosionList.Clear(); playerList.Clear(); if (winner != null && score[winner.Id] == pointsToWin) { Globals.SetState(new WinnerState(winner)); return; } Initialize(); }