Page 1 of 2
Life Bar System
Posted: June 16th, 2009, 12:52 pm
by GoBologna120
I would like to know if it's possible to give your character a life bar that floats above their head using only a .cfg. I'm not very good at C++, so I'm not sure that I can really code it into the source code.
Re: Life Bar System
Posted: June 16th, 2009, 8:30 pm
by Hirato
it's literally one line of code, the declaration you'd want to use...
Code: Select all
extern void particle_meter(const vec &s, float val, int type, int fade = 1, int color = 0xFFFFFF, int color2 = 0xFFFFF, float size = 2.0f);
and how you'd use it
Code: Select all
particle_meter( player1->abovehead(), 100 * player1->health / player1->maxhealth, PART_TEXT, 1, 0xFF0000, 0, 2.0f);
might require a few attempts, but good luck (and check the wiki on compiling)
Re: Life Bar System
Posted: June 17th, 2009, 11:56 am
by Mike
And/or you could check out the RPG

Take care.
-mike
Re: Life Bar System
Posted: June 17th, 2009, 1:56 pm
by GoBologna120
Hirato wrote:it's literally one line of code, the declaration you'd want to use...
Code: Select all
extern void particle_meter(const vec &s, float val, int type, int fade = 1, int color = 0xFFFFFF, int color2 = 0xFFFFF, float size = 2.0f);
and how you'd use it
Code: Select all
particle_meter( player1->abovehead(), 100 * player1->health / player1->maxhealth, PART_TEXT, 1, 0xFF0000, 0, 2.0f);
might require a few attempts, but good luck (and check the wiki on compiling)
Awesome! Thanks. I'll check the RPG source to see where I'd put it.
Re: Life Bar System
Posted: June 17th, 2009, 8:16 pm
by DarthMaak
Hirato wrote:it's literally one line of code, the declaration you'd want to use...
Code: Select all
extern void particle_meter(const vec &s, float val, int type, int fade = 1, int color = 0xFFFFFF, int color2 = 0xFFFFF, float size = 2.0f);
and how you'd use it
Code: Select all
particle_meter( player1->abovehead(), 100 * player1->health / player1->maxhealth, PART_TEXT, 1, 0xFF0000, 0, 2.0f);
might require a few attempts, but good luck (and check the wiki on compiling)
Does this require me to make a new cfg document or is there some kind of already-made-cfg document I can import this in?
Re: Life Bar System
Posted: June 17th, 2009, 9:14 pm
by GoBologna120
This goes in the source code. You don't use a .cfg.
Re: Life Bar System
Posted: June 17th, 2009, 9:35 pm
by CollegeforKids
GoBologna120 wrote:This goes in the source code. You don't use a .cfg.
I'm a little confused by this statement. Does it go in an OGZ file then?
Re: Life Bar System
Posted: June 17th, 2009, 9:41 pm
by GoBologna120
Looked at the Wiki recently?
http://sandboxgamemaker.com/wiki/index. ... ource_code
It's C++ code, therefore, you have to recompile the game to use it.
Re: Life Bar System
Posted: June 17th, 2009, 10:22 pm
by CollegeforKids
I get it now, you must understand my confusion. Considering the only thing that explains how to edit code (for an actual purpose that is mentioned...aka NPCs) says to edit it in the config. The wiki doesn't really explain when you need to use C++ and compile...yet

Re: Life Bar System
Posted: June 18th, 2009, 5:42 pm
by GoBologna120
That's because you can do so much without recompiling.
EDIT: Okay. I can't figure out where to put it.
