Health Noobie question

Talk about making games.

Health Noobie question

Postby S0L1Dfake » Mon Dec 04, 2006 7:44 am

I am a noob to GE and I just started putting together some elements to a game and I am running into a problem. I set variable "health" to 5, then have a collision event "health = health - 1;" then an item that when collision occurs adds "health = health + 1;" but for some reason it automatically raises it to 6, or so i think. Am I making some common mistake or what? and how do I display the value of a variable (ie, "health") on the game screen?
User avatar
S0L1Dfake
 
Posts: 15
Joined: Mon Dec 04, 2006 7:31 am
Location: Cleveland, Ohio
Score: 0 Give a positive score

Postby Novice » Mon Dec 04, 2006 9:41 am

Don't double post.
Why do i always get stuck?
User avatar
Novice
 
Posts: 399
Joined: Mon Aug 29, 2005 10:54 am
Location: Relative
Score: 5 Give a positive score

Postby makslane » Mon Dec 04, 2006 12:33 pm

The add action happens before de sub action.
To see the variable value, create a text actor and put a Draw Actor event with the code:

textNumber = health; //Or player.health if health is an Actor variable
makslane
Site Admin
 
Posts: 3947
Joined: Sat Apr 05, 2003 6:47 pm
Score: 182 Give a positive score

Postby S0L1Dfake » Mon Dec 04, 2006 9:38 pm

Thank you makslane. I figured it out. I was putting the "health = health - 1;" action on the player when he collides with the enemy, and the "health = health +1;" command on the object when the player collides with it. So I just moved the command to the player and its fixed.
User avatar
S0L1Dfake
 
Posts: 15
Joined: Mon Dec 04, 2006 7:31 am
Location: Cleveland, Ohio
Score: 0 Give a positive score


Return to Game Development

Who is online

Users browsing this forum: No registered users and 1 guest