Exemplo n.º 1
0
        private void GameplayForm_KeyDown(object sender, KeyEventArgs e)
        {
            PlayerTank currentTankPlayer = currentGame.GetPlayerTank();

            // Left Key
            if (e.KeyCode == Keys.Left)
            {
                if (numericUpDown1.Value > -90)
                {
                    numericUpDown1.Value--;
                }
                currentTankPlayer.AimTurret((float)numericUpDown1.Value);
            }
            // Right Key
            else if (e.KeyCode == Keys.Right)
            {
                if (numericUpDown1.Value < 90)
                {
                    numericUpDown1.Value++;
                }
                currentTankPlayer.AimTurret((float)numericUpDown1.Value);
            }
            // Up Key
            else if (e.KeyCode == Keys.Up)
            {
                if (trackBar1.Value < 100)
                {
                    trackBar1.Value++;
                    label7.Text = trackBar1.Value.ToString();
                }
                currentTankPlayer.SetPower(trackBar1.Value);
            }
            //Down Key
            else if (e.KeyCode == Keys.Down)
            {
                if (trackBar1.Value > 5)
                {
                    trackBar1.Value--;
                    label7.Text = trackBar1.Value.ToString();
                }
                currentTankPlayer.SetPower(trackBar1.Value);
            }

            DrawGameplay();
            displayPanel.Invalidate();
        }
Exemplo n.º 2
0
        private void numericUpDown1_ValueChanged(object sender, EventArgs e)
        {
            PlayerTank currentTankPlayer = currentGame.GetPlayerTank();

            currentTankPlayer.AimTurret((float)numericUpDown1.Value);

            DrawGameplay();

            displayPanel.Invalidate();
        }
Exemplo n.º 3
0
 public void AimTurret(float angle)
 {
     AngleNumericUpDown.Value = (decimal)angle;
     current_tank.AimTurret(angle);
 }