You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/tutorials/building_2d_games/01_what_is_monogame/index.md
+5-5Lines changed: 5 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -17,11 +17,11 @@ The official first release of MonoGame occurred in 2011, as an open-source versi
17
17
18
18
Today, MonoGame is a mature cross-platform framework, that is built with the spirit of preserving XNA while adopting modern game development practices. Some popular titles created using MonoGame includes [Celeste](https://store.steampowered.com/app/504230/Celeste/), [Stardew Valley](https://store.steampowered.com/app/413150/Stardew\_Valley/), and [Streets of Rage 4](https://store.steampowered.com/app/985890/Streets\_of\_Rage\_4/).
Copy file name to clipboardExpand all lines: articles/tutorials/building_2d_games/02_getting_started/index.md
+43-27Lines changed: 43 additions & 27 deletions
Original file line number
Diff line number
Diff line change
@@ -8,32 +8,35 @@ Unlike game engines, MonoGame is a *framework*. This means it does not come as a
8
8
***Flexibility**: Developers are not locked into using a specific editor or interface, allowing them to use their preferred development tools.
9
9
***Integration**: As a .NET library itself, MonoGame can easily integrate with other .NET libraries and tools.
10
10
***Cross-platform Development**: Since C# is cross-platform, and MonoGame is cross-platform, developers can develop MonoGame projects on Windows, macOS, or Linux, with only slight differences in the setup process for each operating system.
11
-
***Version Control Friendly**: The code-first approach makes it easier to use version control systems like Git for you game projects.
11
+
***Version Control Friendly**: The code-first approach makes it easier to use version control systems like Git for your game projects.
12
12
13
13
While the environment setup process is similar to the standard setup process for C# development, there are some MonoGame specific steps. These can vary slightly depending on your operating system and the *Integrated Development Environment* (IDE).
14
14
15
15
## Installing the .NET SDK
16
16
17
-
The first thing we need to do is install the .NET *Software Development Kit* (SDK). At the time of this writing, MonoGame targets the .NET 8.0 SDK.
17
+
The first thing we need to do is install the .NET *Software Development Kit* (SDK). To install it, follow the instructions based on your operating system below:
18
18
19
-
> [!NOTE]
20
-
> At the time of writing this tutorial, .NET 9.0 is released, however this tutorial still recommends installing .NET 8.0 for two reasons
21
-
>
22
-
> 1. .NET 8.0 is the current Long-Term Support (LTS) release of .NET. This means it receives security updates and bug fixes for 3 years, while Standard-Term Support (STS) releases like .NET 9.0 provide a shorter support window, typically around 18 months. For more information see the [.NET and .NET Core official support policy](https://dotnet.microsoft.com/en-us/platform/support/policy/dotnet-core#cadence) page.
23
-
> 2. MonoGame targets the LTS version of .NET, meaning it targets .NET 8.0, so we are using the same version for consistency.
24
-
25
-
To install it, follow the instructions based on your operating system below
19
+
> [!IMPORTANT]
20
+
> As of MonoGame 3.8.2, the minimum supported version of the .NET SDK is .NET 8.
26
21
27
22
### [Windows](#tab/windows)
28
23
29
24
1. Open a web browser and navigate to https://dotnet.microsoft.com/en-us/download.
30
-
2. Click the *Download .NET SDK x64* button to start the download of the .NET SDK Installer.
25
+
2. Choose the version of the .NET SDK to install and click the **Download .NET SDK x64** button to start the download.
26
+
27
+
> [!NOTE]
28
+
> The minimum supported version is .NET 8
29
+
31
30
3. Once the download finishes, run the installer
32
31
33
32
### [macOS](#tab/macos)
34
33
35
34
1. Open a web browser and navigate to https://dotnet.microsoft.com/en-us/download.
36
-
2. Click the *Download .NET SDK x64 (Intel)* button start the download of the .NET SDK Installer
35
+
2. Choose the version of the .NET SDK to install and click lick the *Download .NET SDK x64 (Intel)* button start the download of the .NET SDK Installer.
36
+
37
+
> [!NOTE]
38
+
> The minimum supported version is .NET 8
39
+
37
40
3. Once the download finishes, run the installer.
38
41
39
42
> [!NOTE]
@@ -48,6 +51,9 @@ To install it, follow the instructions based on your operating system below
MonoGame provides project templates that can be installed to create new projects that are pre-configured to target the current version of MonoGame as a base to begin creating games. As of this writing, the current version of MonoGame targeted is 3.8.3. To install the MonoGame templates, open a *Command Prompt* or *Terminal* window and enter the following command
70
+
MonoGame provides project templates that can be installed to create new projects that are pre-configured to target the current version of MonoGame as a base to begin creating games. To install the MonoGame templates, open a *Command Prompt* or *Terminal* window and enter the following command
65
71
66
72
```sh
67
73
dotnet new install MonoGame.Templates.CSharp
@@ -84,7 +90,7 @@ To install VSCode, follow the instructions for your operating system below:
84
90
1. Open a web browser and navigate to https://code.visualstudio.com/.
85
91
2. Click the *Download for macOS* button to start the download of the *.zip* archive.
86
92
3. Once the download finishes, double click the *.zip* archive to extract the *Visual Studio Code.app* application package
87
-
4. Drag-and-drop the *Visual Studio Code.app* application package into your *Application*directory to make it available in the macOS *LaunchPad*.
93
+
4. Drag-and-drop the *Visual Studio Code.app* application package into your *Application*folder to make it available in the macOS *LaunchPad*.
88
94
89
95
### [Linux](#tab/linux)
90
96
@@ -117,6 +123,10 @@ To install the C# Dev Kit extension, perform the following:
117
123
3. Enter `C#` in the *Search Box*
118
124
4. Click install for the *C# Dev Kit* extension.
119
125
126
+
||
|**Figure 2-1: The C# Dev Kit Extension listed in Visual Studio Code**|
129
+
120
130
> [!NOTE]
121
131
> When you search `C#` in the *Extension Panel* you may notice there is the C# Dev Kit extension and a base standard C# extension. When installing the C# Dev Kit extension, the base extension will also be installed as a requirement.
> After performing these steps, a new directory called *.winemonogame* will be created in your home directory. If you ever wish to undo the setup performed by this script, you can simply delete this directory.
163
+
> After performing these steps, a new folder called *.winemonogame* will be created in your home folder. If you ever wish to undo the setup performed by this script, you can simply delete this folder.
> After performing these steps, a new directory called *.winemonogame* will be created in your home directory. If you ever wish to undo the setup performed by this script, you can simply delete this directory.
175
+
> After performing these steps, a new folder called *.winemonogame* will be created in your home folder. If you ever wish to undo the setup performed by this script, you can simply delete this folder.
166
176
167
177
---
168
178
@@ -180,17 +190,17 @@ With your development environment setup, it is time to create your first MonoGam
180
190
181
191
After selecting *Create Project*, a new C# project will be generated based on the chosen MonoGame template and opened automatically in VSCode.
182
192
183
-
||
184
-
| :---: |
185
-
|**Figure 2-1: A new MonoGame project after being created in Visual Studio Code**|
193
+
||
|**Figure 2-2: A new MonoGame project after being created in Visual Studio Code**|
186
196
187
197
Now that we have the project created, press the `F5` key on your keyboard, or choose *Run > Start Debugging* from the top menu. If prompted for a configuration, choose *C#*. The project will compile and run, displaying a screen similar to the following:
188
198
189
-
||
190
-
| :---: |
191
-
|**Figure 2-2: The default MonoGame cornflower blue game window**|
199
+
||
|**Figure 2-3: The default MonoGame cornflower blue game window**|
192
202
193
-
Be amazed, the default MonoGame Cornflower Blue game window. You have just created your very first MonoGame application. While there isn't much happening here visually, there is a log going on behind the scenes that the MonoGame framework is handling for you. When you ran the application, the following occurred:
203
+
Be amazed, the default MonoGame Cornflower Blue game window. You have just created your very first MonoGame application. While there is not much happening here visually, there is a log going on behind the scenes that the MonoGame framework is handling for you. When you ran the application, the following occurred:
194
204
195
205
1. The application started
196
206
2. The game window was created and graphics were initialized
@@ -209,7 +219,7 @@ You can exit the game at any time by pressing the `Esc` key on your keyboard.
209
219
210
220
## Conclusion
211
221
212
-
Let's review what you accomplished in this chapter:
222
+
In this chapter, you accomplished the following:
213
223
214
224
* You setup your operating system to develop .NET applications by installing the .NET SDK
215
225
* You installed the MonoGame project templates.
@@ -220,16 +230,22 @@ Now that your development environment is setup and ready to go, you can dive in
220
230
221
231
## Test Your Knowledge
222
232
223
-
1. What version of the .NET SDK is currently targeted by MonoGame applications?
233
+
1. What are two advantages of MonoGame being a framework rather than an engine?
224
234
225
235
:::question-answer
226
-
.NET 8.0
236
+
Any two of the following:
237
+
238
+
- Flexibility: Developers can use their preferred development tools
239
+
- Integration: MonoGame easily integrates with other .NET libraries
240
+
- Cross-platform Development: Projects can be developed on Windows, macOS, or Linux
241
+
- Version Control Friendly: The code-first approach works well with systems like Git
242
+
227
243
:::
228
244
229
-
2. What is the current version of MonoGame?
245
+
2. What is the primary reason that game applications implement a *game loop* structure instead of using an event-based approach like traditional desktop applications?
230
246
231
247
:::question-answer
232
-
3.8.3
248
+
Game application implement a *game loop* structure because games need to continuously update and render, event when there is no user input. In games, objects might be moving, animations playing, and physics calculating regardless of user interaction, requiring constant updating and rendering until the game is told to exit.
233
249
:::
234
250
235
251
3. What is the color of the game window when you run a MonoGame project for the first time?
Copy file name to clipboardExpand all lines: articles/tutorials/building_2d_games/03_the_game1_file/index.md
+22-11Lines changed: 22 additions & 11 deletions
Original file line number
Diff line number
Diff line change
@@ -9,8 +9,8 @@ After you created a new MonoGame project using the *MonoGame Cross-Platform Desk
9
9
10
10
At the core of a MonoGame project is the [**Game**](xref:Microsoft.Xna.Framework.Game) class. This class handles the initialization of graphics services, initialization of the game, loading content, updating, and rendering the game. When you create a new Monogame project, this [**Game**](xref:Microsoft.Xna.Framework.Game) class is implemented as the `Game1` class that you can customize as needed for your specific game.
11
11
12
-
> [!TIP]
13
-
> While the default template names the class `Game1`, you're free to rename it to something more appropriate for your project. However, for consistency, the documentation will continue to refer to it as `Game1`.
12
+
> [!TIP]
13
+
> While the default template names the class `Game1`, you are free to rename it to something more appropriate for your project. However, for consistency, the documentation will continue to refer to it as `Game1`.
14
14
15
15
Locate the *Game1.cs* file that was generated when you created the MonoGame project and open it. The default content will be:
16
16
@@ -26,8 +26,8 @@ This class provides the following structure:
26
26
Figure 3-1 below shows the lifecycle of a MonoGame game including the [**Update**](xref:Microsoft.Xna.Framework.Game.Update(Microsoft.Xna.Framework.GameTime)) and [**Draw**](xref:Microsoft.Xna.Framework.Game.Draw(Microsoft.Xna.Framework.GameTime)) methods that make up the *game loop*.
27
27
28
28
||
After that, the [**Initialize**](xref:Microsoft.Xna.Framework.Game.Initialize) method executes, providing a dedicated place for additional configuration and initializations.
46
+
After that, the [**Initialize**](xref:Microsoft.Xna.Framework.Game.Initialize) method executes, providing a dedicated place for additional configuration and initializations.
@@ -73,18 +73,29 @@ The [**Update**](xref:Microsoft.Xna.Framework.Game.Update(Microsoft.Xna.Framewor
73
73
The first line is executing the [**Clear**](xref:Microsoft.Xna.Framework.Graphics.GraphicsDevice.Clear(Microsoft.Xna.Framework.Color)) method of the [**GraphicsDevice**](xref:Microsoft.Xna.Framework.Graphics.GraphicsDevice) property using the color [**CornflowerBlue**](xref:Microsoft.Xna.Framework.Color.CornflowerBlue). Recall that the [**GraphicsDevice**](xref:Microsoft.Xna.Framework.Graphics.GraphicsDevice) object is your direct interface between the game and what is rendered to the screen. Every time the [**Draw**](xref:Microsoft.Xna.Framework.Game.Draw(Microsoft.Xna.Framework.GameTime)) method is called, this line of code of erasing the contents of the game window and refilling it with the color specified. Without clearing the contents of the screen first, every draw call would draw the new frame render over top of the previous render, and you'd end up with something like the old solitaire win screen
74
74
75
75
||
76
-
| :---: |
77
-
|**Figure 3-2: Windows XP Solitaire Win Screen**|
78
-
79
-
While this can make for a neat effect, it is not something you want all the time. So, the screen is cleared and refilled with a solid color. You can test this yourself by modifying the code to use a different color, such as [**Color.MonoGameOrange**](xref:Microsoft.Xna.Framework.Color.MonoGameOrange), then running the game. (yes, there is a MonoGame Orange color).
While this can make for a neat effect, it is not something you want all the time. So, the screen is cleared and refilled with a solid color.
80
+
81
+
> [!NOTE]
82
+
> You can test this yourself by modifying the code to use a different color, such as [**Color.MonoGameOrange**](xref:Microsoft.Xna.Framework.Color.MonoGameOrange). (yes, there is a MonoGame Orange color).
> After making this change and running the game, the screen is cleared to the MonoGame Orange color.
87
+
>
88
+
> ||
89
+
> | :---: |
90
+
> |**Figure 3-3: The game window clearing the screen using the MonoGame Orange color**|
80
91
81
92
Each time the game loops completes and the game is drawn to the screen, we call this a *frame*. So if MonoGame is running the game loop at 60 frames per second, that means it is performing and update and a render of each frame in 16ms. Notice that both the [**Update**](xref:Microsoft.Xna.Framework.Game.Update(Microsoft.Xna.Framework.GameTime)) and the [**Draw**](xref:Microsoft.Xna.Framework.Game.Draw(Microsoft.Xna.Framework.GameTime)) methods both receive a parameter of the type [**GameTime**](xref:Microsoft.Xna.Framework.GameTime). The [**GameTime**](xref:Microsoft.Xna.Framework.GameTime) parameter provides a snapshot of the timing values for the game, including the amount of time that it took for the previous frame to execute. This is commonly referred to as the *delta time*.
82
93
83
94
*Delta time* allows you to track time accurately for things such as animations and events based on *game time* and not the speed of the processor (CPU) on the machine running the game. While in ideal circumstances, the delta time will always be 16ms, there are any number of things that could cause a temporary slow down or hiccup in a frame, and using the delta time ensures that timing based events are always correct.
84
95
85
96
## Conclusion
86
97
87
-
Here is a review of what was accomplished in this chapter:
98
+
In this chapter, you accomplished the following:
88
99
89
100
- You read through the default code provided in a *Game1.cs* file created by a MonoGame template.
90
101
- You learned about the lifecycle of a MonoGame game project.
@@ -97,7 +108,7 @@ In the next chapter, you will start working with sprites and learn how to load a
97
108
1. Can the `Game1` class be renamed or is it required to be called `Game1`
98
109
99
110
:::question-answer
100
-
It is not a requirement that it be called `Game1`. This is just the default name given to it by the templates when creating a new MonoGame game project.
111
+
It is not a requirement that it be called `Game1`. This is just the default name given to it by the templates when creating a new MonoGame game project.
101
112
:::
102
113
103
114
2. What is the [**SpriteBatch**](xref:Microsoft.Xna.Framework.Graphics.SpriteBatch) used for?
0 commit comments