[Tutorial] Building Your First Game Ever with MonoGame

Abstract:

Game development is what got many developers into programming. But how many of us actually ever learned how to create games? Creating games can be challenging, but it doesn’t have to be that way! MonoGame is a cross-platform gaming framework based on Microsoft’s XNA framework that’s extremely easy to learn. Best of all, games you build with MonoGame will run on iOS, Android, Mac OS X, tvOS, Windows, Linux, PlayStation 4, and more—write once, play anywhere.

In this blog post, we’re going to walk through each step required to create your first game from start to finish, creating a user interface to adding game logic. The object of the game is to tap the monkeys as they appear to keep them from running off with your bananas. If you leave any monkey untapped for more than five seconds, the monkey takes your bananas, and the game is over! Think of it as Whack-a-Mole, but with monkeys!

Learn to build your first game ever this weekend:
https://blog.xamarin.com/build-your-first-game-with-monogame-getting-started/

Thought I’d give it a go but is it just me?

File-> New Game

“Within Xamarin Studio, choose File → New Solution → MonoGame → Library → MonoGame Shared Library”

What choices do we get with a new MonoGame solution?..
Monogame Shared Project
Monogame Portable Library
amongst others

Alarm bells!
Eeeny Meeny Miny Mo… I went for PCL! Fingers crossed.

Delighted when I get a blue screen in the emulator…cornflower not BSOD!

Adding Game Assets

Moved the folder around and set the build action of Content.mgcb to MonoGameContetnReference. Correct that it wasn’t available in the drop down so had to manually type it.
Nice one! Why wasn’t it available though? Maybe due to the fact that when I get to double click the mgcb file then nothing happens.
Back in File->New Game there is “To get started, we first need to make sure we have both Xamarin and the latest development build of MonoGame installed.”
Well I’d installed the studio and then used the add-in manager to get what I presume is the nuget packages for monogame and gave me all the templates. Seems it doesn’t include the Content pipeline tool?
The other link to monogame itself was what I missed or at least thought wouldn’t be needed? Used the second link and installed the “Monogame SDK” plus Visual Studio Templates etc. Well it gives me the content pipeline tool as double clicking the mgcb file now opens it.

So add the assets…

more alarm bells go off when the Platform property for the content is Windows…shouldn’t it be Android? I change it. Also change it back to Windows later too
Also notice that each asset’s build property is set to build rather than copy (have changed those too and back!)

…and build them.

Success.

Creating Monkey Tap User Interface

Alarm bells when Content.Load isn’t qualified with type but change that, probably html “removing” it…

Build project and run…

Exception…couldn’t load monkey asset as a non-content file.
Show Details…click…nothing ever happens when the link is clicked?

So presumably the xnb file cannot be found hence playing around with all the build action properties.

Eventually decided to download the master monkey tap project from github to see what difference there may be. That won’t even build, one reason being the ogg content cannot be converted?

So that;s the fruit of my evening’s labour. I know the emulator works but as for a first project, not a great success at the moment.

Still no joy… @dellis1972 any suggestions as I’d rather not have to build everything from scratch again as that seems to be the only way I can ever get Monogame to work?

@procd

Are you doing this in XS on a mac or windows?
You needed to have a unstable development build of MonoGame installed.

The reason MonoGameContentReference does not appear is because Xamarin Studio isn’t very good a dynamically adding Build Actions from .targets file.

It sounds like content is not building. Probably because you used a PCL rather than a Shared Project.
The tutorial was written for Xamarin Studio. There will be differences between that and VS.

Putting a Content.mgcb in a PCL will not work since the PCL library does not know wha to do with it.
That only works with Shared projects. If you want to use PCL the Content.mgcb will need to be in the Android project.

You content in the .mgcb should be set to build not copy over wise the pipeline will just copy the files , not process them into .xnb.

If you want upload the project as it stands and I’ll figure out exactly what is wrong with it :slight_smile: and give you steps to fix it.

Thanks for replying. I’m doing this on WIndows and using Xamarin Studio. It’s my first time using Xamarin Studio and Android so was hoping for a gentle introduction. I’ll make the changes and try that, So my eeny meeny picked the wrong one , doh! …and back to the dev branch! So to answer my “is it just me?” then it’s looking like it is at the moment :blush:

P.S. There is no “installer” for the dev branch for Xamrin on Windows as far as I can see. So is the only/best method to do a build of the dev branch?

Message sent.
.Using Xamarin Studio 5.10.2 (build 56)

I’ve built the dev build. That provides an updated content pipeline tool that understands the ogg format and so can build the content. I can successfully build and run the master project from GitHub. I haven’t worked out how to “install” the dev version of monogame into Xamarin Studio as it still thinks it’s using the stable 3.4 release. Even so it works.
Started from scratch and now although I can build the content using the new pipeline tool and can see the generated xnb files, the project fails to load the content with same exception “Exception…couldn’t load monkey asset as a non-content file”.

@dellis1972 Have uploaded my broken version here https://app.box.com/s/qxhlo9yrcs8x4s1gllmg4e7vrlbhilh3 Thanks for looking.

If I use Visual Studio and create an Android app then I can load all the monkey tap assets and use them. Why the issue with the tutorial project?