Can somebody fix/set up my health bar for me?

Talk about making games.

Can somebody fix/set up my health bar for me?

Postby lilmuleman214 » Fri Jul 27, 2007 6:37 pm

Ok, in my game I have a health bar actor but do not know how to get it setup so it will go down if my main character in the game gets hurt/damaged. And I dont know how to make other things able to damage my main character. If someone who is experienced in this could help me, and fix my problem in the game I would really be thankful.

I would upload my game, but I dont know how too. So i think i need to know how to do that to, so I can let somebody fix the game for me.
Life is to good to waste
Go To http://www.Game-junkiez.us
to play/download my games.
User avatar
lilmuleman214
 
Posts: 102
Joined: Wed Jul 25, 2007 6:42 pm
Score: 5 Give a positive score

Postby DilloDude » Fri Jul 27, 2007 11:40 pm

To upload a game first put it in a zip file, then when you post, put it's name in the filename box. Then add a comment, and click the add attachment button.
Image
User avatar
DilloDude
 
Posts: 866
Joined: Tue Jan 24, 2006 9:51 am
Location: Nyerellion
Score: 58 Give a positive score

Postby arcreamer » Sat Jul 28, 2007 5:14 am

ok, here is how to make a health bar... (by the way u can thank Caaz for this)
open up paint/photoshop/whatever u use... and make a simple health bar with 3+ frames... (normally people like 3 or more lives) and then open up GE and make a actor called HealthBar and add the health bar animation to it... then on Draw Actor, change the animation direction to stopped! once ur this far, make sure u have a main character and an enemy... if u dont, make them then proceed to the next step. Ok once u have a main actor and an enemy, click on HealthBar actor and type DestroyActor("Event Actor"); under the HealthBar's Draw Actor event... then click on ur main actor and click ok add event/collision/script editor/ type this... HealthBar.animpos++; and that will do it... now u have a working health bar
arcreamer
 
Posts: 398
Joined: Tue Jul 03, 2007 4:08 pm
Score: 9 Give a positive score

Postby DocRabbit » Sun Jul 29, 2007 4:18 am

First off, makslane gets credit here for the Goober's initial graphic.
Kudos to Caaz for coming up with the simple healthbar routine displayed here.

Here is a complete tutorial on how to work with a healthbar, text representation of health, changing weapon when strike occurs, and showing damage to the enemy you are hitting.
I am also providing the files to look at.

Open GE and create the following actors:
Goober
DeadGoober
texthealth
mouseweapon
HealthBar


spelling in the actors names only matters if you are following this code with cut and paste.

For the animations, again do the following:

Goober: 4 frame animation, you can use my graphic or your own if you want. Name it:pachurts_00

DeadGoober: single frame image. Name it whatever you want.

HealthBar:12 frame animation, Name it whatever you want.

mouseweapon:2 frame animation, Name it:spikeball01

texthealth:click the text button, select what font you want, and enter 000% in the text area so you can see the size it will be for placement.

Variables:

You only need to make one, and it is an Actor variable. Name it:health, and make it an integer.
If you don't understand how to do it, select [global code] from the script menu at the top, click on [Variables] button. Then click on [Add] button,
type: health next to Name:, click [Global] and change it to [Actor variable], then click [add] button at the bottom of the popup window. Then click [Close] button at the bottom of the User Variables popup window. You can now click [close] on the global code window or go ahead and add your global code in.

The syntax for the following code can be described as:

Actor -> Event
Using Actor Control window:
Select the actor next to "Name:" for the first part, click [add] button next to "Events:"
Then Select the Event stated in the second part. For the Collision events, the name and sides are listed in the () section.
Now for the [add action], select script editor for all code sections below.

Example:
DeadGoober->Create Actor.
You would select DeadGoober next to "name:"
From the [add] button next to "Events:" you would select [Create Actor],
and from the [Add Actions] button, you would select [Script Editor].

This should do it for the prep, you are ready to enter your coding now.


Put this in global code.
Code: Select all
Goober.health=100;
sprintf(texthealth.text,"%d%%",Goober.health);

Save it as primethem.
This sets the Actor: Goober's initial health to 100 and
prints it to the Text Actor: texthealth in the visual form of: 100%

Place this in DeadGoober->Create Actor.
Code: Select all
transp=.999;

This sets the actor used to show dead player to virtually invisible until needed.

Place this in Goober->Create Actor.
Code: Select all
Goober.health=100;
ChangeAnimation("Event Actor", "pachurts_00", STOPPED);

This sets Actor: Goober's health back to 100 on respawn.(This demo as is doesn't respawn him)
The ChangeAnimation here Sets Goober's initial Animation to the first frame and stopped.

****UPDATED***** This section was mistakenly ommited early.
Place this in HealthBar->Create Actor.
Code: Select all
ChangeAnimation("Event Actor", "HB", STOPPED);

Sets the HealthBar to not count down by itself.

