Thank you for visiting Blazing Games

Things Popping up

At this point all the parts are ready, it is just the matter of a bit of coding to glue all the pieces together. Within the main loop of the game we turn on the target buttons. Each button calls it’s own function. While it would be possible to have the function code right in the function declaration, having the functions all in one frame makes it a bit easier to figure out what is going on without having to jump all over the place. The functions simply let the program know that a snowball is being thrown and calls the appropriate canned snowball animation. Here is one of the functions:

At the last frame of every canned snowball throwing animation is a call to the adjustScore function. This is the function that actually determines if the snowball hit a valid target and if that target was a gnome or a Santa. When a snowball is being thrown the handling of targets is paused. This is to reduce the annoyance of throwing a snowball at a target and have the target vanish before the snowball actually hits it. If the target actually has not started to disappear before the player clicks then the target will be hit. To prevent industrious players from noticing this and taking advantage of this feature by clicking on an empty target to gain a bit of mouse positioning time, the countdown is reduced by the appropriate amount the moment the throw ends.

This leads to the main part of the game. Handling targets. This is done by using the OnEnterFrame function. By changing this function to point to either the targetsDisabled() or the targetsEnabled() function, we can easily turn on or off the target handling code. TargetDisabled does nothing, but is there as I don’t like using null to disable the onEnterFrame function.

The first thing the targetsEnabled function does is checks to see if the targetCountdown has expired. When the time countdown has run out, it is potentially time to start a new target. It is also possible that all the targets have been shown in which case the endLevel function. The creation of a target is simply a random choice between the position and the type of target.

If a new target is not being started, we see if the snowball is being thrown. If the player is not in the middle of throwing a snowball, the targetCountdown timer is reduced.

Previous Page
1 2 3 4 5 6 7 8

About - Privacy Policy - Contact - Links - FAQ
Copyright © 2004-2006 Blazing Games Inc. All Rights Reserved.