Skip to content

Commit 35c260f

Browse files
committed
renamed to chapter 22 since adding other UI chapters
1 parent c1b2888 commit 35c260f

17 files changed

+394
-394
lines changed

articles/toc.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,8 @@
150150
href: tutorials/building_2d_games/18_texture_sampling/
151151
- name: "19: User Interface"
152152
href: tutorials/building_2d_games/19_user_interface/
153-
- name: "20: The Game"
154-
href: tutorials/building_2d_games/20_the_game/
153+
- name: "22: The Game"
154+
href: tutorials/building_2d_games/22_the_game/
155155
- name: Console Access
156156
href: console_access.md
157157
- name: Help and Support

articles/tutorials/building_2d_games/20_the_game/index.md renamed to articles/tutorials/building_2d_games/22_the_game/index.md

Lines changed: 304 additions & 304 deletions
Large diffs are not rendered by default.
Original file line numberDiff line numberDiff line change
@@ -1,87 +1,87 @@
1-
using Microsoft.Xna.Framework.Input;
2-
using MonoGameLibrary;
3-
using MonoGameLibrary.Input;
4-
5-
namespace DungeonSlime;
6-
7-
/// <summary>
8-
/// Provides a game-specific input abstraction that maps physical inputs
9-
/// to game actions, bridging our input system with game-specific functionality.
10-
/// </summary>
11-
public class GameController
12-
{
13-
private KeyboardInfo _keyboard;
14-
private GamePadInfo _gamePad;
15-
16-
/// <summary>
17-
/// Creates a new GameController that handles input for the game.
18-
/// </summary>
19-
public GameController()
20-
{
21-
_keyboard = Core.Input.Keyboard;
22-
_gamePad = Core.Input.GamePads[0];
23-
}
24-
25-
/// <summary>
26-
/// Returns true if the player has triggered the "move up" action.
27-
/// </summary>
28-
public bool MoveUp()
29-
{
30-
return _keyboard.WasKeyJustPressed(Keys.Up) ||
31-
_keyboard.WasKeyJustPressed(Keys.W) ||
32-
_gamePad.WasButtonJustPressed(Buttons.DPadUp) ||
33-
_gamePad.WasButtonJustPressed(Buttons.LeftThumbstickUp);
34-
}
35-
36-
/// <summary>
37-
/// Returns true if the player has triggered the "move down" action.
38-
/// </summary>
39-
public bool MoveDown()
40-
{
41-
return _keyboard.WasKeyJustPressed(Keys.Down) ||
42-
_keyboard.WasKeyJustPressed(Keys.S) ||
43-
_gamePad.WasButtonJustPressed(Buttons.DPadDown) ||
44-
_gamePad.WasButtonJustPressed(Buttons.LeftThumbstickDown);
45-
}
46-
47-
/// <summary>
48-
/// Returns true if the player has triggered the "move left" action.
49-
/// </summary>
50-
public bool MoveLeft()
51-
{
52-
return _keyboard.WasKeyJustPressed(Keys.Left) ||
53-
_keyboard.WasKeyJustPressed(Keys.A) ||
54-
_gamePad.WasButtonJustPressed(Buttons.DPadLeft) ||
55-
_gamePad.WasButtonJustPressed(Buttons.LeftThumbstickLeft);
56-
}
57-
58-
/// <summary>
59-
/// Returns true if the player has triggered the "move right" action.
60-
/// </summary>
61-
public bool MoveRight()
62-
{
63-
return _keyboard.WasKeyJustPressed(Keys.Right) ||
64-
_keyboard.WasKeyJustPressed(Keys.D) ||
65-
_gamePad.WasButtonJustPressed(Buttons.DPadRight) ||
66-
_gamePad.WasButtonJustPressed(Buttons.LeftThumbstickRight);
67-
}
68-
69-
/// <summary>
70-
/// Returns true if the player has triggered the "pause" action.
71-
/// </summary>
72-
public bool Pause()
73-
{
74-
return _keyboard.WasKeyJustPressed(Keys.Escape) ||
75-
_gamePad.WasButtonJustPressed(Buttons.Start);
76-
}
77-
78-
/// <summary>
79-
/// Returns true if the player has triggered the "action" button,
80-
/// typically used for menu confirmation.
81-
/// </summary>
82-
public bool Action()
83-
{
84-
return _keyboard.WasKeyJustPressed(Keys.Enter) ||
85-
_gamePad.WasButtonJustPressed(Buttons.A);
86-
}
87-
}
1+
using Microsoft.Xna.Framework.Input;
2+
using MonoGameLibrary;
3+
using MonoGameLibrary.Input;
4+
5+
namespace DungeonSlime;
6+
7+
/// <summary>
8+
/// Provides a game-specific input abstraction that maps physical inputs
9+
/// to game actions, bridging our input system with game-specific functionality.
10+
/// </summary>
11+
public class GameController
12+
{
13+
private KeyboardInfo _keyboard;
14+
private GamePadInfo _gamePad;
15+
16+
/// <summary>
17+
/// Creates a new GameController that handles input for the game.
18+
/// </summary>
19+
public GameController()
20+
{
21+
_keyboard = Core.Input.Keyboard;
22+
_gamePad = Core.Input.GamePads[0];
23+
}
24+
25+
/// <summary>
26+
/// Returns true if the player has triggered the "move up" action.
27+
/// </summary>
28+
public bool MoveUp()
29+
{
30+
return _keyboard.WasKeyJustPressed(Keys.Up) ||
31+
_keyboard.WasKeyJustPressed(Keys.W) ||
32+
_gamePad.WasButtonJustPressed(Buttons.DPadUp) ||
33+
_gamePad.WasButtonJustPressed(Buttons.LeftThumbstickUp);
34+
}
35+
36+
/// <summary>
37+
/// Returns true if the player has triggered the "move down" action.
38+
/// </summary>
39+
public bool MoveDown()
40+
{
41+
return _keyboard.WasKeyJustPressed(Keys.Down) ||
42+
_keyboard.WasKeyJustPressed(Keys.S) ||
43+
_gamePad.WasButtonJustPressed(Buttons.DPadDown) ||
44+
_gamePad.WasButtonJustPressed(Buttons.LeftThumbstickDown);
45+
}
46+
47+
/// <summary>
48+
/// Returns true if the player has triggered the "move left" action.
49+
/// </summary>
50+
public bool MoveLeft()
51+
{
52+
return _keyboard.WasKeyJustPressed(Keys.Left) ||
53+
_keyboard.WasKeyJustPressed(Keys.A) ||
54+
_gamePad.WasButtonJustPressed(Buttons.DPadLeft) ||
55+
_gamePad.WasButtonJustPressed(Buttons.LeftThumbstickLeft);
56+
}
57+
58+
/// <summary>
59+
/// Returns true if the player has triggered the "move right" action.
60+
/// </summary>
61+
public bool MoveRight()
62+
{
63+
return _keyboard.WasKeyJustPressed(Keys.Right) ||
64+
_keyboard.WasKeyJustPressed(Keys.D) ||
65+
_gamePad.WasButtonJustPressed(Buttons.DPadRight) ||
66+
_gamePad.WasButtonJustPressed(Buttons.LeftThumbstickRight);
67+
}
68+
69+
/// <summary>
70+
/// Returns true if the player has triggered the "pause" action.
71+
/// </summary>
72+
public bool Pause()
73+
{
74+
return _keyboard.WasKeyJustPressed(Keys.Escape) ||
75+
_gamePad.WasButtonJustPressed(Buttons.Start);
76+
}
77+
78+
/// <summary>
79+
/// Returns true if the player has triggered the "action" button,
80+
/// typically used for menu confirmation.
81+
/// </summary>
82+
public bool Action()
83+
{
84+
return _keyboard.WasKeyJustPressed(Keys.Enter) ||
85+
_gamePad.WasButtonJustPressed(Buttons.A);
86+
}
87+
}

0 commit comments

Comments
 (0)