Page 1 of 2
Zelda Style Heart Bar- how to do?
Posted: Mon Dec 17, 2007 11:59 pm
by elussya
Looking for a tutorial or somesuch for assistance on this- I can't figure out how to
accomplish a zelda style heart bar..
In other words- pick up vial/heart pieces to increase your characters total life
capacity (4 pieces = 1 increase), which would reflect on the players HUD,
in the form of ((base # of hearts/vials)+1 more per 4 pieces found)- in other
words a health bar that looks like a heart bar, but that increases by adding
a "heart" to your bar...
Any zelda fans out there that know how to pull this off? I'd love to use a
a gui like this for my project so that I can actually finish in a realistic time-frame
Please help
*hugs* Elussya
Posted: Tue Dec 18, 2007 12:17 am
by steven8
Hello elussya, and welcome to Reality Factory. I'm not sure how to accomplish what you desire, but there is a good section on Heads Up Displays in your RF manual. Find it under Programs>Reality Factory>RF Manual On the left hand menu side, you will find a listing for Heads Up Display. Withing this, is what I believe you need. At the top you find 'Pictures'. That is what I think you may need to use. Let us know if this helps.
Good Luck!!
Posted: Tue Dec 18, 2007 1:43 am
by elussya
Hmm... I don't think that the default HUD assistance will work the way I'm hoping.
I'm hoping to be able to pick up more 'hearts' in the style of zelda, and have them
displayed on the HUD health area (while still having them decrease when the player
is hit)
Posted: Tue Dec 18, 2007 4:40 am
by Agentarrow
That'd be hard to do, the people of nintendo created their own zelda engine from scratch, it was pretty cool though, it could compile in Gamecube or Wii format. (for twilight princess) Anyway, speaking of Nintendo, My health Bar for Terra Trooper needs to be like in Metroid, with those little energy tanks that store a full health bar... Would that be something I could do from the manual?
Posted: Tue Dec 18, 2007 2:01 pm
by Juutis
Allright, so let me get this straight. You want to have a row of hearts on the screen and every time you pick up 4 powerups one heart is added to the row?
You could use a healtbar-style HUD element that has large enough intervals in the attribute that it only shows full hearts. In other words, if you increase the attribute with 1, the health bar will become larger and reveal a full heart (instead of half a heart, or one pixel of the next heart).
First off you need to have two different attributes:
Code: Select all
[heartpieces]
initial = 0
low = 0
high = 4
[hearts]
initial = 1
low = 0
high = 8
Then set up a simple script that will handle the 4 heart pieces becoming one heart:
Code: Select all
{
Spawn[ ()
{
LowLevel("setup");
} ]
setup[ ()
{
PawnRender(false); //Don't render the pawn
SetNoCollision(); //Don't collide
self.think = "run";
} ]
run[ ()
{
self.ThinkTime = 0.1; //execute every 0.1 seconds
if(GetAttribute("heartpieces","Player") = 4) // if enough powerups have been collected
{
SetAttribute("heartpieces",0,"Player"); // reset the number of the powerups
ModifyAttribute("hearts",1,"Player"); // add one full heart
}
} ]
}
Add a pawn with this script into the level. It will be invisible and doesn't collide with anything, so it shouldn't affect the game world in any way.
Next, you need to set up your HUD so that it shows the hearts. Now you should create a bitmap that has a row of hearts (either vertical or horizontal). I'll give an example of how to set up the HUD with a horizontal row of 8 hearts that are 32x32 pixels (So the image size for the HUD element is 256x32):
Code: Select all
[hearts]
type = horizontal
frame = XXX.bmp
framealpha = YYY.bmp
indicator = ZZZ.bmp
indicatoralpha = XYZ.bmp
framex = center
framey = 64
indicatoroffsetx = 0
indicatoroffsety = 0
indicatorwidth = 256
This should create the "health bar" in the top center of the screen.
I hope you get what I mean. I didn't test any of this so if you can't get it to work or get some weird errors feel free to ask questions.
***EDIT***
Oh, and welcome to the forums.
Posted: Tue Dec 18, 2007 2:03 pm
by paradoxnj
It's actually not that hard to do. RF might not be able to do it right out of the box, but with a little creativity anything is possible. Here's how you can fake it. Create a HUD item with the maximum amount of heart containers that your player can have. Use script to hide the ones from the player that are not active or have been removed due to damage.
Posted: Tue Dec 18, 2007 8:29 pm
by elussya
Awesome!! That looks like it'll work, I'll be able to test it tomorrow
once my computer's back from the shop
*hugs*
That's saved alot of head bashing from the last few days
Once it's tested and working with my level I'll be posting some screenshots
This is thus far, definitely the most friendly forum I've been part of
Cheers,
Elussya
Posted: Wed Dec 19, 2007 2:33 am
by Agentarrow
welcome to the forums, I forgot to mention that
'-.- anyway, So Juutis, you seem to be good at scripting, could I ask you a favor? a script for a Metroid style health bar? with Energy Tanks and stuff? You don't have to if you don't want to, but it never hurts to ask...
Posted: Wed Dec 19, 2007 4:36 am
by steven8
elussya wrote:Awesome!! That looks like it'll work, I'll be able to test it tomorrow
once my computer's back from the shop
*hugs*
That's saved alot of head bashing from the last few days
Once it's tested and working with my level I'll be posting some screenshots
This is thus far, definitely the most friendly forum I've been part of
Cheers,
Elussya
That'll be excellent! We love screenshots!!
AA - I've never seen that Metroid health bar. Post a screen, if you can. I did a google search, with no luck. No good shots where the HUD is clear.
Posted: Wed Dec 19, 2007 11:35 am
by Juutis
Agentarrow wrote:So Juutis, you seem to be good at scripting, could I ask you a favor? a script for a Metroid style health bar? with Energy Tanks and stuff? You don't have to if you don't want to, but it never hurts to ask...
Let's see, so every time the player's health reaches 0 you want to see if there's a full energy tank and if so, fill the health bar and empty one tank?
Shouldn't be too tricky. First you have to find a way to prevent the player from truly dying. RF's built-in player dies when its health reaches 0, so if you don't let it go that low, the player shouldn't die. So, in the attributes:
Code: Select all
[health]
initial = 100
low = 1
high = 100
[energytanks]
initial = 5
low = 0
high = 10
Since 1 is the lowest value 'health' can have, the player can't die. Then a little piece of script:
Code: Select all
{
Spawn[ ()
{
LowLevel("setup");
} ]
setup[ ()
{
PawnRender(false); //Don't render the pawn
SetNoCollision(); //Don't collide
self.think = "run";
} ]
run[ ()
{
self.ThinkTime = 0.1; //execute every 0.1 seconds
if(GetAttribute("health","Player") = 1) // if 'health' is 1
{
if(GetAttribute("energytanks","Player") > 0) //if there's at least 1 energy tank
{
SetAttribute("health",100,"Player"); // set player's health to 100
ModifyAttribute("energytanks",-1,"Player"); // remove one energy tank
}
else // if there are no energy tanks left
{
SetAttributeValueLimits("health",0,100,"Player"); //let health reach zero
SetAttribute("health",0,"Player"); //kill the player
}
}
} ]
}
I hope this gets you started.
Posted: Wed Dec 19, 2007 9:49 pm
by Agentarrow
thx!!!
===EDIT===
And Steven, Here:
Posted: Thu Dec 20, 2007 7:48 am
by Spyrewolf
Hang on didn't Qod do this for his game? the zelda style health bar, I've seen the images,
yep found it in the gallery! look in teh gallery under legend of Okkora, (sorry if the spelling is out quest)
Posted: Thu Dec 20, 2007 11:58 am
by QuestOfDreams
Although it looks like a Zelda health bar in these screens it was in fact just a normal health bar with alpha maps and didn't work as described above.
Re: Zelda Style Heart Bar- how to do?
Posted: Wed Jan 23, 2008 3:58 pm
by ArKanuS
Hi, Juutis I was wondering if you could make me a script to?
I would like to have like a shield (like health) which when runs out starts affecting your health but if you wait awhile the shield recharges but your health stays the same?
Thanks, I'm relatively new to RF
Re: Zelda Style Heart Bar- how to do?
Posted: Thu Jan 24, 2008 12:44 am
by Agentarrow
I don't know much about scripting, but you'd want a second health bar underneath the first that runs out before health does.
uhhh... something like:
Open the player.ini file and go under armor, Replace the Initial with probably about half, so about 50. Next put High as 100 and low as 0. Juutis will have to help with the regenerate thing. You might be better off having it set at something like 200 and replenishable by items