public override void Update(GameTime gameTime) { if (InputHandler.IsKeyJustPressed(Keys.Up) || InputHandler.IsKeyJustPressed(Keys.Down)) { highlighted = highlighted == 0 ? 1 : 0; Constants.G_SOUNDS_PADDLE_HIT.Play(); } if (InputHandler.IsKeyJustPressed(Keys.Enter)) { Constants.G_SOUNDS_CONFIRM.Play(); if (highlighted == 0) { Paddle paddle = new Paddle(this.Game, GameRef.SpriteBatch); List <Brick> bricks = LevelMaker.CreateMap(this.Game, GameRef.SpriteBatch, random); ServeState serveState = new ServeState(this.Game, paddle, 3, 0, bricks); manager.ChangeState(serveState); } } if (InputHandler.IsKeyJustPressed(Keys.Escape)) { Game.Exit(); } base.Update(gameTime); }
public override async Task Update(TimeSpan dt) { if (Breakout.Instance.Keyboard.WasPressed(Key.Left)) { if (currentPaddle == 0) { await Breakout.Instance.Sounds["no-select"].Play(); } else { await Breakout.Instance.Sounds["select"].Play(); currentPaddle--; } } else if (Breakout.Instance.Keyboard.WasPressed(Key.Right)) { if (currentPaddle == 3) { await Breakout.Instance.Sounds["no-select"].Play(); } else { await Breakout.Instance.Sounds["select"].Play(); currentPaddle++; } } // select paddle and move on to the serve state, passing in the selection if (Breakout.Instance.Keyboard.WasPressed(Key.Enter) || Breakout.Instance.Keyboard.WasPressed(Key.Return)) { await Breakout.Instance.Sounds["confirm"].Play(); await Breakout.Instance.StateMachine.Change("serve", new Dictionary <string, object> { ["paddle"] = new Paddle(currentPaddle), ["bricks"] = levelMaker.CreateMap(1), ["health"] = 3, ["score"] = 0, ["highScores"] = highScores, ["level"] = 1, ["recoverPoints"] = 5000 }); } if (Breakout.Instance.Keyboard.WasPressed(Key.Escape)) { // Quit } }
public override async Task Update(TimeSpan dt) { paddle.Update(dt); // have the ball track the player ball.X = paddle.X + (paddle.Width / 2) - 4; ball.Y = paddle.Y - 8; // go to play screen if the player presses Enter if (Breakout.Instance.Keyboard.WasPressed(Key.Enter) || Breakout.Instance.Keyboard.WasPressed(Key.Return)) { await Breakout.Instance.StateMachine.Change("serve", new Dictionary <string, object> { ["level"] = level + 1, ["bricks"] = levelMaker.CreateMap(level + 1), ["paddle"] = paddle, ["health"] = health, ["score"] = score, ["highScores"] = highScores, ["recoverPoints"] = recoverPoints }); } }