From 899f2bf742e45e4edca77a2e2f12692aaade2317 Mon Sep 17 00:00:00 2001 From: Erin McLaughlin Date: Sun, 2 Jun 2024 10:59:34 -0400 Subject: [PATCH 1/2] updated docblock on GameState --- BenMakesGames.PlayPlayMini/GameState.cs | 94 ++++++++++++++----------- 1 file changed, 54 insertions(+), 40 deletions(-) diff --git a/BenMakesGames.PlayPlayMini/GameState.cs b/BenMakesGames.PlayPlayMini/GameState.cs index 69fb4e1..d283b6e 100644 --- a/BenMakesGames.PlayPlayMini/GameState.cs +++ b/BenMakesGames.PlayPlayMini/GameState.cs @@ -1,78 +1,92 @@ using Microsoft.Xna.Framework; +using BenMakesGames.PlayPlayMini.Services; namespace BenMakesGames.PlayPlayMini; /// /// Inherit this class to create your own game states. -/// -/// Change the current game's state by calling one of `GameStateManager`'s `ChangeState` methods. -/// -/// If a game state needs access to a service, such as the `GameStateManager`, `GraphicsManager`, `SoundManager`, etc., +/// +/// +/// If a game state needs access to a service, such as the , , , etc., /// include the service in the game state's constructor arguments. The IoC container will automatically inject them. +/// +/// +/// Example usage: +/// +/// public sealed class MyGameState: GameState +/// { +/// private GameStateManager GSM { get; } +/// private GraphicsManager Graphics { get; } +/// private KeyboardManager Keyboard { get; } /// -/// Example: -/// -/// public sealed class MyGameState: GameState +/// public MyGameState(GameStateManager gsm, GraphicsManager graphics, KeyboardManager keyboard) /// { -/// private GameStateManager GSM { get; } -/// private GraphicsManager Graphics { get; } -/// private KeyboardManager Keyboard { get; } -/// -/// public MyGameState(GameStateManager gsm, GraphicsManager graphics, KeyboardManager keyboard) -/// { -/// GSM = gsm; -/// Graphics = graphics; -/// Keyboard = keyboard; -/// } -/// -/// public override void Update(GameTime gameTime) -/// { -/// if(Keyboard.IsKeyDown(Keys.Escape)) -/// GSM.ChangeState<MyPauseMenu>(); // or maybe GSM.Exit(); -/// } +/// GSM = gsm; +/// Graphics = graphics; +/// Keyboard = keyboard; /// } -/// +/// +/// public override void Input(GameTime gameTime) +/// { +/// if (Keyboard.IsKeyDown(Keys.Escape)) +/// GSM.ChangeState<MyPauseMenu>(); // or maybe GSM.Exit(); +/// } +/// } +/// +/// +/// +/// public abstract class GameState { /// - /// This method is called once per frame. It's intended to be used to capture inputs from input devices, - /// such as the KeyboardManager, MouseManager, or a gamepad. Simpler games may get away with doing this - /// work in an Update method, instead. + /// Called when input should be captured from input devices. /// - /// + /// + /// Override this method to capture input from a service such as , , etc. + /// This method is called once per frame, immediately before . + /// + /// A instance containing the elapsed time since the last call to and the total time elapsed since the game started. public virtual void Input(GameTime gameTime) { } /// - /// This method is called once per frame. It's intended to be used to run your game logic. + /// Called when the game state should update /// - /// + /// + /// This method is called once per frame. + /// + /// + /// A instance containing the elapsed time since the last call to and the total time elapsed since the game started. public virtual void Update(GameTime gameTime) { } /// - /// This method is called an average of 60 times per second, regardless of the current frame rate. This can be - /// useful for certain physics-based updates. + /// Called when the game state should update. /// /// - /// If you configured your application to use a fixed time step, then Update will ALSO be called about 60 times - /// per second. In that case, there's no reason to use both Update and FixedUpdate. - /// - /// + /// This method is called an average of 60 times per second, regardless of the current frame rate. This can be useful for certain physics-based updates. + /// If your is set to , then will ALSO be called about 60 times per second. + /// In that case, there's no reason to use both and . + /// + /// See also: + /// + /// + /// + /// A instance containing the elapsed time since the last call to and the total time elapsed since the game started. public virtual void FixedUpdate(GameTime gameTime) { } /// /// This method is called once per frame. /// - /// + /// A instance containing the elapsed time since the last call to and the total time elapsed since the game started. public virtual void Draw(GameTime gameTime) { } /// - /// This method is called when the GameStateManager's current state changes to this state. It runs before the - /// first Input, Update, FixedUpdate, or Draw method is called. + /// This method is called when the 's current state changes to this state. + /// It runs before the first , , , or method is called. /// public virtual void Enter() { } /// - /// This method is called when the GameStateManager's current state changes away from this state. + /// This method is called when the 's current state changes away from this state. /// public virtual void Leave() { } } From f7e5a9edc8915750aafef77bff391f8b2273b14a Mon Sep 17 00:00:00 2001 From: Erin McLaughlin Date: Sun, 2 Jun 2024 12:51:39 -0400 Subject: [PATCH 2/2] change input docblock --- BenMakesGames.PlayPlayMini/GameState.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BenMakesGames.PlayPlayMini/GameState.cs b/BenMakesGames.PlayPlayMini/GameState.cs index d283b6e..c2e3838 100644 --- a/BenMakesGames.PlayPlayMini/GameState.cs +++ b/BenMakesGames.PlayPlayMini/GameState.cs @@ -43,7 +43,7 @@ public abstract class GameState /// /// /// Override this method to capture input from a service such as , , etc. - /// This method is called once per frame, immediately before . + /// This method is called once per frame, immediately before and . /// /// A instance containing the elapsed time since the last call to and the total time elapsed since the game started. public virtual void Input(GameTime gameTime) { }