Ejemplo n.º 1
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();
            }
        }
Ejemplo n.º 2
0
        //DRAW

        public void Draw(Window window)
        {
            GfxTools.DrawRectangle(window, this.position, this.side, this.side, this.color);
        }