Exemplo n.º 1
0
		/// <summary>
		/// Games the loop.
		/// </summary>
		/// <param name="app">The app.</param>
		protected virtual void GameLoop(GameApplication app)
		{
			LoadScripts();

			while (app.IsRunning) {
				app.BeginScene();
				{
					foreach (var gameLogic in GameLogics) {
						gameLogic.Update(app.Timer);
					}

					IGameState currentState = app.StateMachine.Current;

					if (currentState == null)
						break;

					foreach (var gameObject in GameObjects) {
						gameObject.Update(app.Timer);
					}

					currentState.Update(app.Timer);
				}
				app.EndScene();
			}
		}
Exemplo n.º 2
0
		/// <summary>
		/// Runs the specified app.
		/// </summary>
		/// <param name="app">The app.</param>
		public void Run(GameApplication app)
		{
			var config = new Configuration {
				Screen = {
					Width = 800,
					Height = 600,
					BackgroundColor = Color.Black
				}
			};

			app.Configure(config);

			while (app.IsRunning)
			{
				var state = app.StateMachine.Current;

				if (state == null)
					break;

				app.BeginScene();
				{
					var gameTime = app.Timer;
					state.Update(gameTime);
				}
				app.EndScene();
			}
		}