Jason's profileXNA GamerBlogListsNetwork Tools Help

Jason

Occupation
Location
Interests
This person's network is empty (or maybe they're keeping it private).

XNA Gamer

A gamer trying to make games...
January 05

"Shape Battles" - A Geometry Wars clone

When I first started playing with XNA (which, don't get me wrong, was quite recently) I started with the same demo almost everyone does; the bouncing ball.  This quickly lead me to start thinking about how I could make a 'Geometry Wars' type game, since that game seems to embody the core fundamentals of any game: A hero, enemies, weapons, and collisions.  Its quite simple but quite addictive.

So, I started playing and playing and eventually came up with "Shape Battles", my Geometry Wars clone.  It's nowhere near as good or complete a game as GeoWars, but its a great start.

It does have some pretty neat features:

  1. You have 3 lives to try to obtain a high score
  2. You have 3 Super Bombs that can be used to destroy every enemy on the screen at once. A "free" Super Bomb is also fired when you are killed, so that your respawn is safe.
  3. You get score Multipliers, as well as your weapon effectiveness increases, the longer you stay alive.
  4. Random enemies add unpredictability to the game which makes it fun and somewhat addictive. (Watch out for the rare Purple enemy, cause they are fast!)
  5. Random weapon modifier in later difficulties (basically the color of your ammo will randomly change to that of one of the 4 different types of enemies for a very short period of time - when this happens you can only kill those colored enemies) - I thought this was a neat twist.
  6. It has sounds!
  7. The code is pretty well documented and commented! (I figured I was obligated since I am making it available to download.)

It does have it's issues however:

  1. There's no Title screen and/or options.
  2. Its quite basic.
  3. Once you die the difficulty that you made it to before dying is still in effect, so once you respawn its pretty hard to continue to survive (since your weapon effectiveness is then reset).
  4. Its not perfectly balanced in its difficulty and the steady increase in difficulty. (To do...)
  5. You can't yet gain additional lives and/or additional Super Bombs. Which makes progressing into very high scores quite unlikely right now, until you have a way of earning extra lives and bombs so you can survive longer.
  6. More bugs I forgot to mention (or are unaware of).

I've obviously included the source code for this game, because thats the point of this blog!  Download is below the instructions.

Instructions for Playing:

Note: This is a Windows game currently, but the only controller support currently is for the Xbox 360 controller.

With a wired Xbox 360 controller, use the Left ThumbStick to control your player character, and the Right ThumbStick to fire your weapon.  The angle of the Right ThumbStick dictates the direction that your stream of shots will go.

The Right Bumper button is used to deploy your "Super Bomb" which will instantly destroy every enemy on the screen at once (use when in a bind).  But be careful, as you have a limited amount (3).

You are limited to 3 lives.

Survive the first 30 seconds without firing a single shot (this includes Super Bombs) to get a Pacificier bonus of 1000 points!  Survive the first 60 seconds to get an additional bonus of 5000 points!! Good luck with that too ;)

There are 5 different types of enemies, each with different characteristics:

  • Red (lower right corner) - Are faster than the other 3 regular enemies and are worth slightly more points.
  • Blue & Yellow (upper left and right corners) - Basically your average enemy, random speed which isn't much of a threat.
  • Green (lower left corner) - Unlike every other enemy, Greens do not chase you, instead they just float around the screen randomly, bouncing off the corners of the screen. (All other enemies main objective is to hunt you down and kill you).
  • Purple (rare) - Purple baddies only spawn 1 at a time and pretty rarely (until your difficulty increases and then they come more and more).  They are very quick (faster than you) and will head directly for you.  Keep an eye out! (they spawn from the Left Middle of the screen.)

Press start after you get 'Game Over' to restart the game.  Back will exit the game completely.

Credit where credit is due!

I must admit that I stole the idea for the enemies graphics from another similiar game that I came across, but I cant find the original link so I apologize in advance to the author of that game. (But he didn't post the source, just the game to download, so I recreated the graphics for what its worth.)

The code that I used to get the rotating sprite and projectile angles correct I mention below, and was provided by a friendly MSDN Forum poster.

Sounds were taken from Flashkit.com Sound FX library.

The source code also includes XNAExtras, which I used to draw fonts to the screen for Scores and other UI things.  This is a library that is publically available and you can find out more information about it here: http://blogs.msdn.com/garykac/articles/749188.aspx

(I hope that I am not doing anything wrong by releasing my source that includes XNAExtras, but if so please someone let me know immediately!!)

Download the source code for "Shape Battles":

 ShapeBattles.zip - 360.44kb

January 03

Rotating a sprite using an Xbox 360 ThumbStick

Took me a little while to find a solution for this problem.  But as usual, posting a simple question on the XNA MSDN forums prompted tportz to provide me with a great chunk of code that worked perfectly (so thanks belong to that poster).

Here is the code in a nutshell:

public float UpdateThumbStickAngle(Vector2 stick)
{
    float angle = 0.0f;
    stick.Normalize();
    if ((stick.X >= 0 || stick.X <= 0) || (stick.Y >= 0 || stick.Y <= 0))
    {
        angle = (float)Math.Acos(stick.Y);
        if (stick.X < 0.0f)
            angle = -angle;
    }
    return angle;
}

Fairly simple chunk of code, but the math part in the middle is pretty much over my head.  Thanks again to tportz for providing this simple solution that would have driven me nuts otherwise (and was starting to, which prompted my original post to the MSDN forums).

In other news, I will be posting my "Geometry Wars Clone" some day this week, I just need to clean up and better comment the code so it makes sense to others ;)

Download source code that contains an example of a triangle sprite that you can freely rotate around in a full circle using the Left ThumbStick of an Xbox 360 controller.

RotateSpriteThumbsticks.zip - 10.50kb

January 02

Links / Resources

While I'm wrapping up my first game project with XNA (and preparing it for download with tutorial article), please check out my Links / Resources (to the right).  There are truly some excellent websites out there dedicated to helping others like me (us) learn XNA so that we can create our own games.  Without sites like these, I would be quite clueless ;)

My experiences with XNA and C#!

Welcome to my XNA Programming blog.  This is going to be a place where I will write about my trials and tribulations regarding Microsofts newest game development tool, XNA.  This tool is a GREAT resource for people who are really interested in getting involved with Game Development, especially if you are interested in trying to make a game for the Xbox 360.
 
I am a programmer by trade, but have limited experience specifically with C#, and absolutely no game development experience.  What lies in these blogs are my experiences working with XNA, games and/or demos that I have written, resources, and any tips and tricks I come across or figure out.
 
Thanks for stopping by, enjoy, and please feel free to comment!
 

Xbox Live GamerCard

H1ro
Xbox Live GamerCard
Rep:
5/5 stars
Score:
15275
Zone:
Pro
STREET FIGHTER IVBlazBlueCall of Duty 4RESIDENT EVIL 5Red Faction: Guerrilla