PDA

View Full Version : Safe at respawn


Xionraseri
03-14-2008, 12:50 AM
I'm making a game where your a monster that shoots fireballs at cars, and whenever your hit by a car, you lose a life. How do I make it so that whenever you get hit, you flash and are invincible for a few seconds? because sometimes 3 cars at the beggining will spawn on top of the monster at the same time and you only have 2 lives left w/out playing at all.

Bombdogs
03-14-2008, 10:52 AM
Include in your hit-testing code a boolean that defines the player being invincible - when set to true the hit-test functions simply do not operate, when false they operate normally.

Then set that boolean to true for a few seconds using a timer.

PMF

Xionraseri
03-14-2008, 12:45 PM
I'm sorry...but Im rather new to progamming, and well I don't know what a boolean is or how to make one:o

Bombdogs
03-14-2008, 01:30 PM
Booleans are the most basic variable type - they're either true or false. To be honest, given your other post, I think you may be trying to run before you can walk - my best advice would be to shelve the game for a bit & take a look at a few of the basic tutorials on this site.

PMF

bluemagica
03-14-2008, 05:27 PM
yeah, you need to know some little programming concept before trying to make a good game... anyway, as said earlier, a boolean is just a variable, but to this variable, you should take care, to set either true or false(0 and 1 can and is used for true and false). for example...

if(var_invincible=="false" && this.hitTest(_root.car)) //on collision with car, if monster NOT invincible
{
var_lives-=1; //decrease live
var_invincible=="true"; //make monster invincible
}
dont try to use this code in game...it is just to show the use of bollean variable.

oh, and remember to set it back to "false" after sometime....