Our First Square
Our First Square¶
I assume you have dotnet core installed on your system. If not get it now, I'll wait...
Now, open up a commandline, from here on called a terminal.
On Windows
Open up a Powershell or commandprompt. (see here)
Linux
Your distro comes with a terminal, it has to, it's the law!
We are going to add a Template to the dotnet runtime on your system. To do that run:
dotnet new --install MonoGame.Template.CSharp
. You will see a lot of stuff rolling by and in there somewhere is a table. This table will now contain a row with MonoGame DesktopGl Game
, like mine printed below.
1 2 3 4 5 | Templates Short Name Language Tags ---------------------------------------------------------------------------------------------------------------------------- Console Application console [C#], F#, VB Common/Console Class library classlib [C#], F#, VB Common/Library MonoGame DesktopGL Game mgdesktopgl [C#] MonoGame/GUI App/Game |
We can now start a new dotnet project with all the stuff needed by monogame!
If you are enyoing your time in your blackscreen of text, type: dotnet new mgdesktopgl -o Voxels
. This will create a new Monogame project called Voxels
in a folder called Voxels
within the current directory.
You can also use an IDE if you want to.
Open up the project using your editor of choice and let's start hacking. You can even run this project to get a pretty screen with nothing in it.
Info
I assume you have an editor, if not go grab visual studio code. From vscode open the folder you just created. Also install the ms-vscode.csharp
extension in vscode. Vscode will probably tell you to do so anyway.
So lets throw out some stuff we will not be needing, gut the Game1.cs
file until it looks like this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | using Microsoft.Xna.Framework; namespace VoxelNet { public class MainGame : Game { private GraphicsDeviceManager _graphicsDeviceManager; public MainGame() { _graphicsDeviceManager = new GraphicsDeviceManager(this); Content.RootDirectory = "Content"; IsMouseVisible = true; } protected override void Initialize() { base.Initialize(); } protected override void LoadContent() { // Load shapes to draw } protected override void Update(GameTime gameTime) { // TODO: Add your update logic here base.Update(gameTime); } protected override void Draw(GameTime gameTime) { GraphicsDevice.Clear(Color.TransparentBlack); // TODO: Add your drawing code here base.Draw(gameTime); } } } |
Simply put, remove the gamepad and spritebatch stuff. I changed the background color because I like black. Change it to whatever you like.