예제 #1
0
        private void HandleKeys()
        {
            switch (CurrentKeyDown)
            {
            case "Space":
                if (ActiveBullet == false)
                {
                    TheBullet.Position = TheMan.GetBulletStart();
                    ActiveBullet       = true;
                    PlaySoundInThread("1.wav", 2);
                }
                CurrentKeyDown = LastKeyDown;
                break;

            case "Left":
                TheMan.MoveLeft();
                Invalidate(TheMan.GetBounds());
                if (timer1.Enabled == false)
                {
                    timer1.Start();
                }
                break;

            case "Right":
                TheMan.MoveRight(ClientRectangle.Right);
                Invalidate(TheMan.GetBounds());
                if (timer1.Enabled == false)
                {
                    timer1.Start();
                }
                break;

            default:
                break;
            }
        }
예제 #2
0
        //static Timer _pauseTimer;


        private void HandleKeys()
        {
            switch (CurrentKeyDown)
            {
            case "Space":
                if (!pause)
                {
                    if (ActiveBullet == false)
                    {
                        TheBullet.Position = TheMan.GetBulletStart();
                        TheBullet.setKInterval(speeds[0]);
                        ActiveBullet = true;
                        PlaySoundInThread("1.wav", 2);
                    }
                }
                CurrentKeyDown = LastKeyDown;
                break;

            case "A":
                if (!pause)
                {
                    TheMan.MoveLeft();
                    TheMan.setPause(pause);
                    Invalidate(TheMan.GetBounds());
                    if (timer1.Enabled == false)
                    {
                        timer1.Start();
                    }
                }
                CurrentKeyDown = LastKeyDown;
                break;

            case "D":
                if (!pause)
                {
                    TheMan.MoveRight(ClientRectangle.Right);
                    TheMan.setPause(pause);
                    Invalidate(TheMan.GetBounds());
                    if (timer1.Enabled == false)
                    {
                        timer1.Start();
                    }
                    CurrentKeyDown = LastKeyDown;
                }
                break;

            case "R":
                if (!pause)
                {
                    InitializeAllGameObjects(true);
                    TimerCounter = 0;
                    CurrentSaucer.Reset();
                    SaucerStart    = false;
                    CurrentKeyDown = LastKeyDown;
                }
                break;

            case "P":
                pause          = !pause;
                CurrentKeyDown = LastKeyDown;
                break;

            default:
                break;
            }
        }