Beispiel #1
0
        // public Game() {}
        /// <summary>
        /// Prepares the game loop.
        /// </summary>
        /// <param name="ups">The desired amount of updates per second.</param>
        /// <param name="fps">The desired amount of renders per second.</param>
        /// <exception cref="System.InvalidOperationException">
        /// Thrown when the game loop has already been prepared.
        /// </exception>
        /// <exception cref="System.ArgumentException">
        /// Thrown when 'ups' is equal to or smaller than 0.
        ///  - OR - 
        /// Thrown when 'fps' is equal to or smaller than 0.
        /// </exception>
        protected void PrepareGameLoop(int ups, int fps)
        {
            if (this.m_GameTime != null)
                new InvalidOperationException("The game loop has already been prepared.");
            if (ups <= 0)
                new ArgumentException("'" + nameof(ups) + "' cannot be equal to or smaller than 0.", nameof(ups));
            if (fps <= 0)
                new ArgumentException("'" + nameof(fps) + "' cannot be equal to or smaller than 0.", nameof(fps));

            this.m_GameTime = new GameTime(ups, fps);
            Application.Idle += (sender, arguments) => this.Run();
        }
Beispiel #2
0
 /// <summary>
 /// Reports the game's current state.
 /// </summary>
 protected virtual void Report(GameTime time)
 {
 }