Esempio n. 1
0
        void GameLoop()
        {
            const int ExplodeDelay = 50;

            _FinishedRound = false;
            _Done          = false;
            int delay = Globals.GameLoopTick_ms;

            while (!_Done)
            {
                CheckKeys();
                Tank.BulletCheckResults result = Tank.Red.CheckBullets(_Map);
                result |= Tank.Blue.CheckBullets(_Map);

                if ((result & Tank.BulletCheckResults.RedDied) != 0)
                {
                    delay = ExplodeDelay;
                    Tank.Red.Explode();
                }
                if ((result & Tank.BulletCheckResults.BlueDied) != 0)
                {
                    delay = ExplodeDelay;
                    Tank.Blue.Explode();
                }

                Mode13hPanel.FlipScreen(_Background, _Mode13hPanel.Screen);
                Tank.Red.Draw(_Mode13hPanel);
                Tank.Blue.Draw(_Mode13hPanel);

                _Mode13hPanel.DoPaint();

                if ((Tank.Red.IsExploding || Tank.Blue.IsExploding) &&
                    Tank.Red.DoneExploding && Tank.Blue.DoneExploding)
                {
                    if (Tank.Blue.IsExploding)
                    {
                        Tank.RedScore++;
                    }
                    if (Tank.Red.IsExploding)
                    {
                        Tank.BlueScore++;
                    }

                    _FinishedRound = true;
                    return;
                }

                if (!_Done)
                {
                    System.Threading.Thread.Sleep(delay);
                }
            }
        }
Esempio n. 2
0
        void NewGame(string map)
        {
            StopRound();

            if (_Thread != null)
            {
                _Thread.Abort();
            }
            LoadMap(map);
            Mode13hPanel.DrawMap(_Map, _Background);
            Mode13hPanel.FlipScreen(_Background, _Mode13hPanel.Screen);
            _Mode13hPanel.GameOver = false;

            Tank.RedScore  = 0;
            Tank.BlueScore = 0;

            NewRound();
        }