/// <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(); } }
/// <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(); } }
/// <summary> /// Initializes the specified app. /// </summary> /// <param name="app">The app.</param> protected override void Initialize(GameApplication app) { base.Initialize(app); string problemPath = app.Configuration.CustomItems. Where(x => x.Name == ProblemConfig). Select(x => x.Value).SingleOrDefault(); string resolutionPath = app.Configuration.CustomItems. Where(x => x.Name == ResolutionConfig). Select(x => x.Value).SingleOrDefault(); IScript problemScript = FindScriptByPath(problemPath); problemScript.LoadOrExecute(); _resolutionScript = FindScriptByPath(resolutionPath); }
/// <summary> /// Initializes the specified app. /// </summary> /// <param name="app">The app.</param> protected virtual void Initialize(GameApplication app) { Tutano.ApplyCustomConfigurators(); app.Configure(Tutano.Configuration); Tutano.InitializeGameStates(); }
/// <summary> /// Runs the specified app. /// </summary> /// <param name="app">The app.</param> public override void Run(GameApplication app) { Initialize(app); GameLoop(app); }
/// <summary> /// Games the loop. /// </summary> /// <param name="app">The app.</param> protected override void GameLoop(GameApplication app) { if (World == null) return; CreateGameState(app); LoadScripts(); BeginKarelTask(); Root.Instance.FrameEvent.FrameRenderingQueued += OnFrameRenderingQueued; Root.Instance.StartRendering(); }
/// <summary> /// Creates the state of the game. /// </summary> /// <param name="app">The app.</param> private void CreateGameState(GameApplication app) { var state = new KarelGameState("MainState"); app.StateMachine.Add("MainState", state); app.StateMachine.CurrentStateName = "MainState"; state.Components.Add("KarelWorld", World); state.Initialize(); }
/// <summary> /// Configures the specified app. /// </summary> /// <param name="app">The app.</param> /// <param name="states">The states.</param> public void Configure(GameApplication app, GameStateMachine states) { }
/// <summary> /// Initializes the self. /// </summary> /// <param name="app">The app.</param> protected override void InitializeSelf(GameApplication app) { SceneNode worldSceneNode = Parent.SceneNode; SceneNode = worldSceneNode.CreateChildSceneNode(); SceneNode.Position = new Vector3(WorldPosition.X, 0, WorldPosition.Y); Entity robot = SceneManager.CreateEntity("robot.mesh"); SceneNode robotNode = SceneNode.CreateChildSceneNode(); robotNode.AttachObject(robot); robotNode.Scale = new Vector3(0.02f, 0.02f, 0.02f); robotNode.Orientation = Quaternion.CreateFromAxisAngle(Vector3.Up, (float)(Math.PI / 2f)); switch (Direction) { case KarelDirection.West: TurnLeft(); TurnLeft(); TurnLeft(); break; case KarelDirection.North: TurnLeft(); TurnLeft(); break; case KarelDirection.East: TurnLeft(); break; case KarelDirection.South: break; } }