Esempio n. 1
0
        public static void Play()
        {
            while (window.opened)
            {
                if (!player.IsAlive || EnemyMgr.AllGone || EnemyMgr.Landed)
                {
                    return;
                }

                totalTime += GfxTools.Win.deltaTime;
                GfxTools.Clean();
                //Input
                if (window.GetKey(KeyCode.Esc))
                {
                    return;
                }

                player.Input();

                //Update
                EnemyMgr.Update();
                player.Update();

                //Draw
                for (int i = 0; i < barriers.Length; i++)
                {
                    barriers[i].Draw();
                }
                EnemyMgr.Draw();
                player.Draw();
                DrawGUI();

                window.Blit();
            }
        }
Esempio n. 2
0
        static Game()
        {
            window  = new Window(800, 600, "Space Invaders", PixelFormat.RGB);
            gravity = 555.0f;
            GfxTools.Init(window);

            Vector2 playerPos;

            playerPos.X = window.width / 2;
            playerPos.Y = window.height - 30;

            EnemyMgr.Init(24, 3);

            player = new Player(playerPos, new Color(0, 0, 0));
            heart  = new Sprite("Assets/heart.png");

            barriers = new Barrier[3];

            for (int i = 0; i < barriers.Length; i++)
            {
                barriers[i] = new Barrier(window.width * (i + 1) / 4, (int)playerPos.Y - 80);
            }



            scoreSprite = new SpriteText(new Vector2(window.width / 4, 20), "000000");
        }
Esempio n. 3
0
 private static void DrawGUI()
 {
     scoreSprite.Draw();
     for (int i = 0; i < player.Lifes; i++)
     {
         GfxTools.DrawSprite(heart, (int)(window.width * (0.75f /* 3/4 */) + (i * heart.width)), 10);
     }
 }
Esempio n. 4
0
 public void Draw()
 {
     GfxTools.DrawRect((int)position.X, (int)position.Y, width, height, color.R, color.G, color.B);
 }
Esempio n. 5
0
 public void Draw()
 {
     GfxTools.DrawRect((int)(Position.X - width / 2), (int)(Position.Y - height / 2), width, height, color.R, color.G, color.B);
 }
Esempio n. 6
0
 public void Draw()
 {
     GfxTools.DrawSprite(sprite, (int)position.X, (int)position.Y);
 }