/// <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) { var keyboardState = Keyboard.GetState(); if (keyboardState.IsKeyDown(Keys.W)) { _tank.Accelerate(); } if (keyboardState.IsKeyDown(Keys.S)) { _tank.Decelerate(); } bool turning = false; if (keyboardState.IsKeyDown(Keys.A)) { _tank.TurnRight(); turning = true; } if (keyboardState.IsKeyDown(Keys.D)) { _tank.TurnLeft(); turning = !turning; } if (!turning) { _tank.StopTurning(); } var mouseState = Mouse.GetState(); _tank.SetTarget(mouseState.X, mouseState.Y); _tank.UpdatePosition(gameTime.ElapsedGameTime); base.Update(gameTime); }
public void Accelerate() { target.Accelerate(); }
void aja(Tank t, double vaanto) { t.Accelerate(vaanto); }