how do you make health?

Non-platform specific questions.

how do you make health?

Postby automail10 » Sun Sep 30, 2007 11:01 pm

how do you make health using text?
Back
User avatar
automail10
 
Posts: 280
Joined: Sun Jun 03, 2007 11:30 pm
Location: On a pancake on a bunny.
Score: 5 Give a positive score

Re: how do you make health?

Postby Rux » Sun Sep 30, 2007 11:27 pm

Make a text number actor and a health var. Text Number Actor -> Draw Actor ->
Code: Select all
textNumber = health;

Then Text Number Actor -> Create Actor ->
Code: Select all
health = //How much health you want\\;

Then collision with the bullet or whatever hurts the player Player -> Collision=Bullet Repete=No ->
Code: Select all
health = health -//how much you want to take away\\;


This should work. Try it! :D
I'm not good at coming up with signatures...
User avatar
Rux
 
Posts: 645
Joined: Sun Apr 29, 2007 9:26 pm
Location: Sitting on your moniter invisable.
Score: 35 Give a positive score

Re: how do you make health?

Postby Kalladdolf » Mon Oct 01, 2007 1:21 pm

yeah and:
if(health<0)
{//die action}
User avatar
Kalladdolf
 
Posts: 2427
Joined: Sat Sep 08, 2007 8:22 am
Location: Germany
Score: 120 Give a positive score

Re: how do you make health?

Postby automail10 » Sun Oct 07, 2007 4:28 pm

Amother Question, how do you make the game over thing after you run out of health?
Back
User avatar
automail10
 
Posts: 280
Joined: Sun Jun 03, 2007 11:30 pm
Location: On a pancake on a bunny.
Score: 5 Give a positive score

Re: how do you make health?

Postby Freddy » Mon Oct 08, 2007 12:37 am

Make an actor with game over text. Then, go to the text actor that has how much health you have left, and in draw actor , script editor type in:
Code: Select all
if("whatever your health variable is here"<1)
{
"create actor event here"
}

in the "create actor event here" section, make it so that it creates the game over text. You can make the position of where it is created relative to the creator, which will most likely be in the view.
Hope this helps :D
Hola
User avatar
Freddy
 
Posts: 548
Joined: Sat Jun 02, 2007 3:42 pm
Location: Why do you want to know?
Score: 14 Give a positive score

Re: how do you make health?

Postby automail10 » Tue Oct 09, 2007 5:20 am

I'll try that later.
I'll keep that in mind.
Back
User avatar
automail10
 
Posts: 280
Joined: Sun Jun 03, 2007 11:30 pm
Location: On a pancake on a bunny.
Score: 5 Give a positive score

Re: how do you make health?

Postby DollMaster » Wed Oct 10, 2007 5:30 am

Can someone help in THIS situation and tell me why its not working as plannned? I want there to be a text health meter that displays your max health. ie. HEALTH: 147 / 150

I have have 5 variables. health, healthmax, stat1, stat2, stat3.

I have 3 actors. player, healthmeter, healthmetermax.

The player create actor event determines the values of stat1, stat2, stat3, and starting health.
Code: Select all
stat1=1;
stat2=1;
stat3=1;
health=999


healthmetermax > draw actor:
Code: Select all
healthmax=(stat1+stat2)*5;
textNumber=healthmax;


healthmeter > draw actor
Code: Select all
textNumber=health;

//if it goes over max, make it equal max
if(health>healthmax)
health=healthmax;

//if it goes under 0, make it 0
if(health<0)
health=0;


This code works as planned, except the current health stays at 0. If I take out the code that prevents it from going over max or under 0, it makes the health be whatever I set it at. What am I doing wrong?
DollMaster
 
Posts: 65
Joined: Fri Jun 16, 2006 2:38 am
Score: 2 Give a positive score

Re: how do you make health?

Postby DollMaster » Wed Oct 10, 2007 6:07 am

Ok, I propose there is a bug with the textNumber variable. As the following code works fine thus far.

Code: Select all
healthmeter.textNumber = health;

if(health>healthmax)
healthmeter.textNumber = healthmax;

if(health<000)
healthmeter.textNumber = 000;


Either there is a bug, OR I am not using it right, OR the numerous tutorials that members point nooblins to on this board are done incorrectly.
DollMaster
 
Posts: 65
Joined: Fri Jun 16, 2006 2:38 am
Score: 2 Give a positive score

Re: how do you make health?

Postby pixelpoop » Wed Oct 10, 2007 3:43 pm

This looks like a problem,
it looks to me that your health should equal 10.
if stat1 is equal to 1, and so is stat2
then
stat1+stat2=2
2*5=10
so healthmax is equal to 10.

Also, double check that you are using global variables when needed, or calling out a specific actor to change a variable from another actor.
ie: actor1.variable2=2+2;
User avatar
pixelpoop
 
Posts: 276
Joined: Tue Aug 29, 2006 9:32 pm
Score: 28 Give a positive score

Re: how do you make health?

Postby DollMaster » Wed Oct 10, 2007 11:00 pm

Yeah it should equal 10, but it was giving me 0. That 2nd group of code I posted worked perfectly. Can you explain what the difference between

healthmeter.textNumber = healthmax;

and

textNumber=healthmax;

I was under the impression that they were the same, but it clearly wasn't as the latter did not work for me.
DollMaster
 
Posts: 65
Joined: Fri Jun 16, 2006 2:38 am
Score: 2 Give a positive score

Re: how do you make health?

Postby pixelpoop » Thu Oct 11, 2007 1:15 am

Use this format:
actor.actorVariableName=4+4;
when you need to change an actor's variable (aka "local variable") from within another actor. It is like naming a path or a folder followed by the variable you want to access.

You don't need to name an actor when using global variables since all actors use the same value. You also don't need to name the actor if you are coding within the actor that you want the variable changed for.
So you would just use:
actorVariableName=4+4;

and I think you may have to name the actor all the time when changing it's displayed text value.
User avatar
pixelpoop
 
Posts: 276
Joined: Tue Aug 29, 2006 9:32 pm
Score: 28 Give a positive score

Re: how do you make health?

Postby DollMaster » Thu Oct 11, 2007 4:00 am

Ok next, question...

When you are in the script editor within an actor, and you create a variable using the variable button. Those are global or local?
DollMaster
 
Posts: 65
Joined: Fri Jun 16, 2006 2:38 am
Score: 2 Give a positive score

Re: how do you make health?

Postby DilloDude » Thu Oct 11, 2007 5:16 am

If you set the variable to be global, then one global variable is created. If you set it to be an actor variable, it is added to the Actor struct (IE each actor has their own). If you want to make a local variable (only for the particular script) you must define it in code:
Code: Select all
int variable;
Image
User avatar
DilloDude
 
Posts: 866
Joined: Tue Jan 24, 2006 9:51 am
Location: Nyerellion
Score: 58 Give a positive score

Re: how do you make health?

Postby automail10 » Sun Oct 28, 2007 1:24 am

You all overhelped me.
Now i forgot game over and health cause there was too much help!
Back
User avatar
automail10
 
Posts: 280
Joined: Sun Jun 03, 2007 11:30 pm
Location: On a pancake on a bunny.
Score: 5 Give a positive score


Return to General

Who is online

Users browsing this forum: Google [Bot] and 1 guest

cron