/// <summary> /// Allows the game to run logic such as updating the world, /// checking for collisions, gathering input, and playing audio. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Update(GameTime gameTime) { // Allows the game to exit if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed) { this.Exit(); } KeyboardState keyState = Keyboard.GetState(); if (keyState.IsKeyDown(Keys.Space) && !enterPressed) { ball.Vector = new Vector2(-5, -5); this.enterPressed = true; } // TODO: Add your update logic here table.Update(gameTime); paddle.Update(gameTime); ball.Update(gameTime); base.Update(gameTime); }
/// <summary> /// Allows the game to run logic such as updating the world, /// checking for collisions, gathering input, and playing audio. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Update(GameTime gameTime) { if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape)) { Exit(); } paddle.Update(gameTime); ball.Update(gameTime); ball.PaddleRebound(paddle); foreach (Brick b in bricks) { b.Update(gameTime); } for (int k = 0; k < bricks.Count; k++) { Brick b = bricks[k]; if (ball.spriteBox.Intersects(b.spriteBox)) { bricks.RemoveAt(k); ball.BrickRebound(b); k--; } } if (ball.IsGameOver) { Start(); } Console.WriteLine(bricks.Count); base.Update(gameTime); }
internal void Update(GameTime gameTime) { paddle.Update(gameTime); ball.Update(gameTime); }