Beispiel #1
0
        public void DrawScreen(ScreenCanvas sc, int iPictX, int iPictY, ref Score score)
        {
            Point ptCheck = new Point(0);

            if (paused)
            {
                // Pause flashes on and off
                if (iPauseTimer > PAUSE_INTERVAL / 2)
                {
                    TextDraw.DrawText(sc, "PAUSE", TextDraw.Justify.CENTER,
                                      iMaxY / 3, 200, 400, iPictX, iPictY);
                }
                if (--iPauseTimer < 0)
                {
                    iPauseTimer = PAUSE_INTERVAL;
                }
            }
            else // Do all game processing if game is not paused
            {
                // If no ship displaying, after explosions are done
                // get a new one - or end the game
                if (!ship.IsAlive() && (explosions.Count() == 0))
                {
                    if (!score.HasReserveShips())
                    {
                        // Game over
                        inProcess = false;
                    }
                    else
                    {
                        if (asteroids.IsCenterSafe())
                        {
                            score.GetNewShip();
                            ship = new Ship(true);
                        }
                    }
                }

                // Create a new asteroid belt if
                // no explosions and no asteroids
                if ((explosions.Count() == 0) && (asteroids.Count() == 0))
                {
                    asteroids = new AsteroidBelt(++iLevel);
                }

                // Move all objects
                ship.Move();
                foreach (Bullet bullet in shipBullets)
                {
                    bullet.Move();
                }
                asteroids.Move();
                explosions.Move();

                // Check bullets for collisions
                foreach (Bullet bullet in shipBullets)
                {
                    if (bullet.AcquireLoc(ref ptCheck) && CheckPointInAsteroid(ptCheck, ref score))
                    {
                        explosions.AddExplosion(ptCheck);
                        bullet.Disable();
                    }
                }

                // Check ship for collisions
                if (ship.IsAlive())
                {
                    foreach (Point ptInShip in ship.pointsTransformed)
                    {
                        ptCheck.X = ptInShip.X + ship.GetCurrLoc().X;
                        ptCheck.Y = ptInShip.Y + ship.GetCurrLoc().Y;
                        if (CheckPointInAsteroid(ptCheck, ref score))
                        {
                            ExplodeShip();
                            break;
                        }
                    }
                }
            }

            // Draw all objects
            ship.Draw(sc, iPictX, iPictY);
            foreach (Bullet bullet in shipBullets)
            {
                bullet.Draw(sc, iPictX, iPictY);
            }

            asteroids.Draw(sc, iPictX, iPictY);
            explosions.Draw(sc, iPictX, iPictY);

            // Draw the score
            score.Draw(sc, iPictX, iPictY);
        }
 public TitleScreen()
 {
     InitTitleScreen();
     asteroids = new AsteroidBelt(15, Asteroid.ASTEROID_SIZE.SMALL);
 }