Beispiel #1
0
        /// <summary>
        /// Run the specified game.
        /// </summary>
        /// <param name="game">Game to run.</param>
        public virtual void Run(Game game)
        {
            GameTree.SetRunningGame(game);

            // - Initialize windows manager
            Windows.Initialize();

            // - Make a new window
            Window.Make();
            Window.Show();

            // - Initialize input apis
            Input.Initialize();

            // - Add services
            GameTree.AddService(Input.GetSettings(PhysicsGameLoop));
            GameTree.AddService(Windows.GetSettings(PhysicsGameLoop));

            // - Load the game
            GameTree.Initialize();

            // - Start gameloops
            PhysicsGameLoop.Run();
            InputGameLoop.Run();
        }
Beispiel #2
0
 /// <summary>
 /// Closes the running game, if there's no game running do nothing.
 /// </summary>
 public virtual void Close()
 {
     if (Running)
     {
         // - Stop all loops
         InputGameLoop.Stop();
         UpdateGameLoop.Stop();
         GraphicGameLoop.Stop();
     }
 }
Beispiel #3
0
        /// <summary>
        /// Close the running game.
        /// </summary>
        public virtual void Close()
        {
            if (!GameTree.CloseGame())
            {
                return;
            }

            PhysicsGameLoop.Stop();
            InputGameLoop.Stop();
        }
Beispiel #4
0
        /// <summary>
        /// Start the game loop, this function will block the executing
        /// context.
        /// </summary>
        public virtual void Run(Game game)
        {
            // - Cannot run many games at the same time
            if (RunningGame != null)
            {
                return;
            }

            // - Set the game
            RunningGame = game;

            // - Start update loop
            UpdateGameLoop.Run();

            // - Start render loop
            GraphicGameLoop.Run();

            // - Start input loop (blocking call)
            InputGameLoop.Run();

            // - Wait for loop finish
            UpdateGameLoop.CurrentThread.Join();
            GraphicGameLoop.CurrentThread.Join();
        }