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
+6-2Lines changed: 6 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -5,11 +5,11 @@ description: Learn about the history of MonoGame and explore the features it pro
5
5
6
6
## A Brief History
7
7
8
-
In 2006, Microsoft released a game development framework named *XNA Game Studio* to facilitate game development for Windows PC and the Xbox 360 console. It revolutionized game development for indie creators by bringing a simplified approach to building games and offering a set of tools that lowered the entry barrier for aspiring game developers. Out of XNA Game Studio came critically acclaimed titles such as [Bastion](https://www.supergiantgames.com/games/bastion/) and [Terraria](https://terraria.org/). In 2008, XNA was expanded to support development for both the Zune and Windows Phone.
8
+
In 2006, Microsoft released a game development framework named *[XNA Game Studio](https://learn.microsoft.com/en-us/previous-versions/windows/xna/bb203894(v=xnagamestudio.42))* to facilitate game development for Windows PC and the Xbox 360 console. It revolutionized game development for indie creators by bringing a simplified approach to building games and offering a set of tools that lowered the entry barrier for aspiring game developers. Out of XNA Game Studio came critically acclaimed titles such as [Bastion](https://www.supergiantgames.com/games/bastion/) and [Terraria](https://terraria.org/). In 2008, XNA was expanded to support development for both the Zune and Windows Phone.
9
9
10
10
> [!NOTE]
11
11
>
12
-
> Fun fact, provided by community member stromkos, The release of XNA 3.0 in 2008, which added the support for Windows Phone, is also the release that specified the default window resolution of 800x480 for new projects as this was the preferred resolution on Windows Phone. [It is still the default resolution used in MonoGame projects today](https://github.com/MonoGame/MonoGame/blob/8b35cf50783777507cd6b21828ed0109b3b07b50/MonoGame.Framework/GraphicsDeviceManager.cs#L44).
12
+
> Fun fact, provided by community member [stromkos](https://github.com/stromkos), The release of XNA 3.0 in 2008, which added the support for Windows Phone, is also the release that specified the default window resolution of 800x480 for new projects as this was the preferred resolution on Windows Phone. [It is still the default resolution used in MonoGame projects today](https://github.com/MonoGame/MonoGame/blob/8b35cf50783777507cd6b21828ed0109b3b07b50/MonoGame.Framework/GraphicsDeviceManager.cs#L44).
13
13
14
14
As XNA became more popular, the need for cross-platform development started to grow. In 2009, [José Antonio Leal de Farias](https://github.com/jalf) introduced *XNA Touch*, an open-source project that aimed to make games with XNA playable on iOS devices. This marked the beginning of what would later become MonoGame. [Dominique Louis](https://github.com/CartBlanche) came on board in 2009 and soon took over as full-time project lead, driving its initial development and expansion. The project attracted other developers, such as [Tom Spilman](https://github.com/tomspilman), who were interested in expanding the scope of the project as well as its reach.
15
15
@@ -23,6 +23,10 @@ Today, MonoGame is a mature cross-platform framework, that is built with the spi
23
23
||[Figure 1-4: Bastion](./images/bastion.jpg)|
24
24
|**Figure 1-3: Streets of Rage 4**|**Figure 1-4: Bastion**|
25
25
26
+
> [!NOTE]
27
+
>
28
+
> For more details about MonoGame's history, check the [About](https://monogame.net/about/) on the official MonoGame website.
29
+
26
30
## Features
27
31
28
32
MonoGame, following in the footsteps of XNA, is a "bring your own tools" framework. It provides developers the basic blocks to design the game, engines, and/or tools. As a code-first approach to game development, MonoGame does not include any pre-built editors or interfaces; instead, it gives developers the freedom to create their own working environment.
description: Setup your development environment for .NET development and MonoGame using Visual Studio Code as your IDE.
4
4
---
5
5
6
-
Unlike game engines, MonoGame is a *framework*. This means it does not come as a standalone program that you download and install, and does not include a graphical user interface used to create games. Instead, MonoGame integrates into the standard .NET development workflow, offering a code-first approach to game development. This approach offers several advantages:
6
+
Unlike game engines (such as Unity, Unreal or Godot), MonoGame is a *framework*. This means it does not come as a standalone program that you download and install, and does not include a graphical user interface used to create games. Instead, MonoGame integrates into the standard .NET development workflow, offering a code-first approach to game development. This approach offers several advantages:
7
7
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.
@@ -21,7 +21,7 @@ The first thing we need to do is install the .NET *Software Development Kit* (SD
21
21
22
22
### [Windows](#tab/windows)
23
23
24
-
1. Open a web browser and navigate to https://dotnet.microsoft.com/en-us/download.
24
+
1. Open a web browser and navigate to [https://dotnet.microsoft.com/en-us/download](https://dotnet.microsoft.com/en-us/download).
25
25
2. Choose the version of the .NET SDK to install and click the **Download .NET SDK x64** button to start the download.
26
26
27
27
> [!NOTE]
@@ -31,7 +31,7 @@ The first thing we need to do is install the .NET *Software Development Kit* (SD
31
31
32
32
### [macOS](#tab/macos)
33
33
34
-
1. Open a web browser and navigate to https://dotnet.microsoft.com/en-us/download.
34
+
1. Open a web browser and navigate to [https://dotnet.microsoft.com/en-us/download](https://dotnet.microsoft.com/en-us/download).
35
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
36
37
37
> [!NOTE]
@@ -81,31 +81,31 @@ To install VSCode, follow the instructions for your operating system below:
81
81
82
82
### [Windows](#tab/windows)
83
83
84
-
1. Open a browser and navigate to https://code.visualstudio.com/.
84
+
1. Open a browser and navigate to [https://code.visualstudio.com/](https://code.visualstudio.com/).
85
85
2. Click the *Download for Windows* button to start the download of the installer.
86
86
3. Once the download finishes, run the installer.
87
87
88
88
### [macOS](#tab/macos)
89
89
90
-
1. Open a web browser and navigate to https://code.visualstudio.com/.
90
+
1. Open a web browser and navigate to [https://code.visualstudio.com/](https://code.visualstudio.com/).
91
91
2. Click the *Download for macOS* button to start the download of the *.zip* archive.
92
92
3. Once the download finishes, double click the *.zip* archive to extract the *Visual Studio Code.app* application package
93
93
4. Drag-and-drop the *Visual Studio Code.app* application package into your *Application* folder to make it available in the macOS *LaunchPad*.
94
94
95
95
### [Linux](#tab/linux)
96
96
97
-
1. Open a web browser and navigate to https://code.visualstudio.com/.
97
+
1. Open a web browser and navigate to [https://code.visualstudio.com/](https://code.visualstudio.com/).
98
98
2. Click the *.deb* download button to download the package for Debian based Linux distributions, or the *.rpm* download button for Red Hat based Linux distributions.
99
99
3. Once the download finishes, open the package downloaded to install.
100
100
101
101
---
102
102
103
103
## Install the C# Dev Kit Extension
104
104
105
-
For C# development using VSCode, it is recommended to use the official *C# Dev Kit* extension provided by Microsoft. Installing this extension will add additional features to VSCode such as a project system and *Solution Explorer* for C# projects. It also provides code editing features such as syntax highlighting, code completion, code navigation, refactoring, NuGet package management, and debugging tools.
105
+
For C# development using VSCode, it is recommended to use the official *[C# Dev Kit](https://marketplace.visualstudio.com/items?itemName=ms-dotnettools.csdevkit)* extension provided by Microsoft. Installing this extension will add additional features to VSCode such as a project system and *Solution Explorer* for C# projects. It also provides code editing features such as syntax highlighting, code completion, code navigation, refactoring, NuGet package management, and debugging tools.
106
106
107
107
> [!NOTE]
108
-
> The *Solution Explorer* panel is a hierarchial view provided by the C# Dev Kit extension that displays your solution structure similar to Visual Studio's Solution Explorer.
108
+
> The *Solution Explorer* panel is a hierarchical view provided by the C# Dev Kit extension that displays your solution structure similar to Visual Studio's Solution Explorer.
109
109
>
110
110
> When you open a workspace in Visual Studio Code containing a .NET solution file (*.sln*), the *Solution Explorer* panel automatically appears and loads your solution. From this panel, you can perform common operations like:
With your development environment setup, it is time to create your first MonoGame application.
182
182
183
183
1. Launch the VSCode application
184
-
2. Open the *Command Palette* by clicking *View > Command Palette* or by using the keyboard shortcut `CTRL+SHIFT+P`.
184
+
2. Open the *Command Palette* by clicking *View > Command Palette* or by using the keyboard shortcut `CTRL+SHIFT+P` (`CMD+SHIFT+P` on Mac).
185
185
3. Type `.NET New Project` in the *Command Palette* and choose the *.NET New Project* command
186
186
4. Next, you will be presented with a list of the available .NET project templates. Enter `MonoGame` into the prompt to filter the project templates to only show the MonoGame ones, then choose the *MonoGame Cross-Platform Desktop Application* project template.
187
-
5. After choosing the template, a dialog window will appear asking you to choose a location to save the project.
188
-
6. Next, you will be prompted to enter a name for the project. Enter the name `DungeonSlime`.
189
-
7. Finally, select the *Create Project* prompt.
187
+
188
+
> [!NOTE]
189
+
> If the MonoGame templates are not showing up, then you skipped the step to install the templates, exit the project creation and click `Terminal -> New Terminal` in VSCode and run the following command:
190
+
>
191
+
> ```sh
192
+
> dotnet new install MonoGame.Templates.CSharp
193
+
>```
194
+
195
+
5. After choosing the template, a dialog window will appear asking you to choose a location to save the project, this is a folder where your projects will will be created by default.
196
+
6. Next, you will be prompted to enter a name forthe project. Enter the name `DungeonSlime`, which will create your projectin a new folder with the same name.
197
+
7. If this is your first time creating your project, you will be asked to choose a solution format, simply selectthe default `.sln` option and click `Next` to continue. (This does not occur with subsequent projects)
198
+
8. Finally, selectthe*Create Project* prompt.
190
199
191
200
After selecting *Create Project*, a new C# project will be generated based on the chosen MonoGame template and opened automatically in VSCode.
192
201
@@ -215,7 +224,7 @@ You can exit the game at any time by pressing the `Esc` key on your keyboard.
215
224
>
216
225
> Desktop applications are event based, meaning once loaded, they do not do much at all while waiting for input from the user. They respond to user interactions and redraw the window only when necessary.
217
226
>
218
-
> In games, things are always happening, such as objects moving around like the player or particle effects. To handle this, games implement a loop structure that runs continuously, first calling a method to update the game logic, and then a draw method to render the current frame, until it is told to exit.
227
+
> In games, things are always happening, such as objects moving around like the player or particle effects. To handle this, games implement a loop structure that runs continuously, first calling a method to **`update`** the game logic, and then a **`draw`** method to render the current frame, until it is told to exit.
219
228
220
229
## Conclusion
221
230
@@ -226,7 +235,7 @@ In this chapter, you accomplished the following:
226
235
* You installed VSCode and the necessary extension to develop C# applications with VSCode
227
236
* You created and ran your first MonoGame project.
228
237
229
-
Now that your development environment is setup and ready to go, you can dive in and start building your first game. In the next chapter, we will cover the contents of the *Game1.cs* file that was included in the MonoGame project you just created.
238
+
Now that your development environment is setup and ready to go, you can dive in and start building your first game. In the next chapter, we will cover the contents of the `Game1.cs` file that was included in the MonoGame project you just created.
230
239
231
240
## Test Your Knowledge
232
241
@@ -235,10 +244,10 @@ Now that your development environment is setup and ready to go, you can dive in
235
244
:::question-answer
236
245
Any two of the following:
237
246
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
247
+
* Flexibility: Developers can use their preferred development tools
248
+
* Integration: MonoGame easily integrates with other .NET libraries
249
+
* Cross-platform Development: Projects can be developed on Windows, macOS, or Linux
250
+
* Version Control Friendly: The code-first approach works well with systems like Git
Copy file name to clipboardExpand all lines: articles/tutorials/building_2d_games/03_the_game1_file/index.md
+6-6Lines changed: 6 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -3,16 +3,16 @@ title: "Chapter 03: The Game1 File"
3
3
description: Explore the contents of the Game1 file generated when creating a new MonoGame project.
4
4
---
5
5
6
-
After you created a new MonoGame project using the *MonoGame Cross-Platform Desktop Application* template in [Chapter 02](../02_getting_started/index.md#creating-your-first-monogame-application), you will notice the generated files and project structure that serve as a starting point for your game application. While MonoGame offers different templates based on target platform, all projects will contain the *Game1.cs* file.
6
+
After you created a new MonoGame project using the *MonoGame Cross-Platform Desktop Application* template in [Chapter 02](../02_getting_started/index.md#creating-your-first-monogame-application), you will notice the generated files and project structure that serve as a starting point for your game application. While MonoGame offers different templates based on target platform, all projects will contain the `Game1.cs` file.
7
7
8
8
## Exploring the Game1 Class
9
9
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.
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
12
> [!TIP]
13
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
-
Locate the *Game1.cs* file that was generated when you created the MonoGame project and open it. The default content will be:
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
17
17
[!code-csharp[](./snippets/game1.cs)]
18
18
@@ -89,15 +89,15 @@ While this can make for a neat effect, it is not something you want all the time
89
89
> | :---: |
90
90
> |**Figure 3-3: The game window clearing the screen using the MonoGame Orange color**|
91
91
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*.
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 every 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*.
93
93
94
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.
95
95
96
96
## Conclusion
97
97
98
98
In this chapter, you accomplished the following:
99
99
100
-
- You read through the default code provided in a *Game1.cs* file created by a MonoGame template.
100
+
- You read through the default code provided in a `Game1.cs` file created by a MonoGame template.
101
101
- You learned about the lifecycle of a MonoGame game project.
102
102
- You learned what a game loop is and how it is implemented in MonoGame.
103
103
@@ -108,7 +108,7 @@ In the next chapter, you will start working with sprites and learn how to load a
108
108
1. Can the `Game1` class be renamed or is it required to be called `Game1`
109
109
110
110
:::question-answer
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.
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. However, you cannot change the name of the *BASE* class `Game`, as this is a MonoGame construct.
112
112
:::
113
113
114
114
2. What is the [**SpriteBatch**](xref:Microsoft.Xna.Framework.Graphics.SpriteBatch) used for?
0 commit comments