예제 #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
        // DRAW

        public void Draw(Window window)
        {
            if (this.state)
            {
                GfxTools.DrawSprite(window, this.position, this.spriteA);
            }
            else
            {
                GfxTools.DrawSprite(window, this.position, this.spriteB);
            }
        }
예제 #3
0
        // DRAW

        private void DrawAllBullets(Window window)
        {
            for (int i = 0; i < this.bullets.Length; i++)
            {
                if (this.bullets[i].IsFired)
                {
                    this.bullets[i].Draw(window);
                }
                if (this.bullets[i].IsExploded)
                {
                    Vector2 explosionPosition = new Vector2(bullets[i].Position.X - bullets[i].ExplosionWidth / 2, bullets[i].Position.Y - bullets[i].ExplosionHeight);
                    GfxTools.DrawSprite(window, explosionPosition, this.bullets[i].ExplosionSprite);
                }
            }
        }
예제 #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
        // DRAW

        private void DrawScore(Window window)
        {
            Vector2 position = this.position;

            for (int i = 0; i < sprites.Length; i++)
            {
                if (sprites[i] == null)
                {
                    return;
                }
                else
                {
                    GfxTools.DrawSprite(window, position, sprites[i]);
                    position.X += sprites[i].width + 2;
                }
            }
        }
예제 #6
0
        //test



        static Game()
        {
            window = new Window(1900, 1000, "Space Invaders", PixelFormat.RGB);
            score  = 0;

            GfxTools.Init(window);

            Vector2 playerPos;

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

            EnemyMgr.Init(45, 3);

            switcher = 0;

            player    = new Player(playerPos, new Color(22, 22, 200));
            scoretext = new spriteText(new Vector2(220, 48), "000000");


            PlayerSound.Play("Assets/spaceship.wav", "suono");

            //music = new SoundPlayer();
            //music.SoundLocation = "Assets/spaceship.wav";
            //music.Load();

            //music.PlayLooping();

            bg  = new backgorund("Assets/space_3.png");
            bg2 = new backgorundMenu("Assets/space_menu.png");
            m   = new Menu();

            barriers = new Barrier[3];

            for (int i = 0; i < barriers.Length; i++)
            {
                barriers[i] = new Barrier(new Vector2((GfxTools.Win.width) * (i + 1) / 4, (GfxTools.Win.height / 2) + 300));
            }

            //test
        }
예제 #7
0
        //DRAW

        public void Draw(Window window)
        {
            GfxTools.DrawRectangle(window, this.position, this.side, this.side, this.color);
        }
예제 #8
0
 public void Draw()
 {
     GfxTools.DrawRect((int)position.X, (int)position.Y, width, height, color.R, color.G, color.B);
 }
예제 #9
0
 public void Draw()
 {
     GfxTools.DrawSprite(sprite, (int)position.X, (int)position.Y);
 }
예제 #10
0
        // DRAW

        public void Draw(Window window)
        {
            GfxTools.DrawSprite(window, this.position, this.sprite);
        }
예제 #11
0
 public void Draw()
 {
     GfxTools.DrawRect((int)(Position.X - width / 2), (int)(Position.Y - height / 2), width, height, color.R, color.G, color.B);
 }