Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: Shade on Sun 28/11/2004 10:03:57

Title: who can i make a hp display?
Post by: Shade on Sun 28/11/2004 10:03:57
i don't know how to make one. i mean i want to make a hp display for four players in one room (for each one one). and i don't know how to make the display smaler or larger and how to say when a charakter is dead. so i don't know anything. but please just tell me how to do it and don't say: ags_freak is a noob thats to difficult for him. just post it. perhaps i know what it means one day :)
Title: Re: who can i make a hp display?
Post by: Radiant on Sun 28/11/2004 11:27:29
It's not very difficult. You create a GUI with labels stating something like '22 of 48 hp'.
Then, whenever necessary, you use

string buffer;
StrFormat (buffer, "%d of %d hp", char1_hp, char1_max_hp);
SetLabelText (THE_HP_GUI, 0, buffer);

Title: Re: who can i make a hp display?
Post by: monkey0506 on Sun 28/11/2004 18:29:37
To expand upon Radiant's script and answer the question of how tell when a character is dead:

function repeatedly_execute(){
Ã,  if (char1_hp==0){
Ã,  Ã,  Display("%s is dead!", CHAR1);
Ã,  Ã,  RestartGame();//if you want to restart when char1 dies...
Ã,  Ã,  }
Ã,  }


Also, I suggest reading the Manual that comes with AGS. It explains much of AGS.

EDIT: In case you can't figure it out, you would need an integer (int char#_hp) for each character, replacing # with a number (it appears you want 4 chars, so #1-4...)

And if you're wondering what the "%d" and "%s" are for, "%d" is replaced with a decimal (int) IF used correctly, and "%s" is replaced with a string (string) IF used correctly...
Title: Re: who can i make a hp display?
Post by: Gregjazz on Thu 02/12/2004 02:28:35
I know what you're talking about. I've done that HP display in one of my amazing unreleased AGS action games.

Just make a GUI (set the GUI background to the color of the bar, or even better, make it a gradient or something) for the HP bar and then use the SetGUISize function make the HP bar diminish. SetGUISize does not scale the GUI background, it just crops it, so it looks and acts just like a real HP bar!