home | game dev | music | writing | software | projects | donate

MonoGame Sprite Sheet Animation Test

I'm teaching myself MonoGame and decided to do a quick mini-tutorial on how to do some simple sprite animation. Hopefully this will save you a little time. :)

First, I headed on over to OpenGameArt.org and grabbed some graphics:

I then followed this tutorial on how to import multiple images into one layered document in Photoshop:

Then I installed this Sprite Sheet Generator script:

Once I exported the sprite sheet in PNG format, I created a new MonoGame project in Visual Studio. I imported the spritesheet and background image into the pipeline tool. After a bit of code finagling I figured out how to do the animation of the girl running.

Then I added some simple code to where she is standing still by default, but if you hold down the right or left arrow on the keyboard she runs from side to side. I also added logic for her scroll back around if she went off the screen.

Here is the result of my little experiment:

UPDATE: I decided to add some support for parallax animation. It really isn't too hard to do. If you want to see how I did it, download the source code ;)

If you'd like to play the game, you can download it below. This entire project is open source so feel free to download the source code and use it for whatever you want (MIT License).

While I'm too lazy to explain the source code via this mini-tutorial, I'm happy to answer any questions you may have via email, so feel free to drop me a line.

(Yes, I am aware that my implementation of parallax is atypical, the sun rises when you go right and sets when you go left, for example. That's just how I wanted it to work, for my testing purposes. If you want to make more traditional parallax it wouldn't take a lot of effort to modify this code to get it to work the way you want it to.)
Download & Play The Game | Download Source Code

email | facebook | soundcloud | blend | github | twitter
~ breaking the fifth wall to travel faster than light ~