Place this in HealthBar->Draw Actor.
Code: Select all
DestroyActor("Goober");
DeadGoober.transp=0;

This code is used to Destroy the Actor:Goober and make the dead actor:DeadGoober visible
after HealthBar has reached frame 11.

Instead of clicking immediate action, choose wait for frame action.
Then in the popup window, enter: 11;
This tells it to wait until HealthBar is displaying the 11th frame before executing this.

Place this in texthealth->Create Actor.
Code: Select all
sprintf(texthealth.text,"%d%%",Goober.health);

This too prints to the text actor:texthealth the Goober's health.

Place this in mouseweapon->Create Actor.
Code: Select all
ChangeAnimation("Event Actor", "spikeball01", STOPPED);
FollowMouse("Event Actor", BOTH_AXIS);

This sets the initial animation of the spikeball actor:mouseweapon to the clean frame.
The FollowMouse line makes the actor: mouseweapon follow the mouse pointer, as if glued to it.

Place this in mouseweapon->Collision (Any Side of Goober).
Code: Select all
mouseweapon.animpos=1;
HealthBar.animpos++;

if (Goober.health!=100)
      {
       Goober.health-=9;
      }
else
      {
      Goober.health-=10;
      }


sprintf(texthealth.text,"%d%%",Goober.health);

if(Goober.health>90)
             {
             Goober.animpos=0;
             }
else if(Goober.health<91 && Goober.health>70)
             {
             Goober.animpos=1;
             }
else if(Goober.health<71 && Goober.health>45)
             {
             Goober.animpos=2;
             }
else
             {
             Goober.animpos=3;
             }

There is alot here, so I will break it down in sections.
First: The mouseweapon and HealthBar animpos change the frames of both actors, the
HealthBar is simply incremented to the next while the mouseweapon is set to a
specific one.
Second:The if.else statement for Goober.health just decreases the health variable of Actor:Goober.
I used this simply to make the health % display to come out evenly.
Third: The sprintf just updates the screen display of the textactor texthealth with the new health value.
Fourth:The If.else if..else statements on the Goober.health just change the Goober's image to show damage
visually.

Place this in mouseweapon->Collision Finish(Goober).
Code: Select all
mouseweapon.animpos=0;

This just sets the spikeball back to a clean image.(no blood and guts)

This should complete the detailed description of how to make a healthbar along with text display work,
along with making visual damage show on the attacked enemy. This is geared to all the new users who have had questions
on how to use the healthbar.

The actors used in this are:
mouseweapon(2 frame animation of type:weapon)
Goober (a 4 frame unfortunate soul who is doomed to die.)
DeadGoober (His one frame dead pool of goo.)
HealthBar (a 12 frame red,yellow,green indicator of certain doom for Goober.)
texthealth (a text equivalent to the HealthBar)

NOTE:Unfortunately, some Goobers were hurt to bring you this tutorial.
Attachments
hbtutorial.zip
The ged file with data included.
(87.75 KiB) Downloaded 120 times
hbtutorial_ss.jpg
Screenshot
Last edited by DocRabbit on Mon Jul 30, 2007 7:52 pm, edited 2 times in total.
User avatar
DocRabbit
 
Posts: 114
Joined: Fri Oct 27, 2006 2:56 am
Score: 10 Give a positive score

Postby lilmuleman214 » Mon Jul 30, 2007 4:18 pm

thanks everybody
Life is to good to waste
Go To http://www.Game-junkiez.us
to play/download my games.
User avatar
lilmuleman214
 
Posts: 102
Joined: Wed Jul 25, 2007 6:42 pm
Score: 5 Give a positive score

Postby lilmuleman214 » Wed Aug 08, 2007 12:01 am

If I want My main actor to die once his health reach's zero, what would be the code that I put in the health bar?
Life is to good to waste
Go To http://www.Game-junkiez.us
to play/download my games.
User avatar
lilmuleman214
 
Posts: 102
Joined: Wed Jul 25, 2007 6:42 pm
Score: 5 Give a positive score

Postby DocRabbit » Fri Aug 10, 2007 3:24 am

Place this in HealthBar->Draw Actor.
Code:
Code: Select all
DestroyActor("YourMainActorsName");

 


This code is used to Destroy the Actor:YourMainActorsName after HealthBar has reached frame 11.

Instead of clicking immediate action, choose wait for frame action.
Then in the popup window, enter: 11;
This tells it to wait until HealthBar is displaying the 11th frame before executing this.

This is of course if you are using the framed damage method described above.

If you want, post your healthbar draw actor code here along with the name of your actor and I can edit it for you to paste back in.
Attachments
ss2.jpg
What to enter in popup window.
ss1.jpg
Wait for action Click
User avatar
DocRabbit
 
Posts: 114
Joined: Fri Oct 27, 2006 2:56 am
Score: 10 Give a positive score


Return to Game Development

Who is online

Users browsing this forum: No registered users and 1 guest

cron