Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: on Mon 16/06/2003 09:32:25

Title: energy bar
Post by: on Mon 16/06/2003 09:32:25
is there anyway to make a energy bar? ie the character's strenght after attacks?

Paranoia
Title: Re:energy bar
Post by: Mr Jake on Mon 16/06/2003 12:14:37
SOmeone said something about using int counters... I see if I can find the post
Title: Re:energy bar
Post by: TerranRich on Mon 16/06/2003 16:11:22
Yes, use a global int for the value of the energy level. Let's say it ranges from 0 to 100, and you're using global int #47,  as an example. Every time the player gets attacked, you could use SetGlobalInt(47, GetGlobalInt(47)-3); to decrease the energy level by 3 every time. If the player drinks some potion or eats some food to regenerate his/her energy, use SetGlobalInt(47, GetGlobalInt(47)+2); to increase by 2 every time, for example.

As for the graphical part of the energy bar, that's something I don't really know how to do. As far as I know, there isn't any way to resize GUI objects during runtime. Or is there? Does anyone else know?
Title: Re:energy bar
Post by: Mr Jake on Mon 16/06/2003 17:25:25
You could use a GUI for each 1% to 100% but that would take a lot of filespace...
Title: Re:energy bar
Post by: Scummbuddy on Mon 16/06/2003 17:50:44
No, you could set up 10 back-to-back pics... say 10% levels.

then
---------------------------------
SetButtonPic
SetButtonPic (int gui, int object, int which, int newslot)

Changes a GUI button's graphic to the one you specify. This could be used as an indicator of whether a feature is switched on or off by changing its picture. Sets object number OBJECT on gui GUI to NEWSLOT from the sprite manager.
The WHICH parameter selects which picture to change. It can have these values:

1  normal picture
2  mouse-over picture
3  button pushed picture

Note that you can pass NEWSLOT as -1 to disable the mouse-over and pushed pictures.
Example: if the GUI setup in the editor specifies a pushed-pic, but you want to change the main picture in the game (and so remove the old pushed picture), you can do something like this:

SetButtonPic (2, 3, 1, 100);
SetButtonPic (2, 3, 3, -1);

which will change button 3 on GUI 2 to have normal picture the one in slot 100 and not have a pushed graphic.

-------------------------------------------

You can turn them on and off succesfully, especially with the help of an if statement to find which one needs to be turned on or off next.
Title: Re:energy bar
Post by: on Mon 16/06/2003 17:59:19
TY Scummbuddy ;D thats great

Paranoia