Extra Credit Tutorials

For those of you following my work on the Beginner’s Guide to 2D Games”, it may be of interest that I have just launched the first going beyond tutorial in a series we are calling “Extra Credit”. Members of the XNA community, along with myself, have provided a collection of tutorials to help you get beyond the basics and start adding custom elements to your games.

My first Extra Credit tutorial, found here, shows you how to build a modular particle engine that can be used in any 2D game. The source code is a modified form of the 2D Particle Sample available on the XNA website, so if you’ve played around with it before, this should be familiar. The source code for this project is available here.

Any feedback, good or bad, is a positive thing in my book, and I’d love to hear about your experiences with my tutorial.

~Joshua Foss

5 Comments

  1. joeldixon66 said,

    I don’t know if you’re still reading these blog comments – but I really enjoyed your Beginners Guide to 2D games. I’m new to games programming so maybe I’m easily impressed, but I was surprised how easy it was to get a pretty realistic looking effect like an explosion in so few lines of code.

    I do have a quick question about the ParticleSystem described in the tutorial. Firstly, am I right in assuming that you allow a limit to the number of particle effects (via the ParticleSystem’s constructor parameter howManyEffects) due to performance concerns? I would guess having many particle effects on screen at the one time may cause noticeable frame rate issues.

    In this case, why are we limiting howManyEffects to just 1 for the explosion particle system? I would have thought that, as we have 3 potential cannonballs at the one time – we might need to show three explosions at once.

    As I say, I’m very new to all this, so would be interested to hear your thoughts. Cheers, Joel

  2. Joshua Foss said,

    Hey, Joel. Thanks for checking out the tutorials, and I’m glad you found them useful. As for your question about limiting the explosion particle systems to one, yes, this is done mainly for performance reasons. In a game as simple as this, we could probably have 30 explosions on screen at once and it wouldn’t hurt our framerate, but I think it’s good practice to limit your special effects to as few as possible.

    One of the big tricks to game programming, where you have things like networking, ai, collision, physics, and particles all trying to get processing time, is to cut corners in places where the player will not notice the difference. Because all of our enemies are located in a central location(the top half of the screen), it isn’t a jarring experience if an explosion ends before it is finished. This is helped a great deal by the smoke particles, and actually has a side benefit of making explosions appear to have different durations.

    If the situation ever arose where it became noticable to the player that an effect was being cut off, we could go ahead and up our number of effects, but as long as the player cannot tell that anything is wrong, we’ve done our job and saved some precious resources. :)

  3. joeldixon66 said,

    Thanks for the reply Joshua – cleared it right up for me.

  4. alexbm07 said,

    Hello Joshua,

    First of all Thank you for your contribution to the game community!

    I am a new member of the XNA creators club and I followed the 2D tutorials including the first two videos of extra credit. I wrote the code according to the instructions and created the class Particle as public class Particle as you suggested but I am having an error that is repeated in 4 different parts of the code. The error is:

    ‘WindowsGame1.Game1′ does not contain a definition for ‘SpriteBatch’
    File ParticleSystem.cs
    Line …
    Project WindowsGame1

    When I run the program and I choose to continue and run the last successful build, the program works fine as it was supposed until the 9th session of 2D tutorial.

    Based on your experience, do you have any clue what kind of typical error am I doing?
    I went to the error help session of MSDN and it says that a reference is made to a member that does not exist for the data type. When I go to my code I really can’t figure it out. I am completely new in C#, so do not know where to go. I did some modification, but nothing worked, so I put everything back the way there were.

    I will really appreciate any help you could offer on this issue.

    Thank once again,

    Alexbm07

  5. alexbm07 said,

    Hello again Joshua,

    I already figured it out. Since the order of the videos is not 1, 2, 3, 4 but 1, 3, 4, 2. I was getting stuck in the same place and I was missing some information as well as pieces of code.

    Thanks and have a nice week.

    Alexbm07

Post a Comment

You must be logged in to post a comment.