sample

Okay, so I’m done with the class, but I’m still having fun! I’ve updated some of the game mechanics for JelloStorm!

Some of the improvements that I have made to my game are not really technical, but really improve the game play. First off, I added in “poison rings” around each jello, so you can see the area of collision better. It adds a nice visual touch to the game, while adding the benefit of being able to see where you should stand in relation to the jello without getting hurt.

The second addition was teleportation. In the original build, getting away from the jello blobs was easy: just run around the edge in a circle. The jello monsters would eventually all end up in the middle of the screen and you could play indefinitely. That’s no fun, but to God be the glory, I came up with the teleportation idea!

So, I fixed it by giving the jellos a chance to “teleport” to another place in the gaming area. While it isn’t intelligent (in fact it is random) it happens often enough to make you miss targets, because they disappear, and to put them in the way of where you are going!

The code looks like this:

if (specificJello % 2 == 0) {
// Give the jello an opportunity to randomly teleport!
// The if statement checks if it is even number.
// If it is, do this:

// Find the min/max of the arena area
int maxY = arena.height – 50;
int minY = arena.top + 50;
int maxX = arena.width – 50;
int minX = arena.left + 50;

// Generate our random number
srand((int)time(0) * specificJello);
int side = (rand() % 10);

switch (side)
{
case 0:
// left
m_Position.x = (rand() % maxX) + minX;
m_Position.y = (rand() % maxY) + minY;
break;
}

}

All that fancy stuff says, if it is an even numbered jello (sorry oddies, you’re left out), then it has a 10% chance of being chosen for teleportation. That’s pretty low, but remember, by round 20 there are 100 jellos, and so (in theory based on probability) 5 of them would randomly teleport every frame of the game (100 / 2 * 0.1). Since there are upwards of 30 fps on my computer, then as many as 150 teleportation events could happen in a second.

That makes the game just a little less predictable….

Be sure to check out the full commit, and download the code to give it a try!

Linux – keep it simple.

Leave a Reply

Your email address will not be published. Required fields are marked *