void Update() { pesawat.MoveUp(); if (this.transform.position.y < -20) { Destroy(this.gameObject); } }
/// <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(); } var dt = gameTime.ElapsedGameTime.TotalSeconds; KeyboardState state = Keyboard.GetState(); // TODO: Add your update logic here if (Keyboard.GetState().IsKeyDown(Keys.D)) { plane.MoveRight(300 * dt); } if (Keyboard.GetState().IsKeyDown(Keys.A)) { plane.MoveLeft(300 * dt); } if (Keyboard.GetState().IsKeyDown(Keys.W)) { plane.MoveUp(300 * dt); } if (Keyboard.GetState().IsKeyDown(Keys.S)) { plane.MoveDown(300 * dt); } if (state.IsKeyDown(Keys.Space) && !keyboardState.IsKeyDown(Keys.Space)) { plane.Fire(); } plane.LaunchBullet(); keyboardState = state; base.Update(gameTime); }
// Update is called once per frame void Update() { if (Input.GetKey(KeyCode.UpArrow)) { pesawat.MoveUp(); } if (Input.GetKey(KeyCode.DownArrow)) { pesawat.MoveDown(); } if (Input.GetKey(KeyCode.LeftArrow)) { pesawat.MoveLeft(); } if (Input.GetKey(KeyCode.RightArrow)) { pesawat.MoveRight(); } if (Input.GetKey(KeyCode.Space)) { pesawat.Attack(); } }
// Update is called once per frame void Update() { if (PencetAtas) { pesawat.MoveUp(); } if (PencetBawah) { pesawat.MoveDown(); } if (PencetKanan) { pesawat.MoveRight(); } if (PencetKiri) { pesawat.MoveLeft(); } if (PencetTembak) { pesawat.Attack(); } }