Game Development Community

Another set of Energy / Health Gui Objects

by Harold "LabRat" Brown · in Torque Game Engine · 08/17/2001 (10:08 pm) · 19 replies

Here are 4 more new GUI objects, I did things a bit differently then the other sample provided here. I'm sure each has it's Pro's and Con's.

New GUI Objects

Included in the zip are 4 new GUI controls:

Player Energy
Player Health
Vehicle Energy
Vehicle Health

Add the .cc and .h files to gui folder in the appropriate sections. After that you will probably want to add 4 new gui profiles as below:

new GuiControlProfile ("GuiEnergyBarProfile")
{
opaque = false;
fillColor = "0 0 255 100";
border = true;
borderColor = "0 255 0";
};

new GuiControlProfile ("GuiHealthBarProfile")
{
opaque = false;
fillColor = "255 0 0 100";
border = true;
borderColor = "0 255 0";
};

new GuiControlProfile ("GuiVehicleEnergyProfile")
{
opaque = false;
fillColor = "0 0 255 100";
border = true;
borderColor = "0 255 0";
};

new GuiControlProfile ("GuiVehicleHealthProfile")
{
opaque = false;
fillColor = "255 0 0 100";
border = true;
borderColor = "0 255 0";
};

Once you have added those you will need to add the GUI objects to your Playgui. You can either do that with the GUI Editor. Or you can add the following befor the last "};" at the end of your PlayGui.gui file:

new GuiEnergyBarCtrl() {
profile = "GuiEnergyBarProfile";
horizSizing = "left";
vertSizing = "bottom";
position = "522 7";
extent = "105 16";
minExtent = "8 8";
visible = "1";
helpTag = "0";
};
new GuiHealthBarCtrl() {
profile = "GuiHealthBarProfile";
horizSizing = "left";
vertSizing = "bottom";
position = "522 28";
extent = "105 16";
minExtent = "8 8";
visible = "1";
helpTag = "0";
};
new guiVehicleEnergyCtrl() {
profile = "GuiEnergyBarProfile";
horizSizing = "right";
vertSizing = "top";
position = "79 456";
extent = "105 16";
minExtent = "8 8";
visible = "1";
helpTag = "0";
};
new guiVehicleHealthCtrl() {
profile = "GuiHealthBarProfile";
horizSizing = "left";
vertSizing = "top";
position = "461 456";
extent = "105 16";
minExtent = "8 8";
visible = "1";
helpTag = "0";
};

Compile a new test application and give it a test run. the result should look something like this:

zebest.mine.nu/V12/GuiControls.png

#1
08/18/2001 (3:06 am)
LabRat

hey, i think i sent you an email about a project, could use you big time

irc.dynamix.com #v12

pm either me, (Draconix or Drax, depending on which computer) or Xylek

Could really use your help :D
#2
08/18/2001 (12:58 pm)
Really, really tiny nit:
In guiHealthBarCtrl.cc
#include "gui/GuiHealthBarCtrl.h" should be
#include "gui/guiHealthBarCtrl.h"
Ditto in guiVehicleHealthControl.c . :)

Nifty example! Thanks!
#3
08/18/2001 (1:48 pm)
Doh..

Thought I had fixed those
#4
08/19/2001 (4:29 am)
Not sure why yet, but getEnergyValue() is always returning NULL. How did you get around that? I haven't found why this is happening, yet. I'm still looking though.

If you could tell me it would save some time :)


Dark

*Edit: Figured it out. I forgot to put obj-> before it, then got forum happy and decided to post. Anyway, thanks, and nice code :)

You are a genius, and a gift to the community. Thank you.
#5
08/20/2001 (7:48 pm)
where do you add
new GuiControlProfile ("GuiEnergyBarProfile")
{
opaque = false;
fillColor = "0 0 255 100";
border = true;
borderColor = "0 255 0";
};

new GuiControlProfile ("GuiHealthBarProfile")
{
opaque = false;
fillColor = "255 0 0 100";
border = true;
borderColor = "0 255 0";
};

new GuiControlProfile ("GuiVehicleEnergyProfile")
{
opaque = false;
fillColor = "0 0 255 100";
border = true;
borderColor = "0 255 0";
};

