Skip to content

Commit 614d966

Browse files
authored
Add current level hot reloading, during DEBUG, using F5 (#108)
1 parent b5d255d commit 614d966

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

Platformer2D/Core/Screens/GameplayScreen.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ private string GetLevelStats(string messageTitle)
252252

253253
/// <summary>
254254
/// Processes player input and updates game state accordingly.
255-
/// Handles pausing, level continuation, and player actions.
255+
/// Handles pausing, hot level reloading, level continuation, and player actions.
256256
/// </summary>
257257
/// <param name="gameTime">Provides a snapshot of timing values.</param>
258258
/// <param name="inputState">Current input state for all input devices.</param>
@@ -288,6 +288,14 @@ public override void HandleInput(GameTime gameTime, InputState inputState)
288288
}
289289
else
290290
{
291+
// Hot level reloading
292+
#if DEBUG
293+
if (inputState.IsNewKeyPress(Keys.F5, null, out PlayerIndex index))
294+
{
295+
ReloadCurrentLevel();
296+
}
297+
#endif
298+
291299
// update our level, passing down the GameTime along with all of our input states
292300
level.Update(gameTime,
293301
inputState,

0 commit comments

Comments
 (0)