Health trouble

Started by computerbynar, Tue 23/03/2004 13:13:19

Previous topic - Next topic

computerbynar

Im having trouble with the health function. Im using:

function repeatedly_execute() {
 string hlthstr;
StrFormat(hlthstr, "Health:%d", GetGlobalInt(100));
SetLabelText(HEALTH, 0, hlthstr);  // put anything you want to happen every game cycle here
}

It only starts at zero, and it doesn't have a way to subtract health.

computerbynar

I cant stay much longer, so if you have the answer, please email me at computerbynar@hotmail.com.

Ishmael

#2
If you make this little change:

put to the start of the global script:

int hlthch, hlth;
string htlhstr;

and then the rep_ex:

function repeatedly_execute() {
 // put anything you want to happen every game cycle here
Ã, Ã, if (hlthch != hlth) {
Ã, Ã, Ã, Ã, hlth = GetGlobalInt(100);
Ã, Ã, Ã, Ã, StrFormat(hlthstr, "Health:%d", hlth);
Ã, Ã, Ã, Ã, SetLabelText(HEALTH, 0, hlthstr);
Ã, Ã, Ã, Ã, hlthch = hlth;
Ã, Ã, }
}

I don't know what it does, but I think it's worth the try.

----- EDIT -----

Or do what's said below, I'm not so sure about your problem anymore... And it's game_start.
I used to make games but then I took an IRC in the knee.

<Calin> Ishmael looks awesome all the time
\( Ö)/ ¬(Ö ) | Ja minähän en keskellä kirkasta päivää lähden minnekään juoksentelemaan ilman housuja.

Radiant

#3
Well, in the function at_start_of_game (or whatever the name was), add
SetGlobalInt (100, 50);

Then in repeatedly_execute, do something like
if (AreCharactersColliding (EGO, ENEMY)) SetGlobalInt (100, GetGlobalInt (100) - 1);

(edit) Okay, game_start it is. <grin> we must have been typing at the same time, I hadn't seen your post when writing mine

SMF spam blocked by CleanTalk