Пример #1
0
    public void GameLoop()
    {
        while (win.IsRunning())
        {
            gameTimer.MeasureTime();
            while (gameTimer.ShouldUpdate())
            {
                win.PollEvents();
                GalagaBus.GetBus().ProcessEvents();
                stateMachine.ActiveState.UpdateGameLogic();
            }

            if (gameTimer.ShouldRender())
            {
                win.Clear();
                stateMachine.ActiveState.RenderState();
                win.SwapBuffers();
            }

            if (gameTimer.ShouldReset())
            {
                win.Title = "Galaga | UPS: " + gameTimer.CapturedUpdates +
                            ", FPS: " + gameTimer.CapturedFrames;
            }
        }
    }
Пример #2
0
        public void GameLoop()
        {
            while (win.IsRunning())
            {
                gameTimer.MeasureTime();
                while (gameTimer.ShouldUpdate())
                {
                    win.PollEvents();
                    // Update game logic here
                    player.Move();
                    eventBus.ProcessEvents();
                    stateMachine.ActiveState.RenderState();
                    win.SwapBuffers();
                }

                if (gameTimer.ShouldRender())
                {
                    win.Clear();
                    // Render gameplay entities here
                }
                if (gameTimer.ShouldReset())
                {
                    // 1 second has passed - display last captured ups and fps
                    win.Title = "Galaga | UPS: " + gameTimer.CapturedUpdates + ", FPS: " + gameTimer.CapturedFrames;
                }
            }
        }
Пример #3
0
 public void GameLoop()
 {
     while (win.IsRunning())
     {
         gameTimer.MeasureTime();
         if (gameState == GameState.GamePlaying)
         {
             while (gameTimer.ShouldUpdate())
             {
                 eventBus.ProcessEvents();
                 win.PollEvents();
                 UpdateEnemies();
                 player.Move();
                 IterateShots();
                 ExitGameOver();
                 currentMoveStrategy.MoveEnemies(enemies);
             }
             if (gameTimer.ShouldRender())
             {
                 win.Clear();
                 player.Entity.RenderEntity();
                 enemies.RenderEntities();
                 playerShots.RenderEntities();
                 explosions.RenderAnimations();
                 score.RenderScore();
                 win.SwapBuffers();
             }
             if (gameTimer.ShouldReset())
             {
                 win.Title = "Galaga | Ups: " + gameTimer.CapturedUpdates + ", FPS: " + gameTimer.CapturedFrames;
             }
         }
         else
         {
             win.Clear();
             GameOverDisPlay.RenderGameOverDisPlay(score.score);
             win.SwapBuffers();
             while (gameTimer.ShouldUpdate())
             {
                 eventBus.ProcessEvents();
                 win.PollEvents();
             }
         }
     }
 }
Пример #4
0
        public void GameLoop()
        {
            while (win.IsRunning())
            {
                gameTimer.MeasureTime();
                while (gameTimer.ShouldUpdate())
                {
                    win.PollEvents(); // Update game logic
                }

                if (gameTimer.ShouldRender())
                {
                    win.Clear();
                    // Render player
                    player.RenderEntity();
                    // Render enemies
                    foreach (var ene in enemies)
                    {
                        ene.RenderEntity();
                    }

                    //Shots
                    IterateShots();

                    //Explosions, score and win
                    explosions.RenderAnimations();
                    score.RenderScore();
                    win.SwapBuffers();
                }

                if (gameTimer.ShouldReset())
                {
                    // 1 second has passed - display last captured ups and fps
                    win.Title = "Galaga | UPS: " + gameTimer.CapturedUpdates + ", FPS: " +
                                gameTimer.CapturedFrames;
                }
                eventBus.ProcessEvents();
            }
        }
Пример #5
0
    public void GameLoop()
    {
        while (win.IsRunning())
        {
            gameTimer.MeasureTime();
            while (gameTimer.ShouldUpdate())
            {
                win.PollEvents();
                // Update game logic here
                player.Move();
                eventBus.ProcessEvents();
            }

            if (gameTimer.ShouldRender())
            {
                win.Clear();
                // Render gameplay entities here
                player.Entity.RenderEntity();
                foreach (Enemy enemy in enemies)
                {
                    enemy.RenderEntity();
                }
                foreach (PlayerShot shot in playerShots)
                {
                    shot.RenderEntity();
                }
                IterateShots();
                explosions.RenderAnimations();
                score.RenderScore();
                win.SwapBuffers();
            }
            if (gameTimer.ShouldReset())
            {
                // 1 second has passed - display last captured ups and fps
                win.Title = "Galaga | UPS: " + gameTimer.CapturedUpdates + ", FPS: " + gameTimer.CapturedFrames;
            }
        }
    }
Пример #6
0
 public void GameLoop()
 {
     while (win.IsRunning())
     {
         gameTimer.MeasureTime();
         while (gameTimer.ShouldUpdate())
         {
             eventBus.ProcessEvents();
             win.PollEvents();
         }
         if (gameTimer.ShouldRender())
         {
             win.Clear();
             player.Entity.RenderEntity();
             score.RenderScore();
             player.Move();
             foreach (var enemy in enemies)
             {
                 enemy.Entity.RenderEntity();
             }
             PlayerShot.iterateShots();
             foreach (var shot in PlayerShots)
             {
                 shot.Entity.RenderEntity();
             }
             newEnemies();
             PlayerShots = PlayerShot.updateShot();
             win.SwapBuffers();
         }
         if (gameTimer.ShouldReset())
         {
             win.Title = "galga | UPS" + gameTimer.CapturedUpdates +
                         ", FPS " + gameTimer.CapturedUpdates;
         }
     }
 }