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()) { // 1 second has passed - display last captured ups and fps win.Title = "Galaga | UPS: " + gameTimer.CapturedUpdates + ", FPS: " + gameTimer.CapturedFrames; } } }
private void Die() { GalagaBus.GetBus().RegisterEvent( GameEventFactory <object> .CreateGameEventForAllProcessors( GameEventType.GameStateEvent, this, "CHANGE_STATE", "GAME_OVER", "")); }
public LifeBar() { GalagaBus.GetBus().Subscribe(GameEventType.PlayerEvent, this); for (int i = 1; i < 4; i++) { playerLives.Add(new PlayerLife( new StationaryShape( new Vec2F(0f, 0f), new Vec2F(0.05f, 0.05f)), i)); } }
public Game() { win = new Window("Film", 500, 500); gameTimer = new GameTimer(60, 144); GalagaBus.GetBus().InitializeEventBus(new List <GameEventType> { GameEventType.InputEvent, GameEventType.WindowEvent, GameEventType.PlayerEvent, GameEventType.GameStateEvent }); win.RegisterEventBus(GalagaBus.GetBus()); GalagaBus.GetBus().Subscribe(GameEventType.WindowEvent, this); stateMachine = new StateMachine(); GalagaBus.GetBus().Subscribe(GameEventType.GameStateEvent, stateMachine); GalagaBus.GetBus().Subscribe(GameEventType.InputEvent, stateMachine); }
public Player(DynamicShape shape) : base(shape, Player.stride) { GalagaBus.GetBus().Subscribe(GameEventType.PlayerEvent, this); lives = 3; }