public void TestSenderReceiver() { _sender.SendEvent(_eventBus, _receiver1, 1); _sender.SendEvent(_eventBus, _receiver2, 2); _eventBus.ProcessEvents(); Assert.AreEqual(1, _receiver1.Value); Assert.AreEqual(2, _receiver2.Value); }
public void TestEventBusSimpleCount5Test() { _eb.RegisterEvent(_eventControl); _eb.RegisterEvent(_eventSound); _eb.RegisterEvent(_eventControl); _eb.RegisterEvent(_eventControl); _eb.RegisterEvent(_eventSound); _eb.ProcessEvents(); Assert.That(_simpleEventProcessor.EventCounterControl == 3); Assert.That(_simpleEventProcessor.EventCounterSound == 2); }
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; } } }
public void GameLoop() { while (win.IsRunning()) { gameTimer.MeasureTime(); while (gameTimer.ShouldUpdate()) { win.PollEvents(); eventBus.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 from the timer win.Title = "Space Taxi | UPS: " + gameTimer.CapturedUpdates + ", FPS: " + gameTimer.CapturedFrames; } } }
public void GameLoop() { while (_win.IsRunning()) { _gameTimer.MeasureTime(); while (_gameTimer.ShouldUpdate()) { _win.PollEvents(); _eventBus.ProcessEvents(); } if (_gameTimer.ShouldRender()) { _win.Clear(); //SplattStuff _backGroundImage.RenderEntity(); maps[0].RenderEntities(); _player.RenderPlayer(); _win.SwapBuffers(); } if (_gameTimer.ShouldReset()) { // 1 second has passed - display last captured ups and fps from the timer _win.Title = "Space Taxi | UPS: " + _gameTimer.CapturedUpdates + ", FPS: " + _gameTimer.CapturedFrames; } } }
public void GameLoop() { while (win.IsRunning()) { win.PollEvents(); gameTimer.MeasureTime(); while (gameTimer.ShouldUpdate()) { eventBus.ProcessEvents(); ItterateShots(); player.Move(); movementStrategy.MoveEnemies(enemies); } if (gameTimer.ShouldRender()) { win.Clear(); backGround.Render(new StationaryShape( new Vec2F(0.0f, 0.0f), new Vec2F(1.0f, 1.0f))); playerShots.RenderEntities(); enemies.RenderEntities(); explosions.RenderAnimations(); player.Entity.RenderEntity(); win.SwapBuffers(); } if (gameTimer.ShouldReset()) { win.Title = "Galaga | UPS: " + gameTimer.CapturedUpdates + ", FPS: " + gameTimer.CapturedFrames; } } }
public void GameLoop() { while (win.IsRunning()) { gameTimer.MeasureTime(); while (gameTimer.ShouldUpdate()) { win.PollEvents(); eventBus.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; } } }
public void TestRegisterTimedEvent() { var e = new GameEvent { EventType = GameEventType.TimedEvent, From = this, To = _helper }; _eventBus.RegisterTimedEvent(e, TimePeriod.NewMilliseconds(500)); _eventBus.ProcessEvents(); Assert.AreEqual(0, _helper.EventCounter); Thread.Sleep(550); _eventBus.ProcessEvents(); Assert.AreEqual(1, _helper.EventCounter); }
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(); } } } }
public void GameLoop() { while (win.IsRunning()) { win.PollEvents(); win.Clear(); bus.ProcessEvents(); win.SwapBuffers(); } }
public void GameLoop() { while (win.IsRunning()) { win.PollEvents(); win.Clear(); bus.ProcessEvents(); player.RenderEntity(); wall.RenderEntity(); win.SwapBuffers(); } }
/// <summary> /// GameLoop utilizes the GameTimer class to ensure that the game runs at a steady speed on all systems. /// We update both rendering and game logic in the loop. The speed of the updates are specified in the gameTimer object. /// </summary> public void GameLoop() { //AddEnemies(); row.CreateEnemies(enemyStrides); while (win.IsRunning()) { gameTimer.MeasureTime(); while (gameTimer.ShouldUpdate()) { win.PollEvents(); eventBus.ProcessEvents(); player.Move(); movementStrategy.MoveEnemies(row.Enemies); IterateShots(); } if (gameTimer.ShouldRender()) { win.Clear(); player.entity.RenderEntity(); row.Enemies.Iterate(entity => entity.RenderEntity()); foreach (var shot in playerShots) { shot.RenderEntity(); } 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; } } }
public void GameLoop() { while (win.IsRunning()) { //Timer gameTimer.MeasureTime(); //EventUpdate while (gameTimer.ShouldUpdate()) { win.PollEvents(); eventBus.ProcessEvents(); state.ActiveState.UpdateGameLogic(); } //Render if (gameTimer.ShouldRender()) { win.Clear(); state.ActiveState.RenderState(); // foreach (var squadron in squadronContainer) { // squadron.Move(); // squadron.Enemies.RenderEntities(); // } // // Projectile.IterateShot(player.Projectiles,squadronContainer); // // explosions.RenderAnimations(); // // player.Update(); win.SwapBuffers(); } if (gameTimer.ShouldReset()) { win.Title = "Galaga | UPS: " + gameTimer.CapturedUpdates + ", FPS: " + gameTimer.CapturedFrames; } } }
public void GameLoop() { while (win.IsRunning()) { gameTimer.MeasureTime(); while (gameTimer.ShouldUpdate()) { win.PollEvents(); eventBus.ProcessEvents(); player.Entity.Shape.Move(); } if (gameTimer.ShouldRender()) { win.Clear(); player.Entity.RenderEntity(); enemies.RenderEntities(); playerShots.RenderEntities(); explosions.RenderAnimations(); foreach (Entity playerShot in playerShots) { playerShot.Shape.MoveY(0.010f); } playerShots.Iterate(IterateShots); win.SwapBuffers(); } if (gameTimer.ShouldReset()) { win.Title = "Galaga | UPS: " + gameTimer.CapturedUpdates + ", FPS: " + gameTimer.CapturedFrames; } } }
public void GameLoop() { while (win.IsRunning()) { //Timer gameTimer.MeasureTime(); //EventUpdate while (gameTimer.ShouldUpdate()) { win.PollEvents(); eventBus.ProcessEvents(); } //Render if (gameTimer.ShouldRender()) { win.Clear(); IterateShot(); enemies.RenderEntities(); explosions.RenderAnimations(); player.Update(); win.SwapBuffers(); } if (gameTimer.ShouldReset()) { win.Title = "Galaga | UPS: " + gameTimer.CapturedUpdates + ", FPS: " + gameTimer.CapturedFrames; } } }
/// <summary> /// GameLoop utilizes the GameTimer class to ensure that the game runs at a steady speed on all systems. /// We update both rendering and game logic in the loop. The speed of the updates are specified in the gameTimer object. /// </summary> public void GameLoop() { AddEnemies(); while (win.IsRunning()) { gameTimer.MeasureTime(); while (gameTimer.ShouldUpdate()) { win.PollEvents(); eventBus.ProcessEvents(); player.Move(); IterateShots(); } if (gameTimer.ShouldRender()) { win.Clear(); player.RenderEntity(); foreach (var enemy in enemies) { enemy.RenderEntity(); } foreach (var shot in playerShots) { shot.RenderEntity(); } explosions.RenderAnimations(); score.RenderScore(); win.SwapBuffers(); } } }
public void GameLoop() { while (win.IsRunning()) { gameTimer.MeasureTime(); while (gameTimer.ShouldUpdate()) { win.PollEvents(); player.Move(); eventBus.ProcessEvents(); IterateShots(); enemies = newEnemies; newEnemies = new List <Enemy>(); playerShots = newPlayerShots; newPlayerShots = new List <PlayerShot>(); } if (gameTimer.ShouldRender()) { win.Clear(); player.RenderEntity(); foreach (Enemy element in enemies) { element.RenderEntity(); } foreach (var elem in playerShots) { elem.RenderEntity(); } explosions.RenderAnimations(); score.RenderScore(); win.SwapBuffers(); score.RenderScore(); } if (gameTimer.ShouldReset()) { win.Title = "Galaga | UPS: " + gameTimer.CapturedUpdates + ", FPS: " + gameTimer.CapturedFrames; } } }
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(); } }
public void GameLoop() { while (_win.IsRunning()) { Game.ScreenTimer.MeasureTime(); while (Game.ScreenTimer.ShouldUpdate()) { _win.PollEvents(); _eventBus.ProcessEvents(); StateMachine.ActiveState.GameLoop(); } if (Game.ScreenTimer.ShouldRender()) { _win.Clear(); _backGroundImage.RenderEntity(); StateMachine.ActiveState.RenderState(); _win.SwapBuffers(); } if (Game.ScreenTimer.ShouldReset()) { // 1 second has passed - display last captured ups and fps from the timer _win.Title = "Space Taxi | UPS: " + Game.ScreenTimer.CapturedUpdates + ", FPS: " + Game.ScreenTimer.CapturedFrames; } if (Player.GetInstance().IsExploding) { // TODO - needs delay _eventBus.RegisterEvent( GameEventFactory <object> .CreateGameEventForAllProcessors( GameEventType.GameStateEvent, this, "MAIN_MENU", "", "")); } } }
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; } } }
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; } } }
public void GameLoop() { while (win.IsRunning()) { gameTimer.MeasureTime(); while (gameTimer.ShouldUpdate()) { win.PollEvents(); eventBus.ProcessEvents(); level.Player.Move(); UpdateCustomer(); ItterateProps(); ItterateLevelSprites(); } if (gameTimer.ShouldRender()) { win.Clear(); backGroundImage.RenderEntity(); level.Player.RenderPlayer(); level.Customer.RenderCustomer(); level.LevelSprites.RenderEntities(); RenderProps(); win.SwapBuffers(); } if (gameTimer.ShouldReset()) { // 1 second has passed - display last captured ups and fps from the timer win.Title = "Space Taxi | UPS: " + gameTimer.CapturedUpdates + ", FPS: " + gameTimer.CapturedFrames; } } }
public void GameLoop() { while (win.IsRunning()) { gameTimer.MeasureTime(); while (gameTimer.ShouldUpdate()) { win.PollEvents(); player.Move(); eventBus.ProcessEvents(); IterateShots(); enemies = newEnemies; newEnemies = new List <Enemy>(); playerShots = newPlayerShots; newPlayerShots = new List <PlayerShot>(); } if (gameTimer.ShouldRender()) { win.Clear(); player.Entity.RenderEntity(); foreach (Enemy element in enemies) { element.RenderEntity(); } foreach (var elem in playerShots) { elem.RenderEntity(); } explosions.RenderAnimations(); score.RenderScore(); win.SwapBuffers(); score.RenderScore(); bool allDead = true; bool belowScreen = true; foreach (var iter in enemies) { if (!iter.IsDeleted()) { allDead = false; } if (iter.shape.Position.Y > -0.2f) { belowScreen = false; } } if (allDead || belowScreen) { if (globalMove.Equals("down")) { createEnemiesSpot = new CreateEnemiesSpot(this, enemies); createEnemiesSpot.CreateEnemies(enemyStrides); globalMove = "zigzag"; } else if (globalMove.Equals("zigzag")) { createEnemiesZig = new CreateEnemiesZig(this, enemies); createEnemiesZig.CreateEnemies(enemyStrides); globalMove = "nomove"; } } else { MoveFunction(globalMove); } } if (gameTimer.ShouldReset()) { win.Title = "Galaga | UPS: " + gameTimer.CapturedUpdates + ", FPS: " + gameTimer.CapturedFrames; } } }
public override void Update() { eventBus.ProcessEvents(); }