new GuiControlProfile ("GuiVehicleHealthProfile")
{
opaque = false;
fillColor = "255 0 0 100";
border = true;
borderColor = "0 255 0";
};
I'm sorta lost still I added those file ( to the /engine/gui/ I presume section and recomplied but)
there wern't any new selections in the gui editor isn't that what supost to happen? please help these .guis are totally brand new to me
thnaks anthony
#6
08/20/2001 (8:26 pm)
Anthony,

I have created a separate script that contains profiles I have added (guiProfiles.cs), such as the ones you need to add for the examples posted. I simply created the file and pasted in the code you are asking about in it. I then placed the file in /client/ui, as it seemed an appropriate place due to its association with the *.gui scripts.

You then have to make sure it is executed in the console while running the test app or execute it from the script /client/main.cs).

If the former, use

exec("client/ui/guiProfiles.cs");

If the latter, use

exec("~/ui/guiProfiles.cs");

I placed my call in /client/main.cs before the line that reads exec("~/ui/PlayGui.gui"); .

Hope that was clear.
#7
08/20/2001 (9:03 pm)
I see what is happening but console says it dosn't find those profiles. . tried both ways . . do a I need to recompile again or can I set up in gui editor?
thanks dw your now in my code :-) Anthony
#8
08/21/2001 (12:03 am)
Anthony,

I'm not clear what you mean when you say it doesn't find those profiles. Do you mean that when you try to exec the guiProfiles.cs script (or whatever you named your file) from the console that it gave an error about a missing file? Or something else?

Once you have built the new files that were posted into the engine and created a new executable, and then added and executed the profile script I mentioned, you should be ready to start up the app and add the controls via the GUI editor.

Try to give a step-by-step account of what you did and let's see if one of us can't help you.
#9
08/21/2001 (8:49 am)
ok I got the guiHealth/Engery stuff to compile and I can use them to make an interface. BUT my question is about THE gui profile (had copied and pasted earlier) I did make a new txt doc and copied and pastes DIRECTLY from here to there. Then I went into the main.cs in /example/client/ and added the exceute command however when I load the game in the console it reads
"client/main.cs(0):unable to find funtion exce" and then goes on saying "client/ui/playgui.gui(0) unable to instigate non conobject class EnergyBarCtrl" one for each of the new gui objects!!!! Basically am I aiming the main.cs wrong or putting guiProfile.cs file in wrong place, it is in client/iu/ folder and the exce I got straight from above. Please help, or could I just go into the game and add the gui by myself and take them out of the guiplay.gui or something!!! silly thing driving me nuts
thanks Athony
#10
08/21/2001 (8:57 am)
I am and Idoit I had the exec as "exce" damb typos. so that is one problem down the guiprofile.gui did execute BUT STILL it says for each guihealth/energy it says
"client\ui\playgui.gui(0)unable to instantiate non-object class . . . " so what does that mean and how do I fix it
Thanks Anthony
#11
08/23/2001 (10:48 am)
Erm, when i run a new compile, it doesn't add the new files to the build, is there any way to force it to do so?
#12
08/23/2001 (11:18 am)
Add the news files to the project.
#13
08/23/2001 (11:29 am)
OK, my game is in a different folder, so what i need to do is copy over any files that the last compile (that added the health bar) changed, can you tell me what files i'll need to move to get this to work please?
#14
08/23/2001 (6:53 pm)
Heh.. I can't get this working either..

I put all the headers and .cc files into the project and compile. They compile fine. And I know they're in there. I added the gui profiles to whatever that defaultGameProfiles.cs and added the other things to PlayGui. The console shows no errors, but I cannot see the bars.
#15
09/01/2001 (11:14 am)
wow I'm all over this thread. . . anyway I was wondering I added all of these and the player seems to work fine but it never seems to effect the damage on the vehicle am I missing something?
anthony
#16
09/02/2001 (3:07 pm)
The next release of v12 has a decent HUD framework and the following objects:

HudBarDisplayCtrl
HudBezierDisplayCtrl
HudBitmapCtrl
HudClockCtrl
HudCrosshairCtrl
HudHealthCtrl
HudObject (Top of the inheritance tree for HUDs)
HudZoomCtrl

Check my last .plan update for screenshots.
#17
09/02/2001 (7:39 pm)
I have just finished my bitmap energy/health huds... if anyone is interested I could post them....
#18
09/02/2001 (8:15 pm)
I would like the bitmap health and enery huds...
#19
09/03/2001 (10:18 am)
My Bitmap Health and Energy controls are now avaible at http://v12.mgonetwork.com/