Thursday, December 27, 2007

Crazy Animals Flash Game

I've just finished a little Flash game and posted it on my website. It's an easy game...well, it starts out easy, then gets more difficult.

You choose an animal from either a pig, a chicken or a bee, and you keep your cursor away from them. Ever 5 seconds, another animal is added to the field. Like I said, it gets harder pretty quick.

The pig is the slowest, and the bee is fast.

I've had the idea for a game like this one for a while now, but finally found the solution I needed. I needed to be able to have the animals appear in a random place on the field so that they would not all follow the same path. Otherwise, they just bounce off the walls and floor.

There is one problem in that I don't know how to check for where the mouse is and them offset the placement of the next animal. If you play this enough, you'll see that every once in a while the next animal will appear right on top of your cursor and it will end the game...sorry.

I had some trouble with the animals not going away once the game finished, but I got that figured out with a simple:

removeMovieClip(ball);

The original animal instance name on each level is called "ball".

I always learn new things with every game. This one was no exception. At the end, notice where the final "timer" number is displayed, well, I wanted to display how many animals (score) were on the field when you "lost".

So I took the "timer" variable (_root.timer), and I needed to divide that by 5 (remember that every five seconds a new animal appears). Well, I got that working with this:

score = Math.floor(_root.timer/5+1);

Oh, the "Math.floor" thing is ActionScript for "Round Down". The score was displaying with a decimal (like 8.3 or 2.7) and I needed it to display a round number. (thanks to flashkit forums for help with that!)

Also, you'll notice that I needed to add "1". I had to do this because when you start the game, one animal is on the field, which means that there is not animal accounted for in the 1st 4 seconds.

The animal noises on the title screen were made by my 2 year old boy.

I drew these cute little animals in Flash, and you'll be seeing them again soon.

The title font is "Loki Cola"

Enjoy the game: [Play Crazy Animals]

jorge

0 comments: