示例#1
0
 static Game()
 {
     window = new Window(1000, 700, "Space Invaders", PixelFormat.RGB);
     GfxTools.Init(window);
     EnemiesManager.Init();
     player    = new Player();
     scoreText = new SpriteText(new Vector2(window.width - Edge - 140, window.height - Edge), Player.Score.ToString("D6"));
 }
示例#2
0
 private bool BulletCollideWithBullet()
 {
     for (int i = 0; i < bullets.Length; i++)
     {
         if (!bullets[i].IsFired)
         {
             continue;
         }
         if (EnemiesManager.BulletCollideWithBullet(bullets[i]))
         {
             return(true);
         }
     }
     return(false);
 }
示例#3
0
 private void UpdateBullets()
 {
     for (int i = 0; i < bullets.Length; i++)
     {
         if (!bullets[i].IsFired)
         {
             continue;
         }
         bullets[i].Update();
         if (EnemiesManager.IsCollideWithBullet(bullets[i]) ||
             Mothership.IsCollideWithBullet(bullets[i]))
         {
             bullets[i].IsFired = false;
         }
     }
 }
示例#4
0
        public static void Play()
        {
            while (window.opened)
            {
                GfxTools.Clean();

                // INPUT

                if (window.GetKey(KeyCode.Esc) || window.GetKey(KeyCode.Return))
                {
                    return;
                }

                if (window.GetKey(KeyCode.P) && pauseCooldown <= 0)
                {
                    isPause       = !isPause;
                    pauseCooldown = pauseTempo;
                }

                player.Input();

                // UPDATE

                if (!isPause && Player.Lives > 0 && EnemiesManager.EnemiesAlive > 0)
                {
                    player.Update();
                    EnemiesManager.Update();
                }
                pauseCooldown -= window.deltaTime;
                scoreText.Text = Player.Score.ToString("D6");

                // DRAW

                player.Draw();
                scoreText.Draw();
                EnemiesManager.Draw();

                if (isPause)
                {
                    GfxTools.DrawRectangle(window.width / 2 - 30, window.height / 2 - 45, 60, 90, 0, 0, 0);
                    GfxTools.DrawRectangle(window.width / 2 - 25, window.height / 2 - 40, 20, 80, 255, 255, 255);
                    GfxTools.DrawRectangle(window.width / 2 + 5, window.height / 2 - 40, 20, 80, 255, 255, 255);
                }

                window.Blit();
            }
        }
示例#5
0
 public void Update(Window window, PlayersBulletssManager playersBulletssManager, EnemiesManager enemiesManager)
 {
     if (IsCollideWithEnemy(enemiesManager.Enemies) ||
         IsCollideWithPlayerBullet(playersBulletssManager.Bullets) ||
         IsCollideWithEnemiesBullet(enemiesManager.BulletssManager.Bullets))
     {
         for (int i = 0; i < barriers.Length; i++)
         {
             barriers[i].Update(window);
         }
     }
 }