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
+10-23Lines changed: 10 additions & 23 deletions
Original file line number
Diff line number
Diff line change
@@ -17,23 +17,11 @@ The official first release of MonoGame occurred in 2011, as an open source versi
17
17
18
18
Today, it is a mature, cross-platform framework, that is built with the spirit of preserving XNA but adopting modern game development practices. Some popular titles created using MonoGame include [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/).
|||
24
+
|**Figure 1-3: Streets of Rage 4**||
37
25
38
26
## Features
39
27
@@ -63,7 +51,7 @@ By providing cross-platform support, developers can target multiple platforms fr
63
51
64
52
MonoGame is designed and built in C#. It is the official programming language supported in documentation, samples, and community discussion. However, MonoGame is not exclusively tied to C#. As a .NET library, MonoGame can be used with any .NET-compatible language including Visual Basic and F#.
65
53
66
-
> [!CAUTION]
54
+
> [!CAUTION]
67
55
> While the alternative .NET languages can be used, community support may be limited outside the scope of C#.
68
56
69
57
Regardless of which .NET language used, developers should have a foundational understanding of the language and programming concepts such as:
@@ -83,7 +71,7 @@ Regardless of which .NET language used, developers should have a foundational un
83
71
84
72
<details>
85
73
<summary>Question 1 Answer</summary>
86
-
74
+
87
75
> Any of the following are advantages of using the MonoGame
88
76
> 1. It provides cross-platform support, allowing developers to target multiple platforms from a single code base.
89
77
>
@@ -93,12 +81,11 @@ Regardless of which .NET language used, developers should have a foundational un
93
81
94
82
</details><br />
95
83
96
-
97
84
2. What programming languages can be used when creating a game with MonoGame?
98
85
99
86
<details>
100
87
<summary>Question 2 Answer</summary>
101
-
88
+
102
89
> The primary language used is C#, which is the same language that the MonoGame framework is developed in. However, any .NET language can be used, such as F# or Visual Basic.
Copy file name to clipboardExpand all lines: articles/tutorials/building_2d_games/02_getting_started/index.md
+6-2Lines changed: 6 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -157,11 +157,15 @@ Now that you have your development environment setup, it's time to create your f
157
157
158
158
After selecting *Create Project*, a new C# project will be created based on the MonoGame template we choose and opened automatically in VSCode.
159
159
160
-
<figure><imgsrc="./images/vscode.png"alt="Figure 2-1: A new MonoGame project after being created in Visual Studio Code"><figcaption><p><em>Figure 2-1: A new MonoGame project after being created in Visual Studio Code</em></p></figcaption></figure>
160
+
||
161
+
| :---: |
162
+
|**Figure 2-1: A new MonoGame project after being created in Visual Studio Code**|
161
163
162
164
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
163
165
164
-
<figure><imgsrc="./images/cornflower-blue.png"alt="Figure 2-2: The default MonoGame cornflower blue game window."><figcaption><p><em>Figure 2-2: The default MonoGame cornflower blue game window.</em></p></figcaption></figure>
166
+
||
167
+
| :---: |
168
+
|**Figure 2-2: The default MonoGame cornflower blue game window**|
165
169
166
170
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:
Copy file name to clipboardExpand all lines: articles/tutorials/building_2d_games/03_the_game1_file/index.md
+6-2Lines changed: 6 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -72,7 +72,9 @@ This class provides the following structure:
72
72
73
73
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*.
74
74
75
-
<figure><imgsrc="./images/monogame-lifecycle.png"alt="Figure 3-1: Lifecycle of a MonoGame game."><figcaption><p><em>Figure 3-1: Lifecycle of a MonoGame game.</em></p></figcaption></figure>
75
+
||
76
+
| :---: |
77
+
|**Figure 3-1: Lifecycle of a MonoGame game**|
76
78
77
79
## Graphics and Rendering
78
80
The graphics pipeline in monogame starts with two components: the [**GraphicsDeviceManager**](xref:Microsoft.Xna.Framework.GraphicsDeviceManager) and [**SpriteBatch**](xref:Microsoft.Xna.Framework.Graphics.SpriteBatch).
@@ -150,7 +152,9 @@ The [**Update**](xref:Microsoft.Xna.Framework.Game.Update(Microsoft.Xna.Framewor
150
152
151
153
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
152
154
153
-
<figure><imgsrc="./images/solitaire.webp"alt="Figure 3-2: Windows XP Solitaire Win Screen."><figcaption><p><em>Figure 3-2: Windows XP Solitaire Win Screen.</em></p></figcaption></figure>
155
+
||
156
+
| :---: |
157
+
|**Figure 3-2: Windows XP Solitaire Win Screen**|
154
158
155
159
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).
For the same amount of steps, you also get the benefit of the assets being pre-processed and compiled to an optimized format for the target platform. For instance, image files can be compiled using [DXT compression](https://en.wikipedia.org/wiki/S3\_Texture\_Compression), which is a format that is understood by GPUs without needing to be decompressed first, reducing the memory footprint.
34
36
@@ -39,7 +41,9 @@ For this tutorial series, we are going to focus on using the content pipeline wo
39
41
40
42
To get started and to walk through the process, we'll start with loading an image file. Right-click the following image of the MonoGame logo and save it named *logo.png* somewhere on your on your computer, such as your desktop.
@@ -49,7 +53,9 @@ The *MonoGame Content Builder Editor (MGCB Editor)* is a GUI tool that can be us
49
53
50
54
To open the *Content.mgcb* content project file in the MGCB Editor with Visual Studio Code, you can use the *MonoGame for VSCode* extension. You should have installed this extension in [Chapter 02](../02_getting_started/index.md#installing-the-monogame-for-vscode-extension). With this extension install, anytime you have a code file open, you will see the MonoGame logo in the top-right of the code window like below:
51
55
52
-
<figure><imgsrc="./images/mgcb-editor-icon.png"alt="Figure 4-3: MonoGame for VSCode extension icon"><figcaption><p><strong>Figure 4-3: MonoGame for VSCode extension icon</strong></p></figcaption></figure>
56
+
||
57
+
| :---: |
58
+
|**Figure 4-3: MonoGame for VSCode extension icon**|
53
59
54
60
Clicking the MonoGame logo here will open the *Content.mgcb* content project file from the current project in the MGCB Editor.
55
61
@@ -68,7 +74,9 @@ To open the *Content.mgcb* content project file in the MGCB Editor using the dot
68
74
69
75
Once you have the *Content.mgcb* content project file for your game project opened in the MGCB Editor, you should see a window similar to the following:
For the purposes of this tutorial, choose the *Copy the file to the directory* option, then click the *Add* button. When adding existing files in the future, the choice between copying the file and adding a link can make a big difference:
89
99
@@ -93,7 +103,9 @@ For the purposes of this tutorial, choose the *Copy the file to the directory* o
93
103
94
104
After adding the *logo.png* file, your project node should look similar to the following:
95
105
96
-
<figure><imgsrc="./images/mgcb-logo-added.png"alt="Figure 4-6: Logo image added to the MGCB Editor"><figcaption><p><strong>Figure 4-6: Logo image added to the MGCB Editor</strong></p></figcaption></figure>
106
+
||
107
+
| :---: |
108
+
|**Figure 4-6: Logo image added to the MGCB Editor**|
97
109
98
110
After changes have been made in the MGBC Editor, ensure that you save the changes. They are not automatically saved, though you will be warned if you close the editor and haven't saved changes. You can tell that changes have not been saved by looking at the title bar of the MGCB editor window. If it has an '*' at the end of the window title, this means changes have not been saved. To save changes, you can perform one of the following:
99
111
@@ -172,7 +184,9 @@ The key changes we made here are
172
184
173
185
Running the game now will show the MonoGame logo displayed in the upper-left corner of the game window.
174
186
175
-
<figure><imgsrc="./images/logo-drawn.png"alt="Figure 4-7: The MonoGame logo drawn to the game window."><figcaption><p><strong>Figure 4-7: The MonoGame logo drawn to the game window.</strong></p></figcaption></figure>
187
+
||
188
+
| :---: |
189
+
|**Figure 4-7: The MonoGame logo drawn to the game window**|
0 commit comments