 |
Castle Paradox
|
View previous topic :: View next topic |
Author |
Message |
Baconlabs PURPLE IS MANLY

Joined: 15 Mar 2009 Posts: 335 Location: Tennessee
|
Posted: Fri Jul 03, 2009 11:25 am Post subject: Want to make a rectanglar HUD |
|
|
I have a feeling already that this will require slices.
Anyway, for my game Viridia, there is a prominent "dehydration" effect, which is based primarily off of Pepsi Ranger's script by the same name. To summarize, in certain areas, walking dehydrates you, depleting the variable H. When H is gone, you lose HP until you die.
At the moment I'm making due with "show value(H)", but I'd like to have a long, blue, rectangular METER at the top of the screen that shrinks when H goes down - possibly changing to a red rectangle representing HP later.
So, gentlemen, how can I make this happen? |
|
Back to top |
|
 |
Bob the Hamster OHRRPGCE Developer

Joined: 22 Feb 2003 Posts: 2526 Location: Hamster Republic (Southern California Enclave)
|
Posted: Fri Jul 03, 2009 1:07 pm Post subject: |
|
|
If you look at the plotscripts for Crypt of Baconthulhu, you will find some scripts that handle the HP meter and the stamina meter.
Basically you want two rectangle slices.
The first rectangle slice represents the maximums size of the meter.
The second rectangle slice will be parented to the first slice, and you will change its size to reflect the hydration value. |
|
Back to top |
|
 |
Moogle1 Scourge of the Seas Halloween 2006 Creativity Winner


Joined: 15 Jul 2004 Posts: 3377 Location: Seattle, WA
|
Posted: Fri Jul 03, 2009 3:08 pm Post subject: Re: Want to make a rectanglar HUD |
|
|
Baconlabs wrote: | So, gentlemen, how can I make this happen? |
I have nothing of value to add to this topic now that James has given you the answer except to say that you might want another black rectangle behind your gauge to show the maximum possible value.
Oh, you know what would be classy? Making it a vertical bar instead of horizontal. _________________
|
|
Back to top |
|
 |
TMC On the Verge of Insanity
Joined: 05 Apr 2003 Posts: 3240 Location: Matakana
|
Posted: Fri Jul 03, 2009 7:17 pm Post subject: Re: Want to make a rectanglar HUD |
|
|
Moogle1 wrote: | I have nothing of value to add to this topic now that James has given you the answer except to say that you might want another black rectangle behind your gauge to show the maximum possible value. |
Except he already said that too!
Are you looking for general help on slices? Baconthulhu should be a good example, just make sure to ignore everything else in there!
There's also some help here, if you want more: 'Plotslices Tutorial' _________________ "It is so great it is insanely great." |
|
Back to top |
|
 |
Moogle1 Scourge of the Seas Halloween 2006 Creativity Winner


Joined: 15 Jul 2004 Posts: 3377 Location: Seattle, WA
|
Posted: Fri Jul 03, 2009 8:25 pm Post subject: |
|
|
Oh, right.
Well, I did say I had nothing useful to add. _________________
|
|
Back to top |
|
 |
Baconlabs PURPLE IS MANLY

Joined: 15 Mar 2009 Posts: 335 Location: Tennessee
|
Posted: Thu Jul 09, 2009 12:52 am Post subject: |
|
|
Very nice, I've gotten the main effect I was going for: A long bar that decreases by one pixel for each step you take, representing hydration levels. The visual effect is different (and better) compared to the old counter.
I've run into a few problems though.
1) A copy of the first slice (the bottom bar that represents Max Hydration) appears at screen point (0,0) while the main one remains at (10,10). FIXED
2) The aforementioned slices linger when the Health slice appears.
3) When the Health slice shrinks, it leaves a "trail" of the previous length. FIXED
Part of the problem may be that I am only using one variable for all slices. I don't know, it's late, I'll double-check everything tomorrow.
Last edited by Baconlabs on Thu Jul 09, 2009 3:58 pm; edited 1 time in total |
|
Back to top |
|
 |
TMC On the Verge of Insanity
Joined: 05 Apr 2003 Posts: 3240 Location: Matakana
|
Posted: Thu Jul 09, 2009 1:14 am Post subject: |
|
|
Baconlabs wrote: | Very nice, I've gotten the main effect I was going for: A long bar that decreases by one pixel for each step you take, representing hydration levels. The visual effect is different (and better) compared to the old counter.
I've run into a few problems though.
1) A copy of the first slice (the bottom bar that represents Max Hydration) appears at screen point (0,0) while the main one remains at (10,10).
2) The aforementioned slices linger when the Health slice appears.
3) When the Health slice shrinks, it leaves a "trail" of the previous length. |
I think that you'd better post your scripts.
Quote: | Part of the problem may be that I am only using one variable for all slices. |
It's not necessary to store each slice handle in a variable, but if you want to manipulate a slice, you obviously need to have some way of getting its handle. If you're not going to manipulate them, you can set them as children of some other slice and then delete them all at once by freeing the parent. _________________ "It is so great it is insanely great." |
|
Back to top |
|
 |
Bob the Hamster OHRRPGCE Developer

Joined: 22 Feb 2003 Posts: 2526 Location: Hamster Republic (Southern California Enclave)
|
Posted: Thu Jul 09, 2009 7:43 am Post subject: |
|
|
Baconlabs wrote: |
I've run into a few problems though.
1) A copy of the first slice (the bottom bar that represents Max Hydration) appears at screen point (0,0) while the main one remains at (10,10).
2) The aforementioned slices linger when the Health slice appears.
3) When the Health slice shrinks, it leaves a "trail" of the previous length. |
I have a hunch that you are re-creating new slices over and over. That would explain the "trail"... but to be sure, it would help to see your source code. |
|
Back to top |
|
 |
Baconlabs PURPLE IS MANLY

Joined: 15 Mar 2009 Posts: 335 Location: Tennessee
|
Posted: Thu Jul 09, 2009 3:34 pm Post subject: |
|
|
Here the code is.
FOREWORD: Yes, I accidentally made the global variable "H-twenty" instead of "H-two-oh."
A lot was taken from Pepsi Ranger's same-name script and the Plotslices tutorial.
Code: | global variable (2,H20)
plotscript,Dehydration,begin
#the hero's current hydration level is "H20", a global variable
variable (mx) #the hero's max HP
variable (m) #the hero's current HP
variable (h) #the hero's new HP stat
variable (sl) #The slice variable
#the first section of the script slowly eats away at the hero's H20 level
if (H20>>0)
then,begin(
reset palette
update palette
set variable (H20,H20--1)
if (check tag(tag:pryo)==ON) then,begin
sl := create rect(150,10,13) #Each hero has a different Max Hydration level, which is the bottom slice here. 150 for Ryo...
end
if (check tag(tag:ppayton)==ON) then,begin
sl := create rect(210,10,13) #And 210 for Payton.
end
set slice screen x(sl,10)
set slice screen y(sl,10)
sl := create rect((H20),10,1) #The top slice, the current Hydration level, is as long as the variable in pixels.
set slice screen x(sl,10)
set slice screen y(sl,10)
)
end
#the second section slowly decreases his physical health.
else,begin(
if (H20<=0) #if the hero doesn't have anymore H20...
then,begin( #then it's time for him to lose some health.
set variable (H20,0)
tweak palette (7,1,0)
update palette
set variable (m,get hero stat (me,stat:Stamina,current stat))
set variable (mx,get hero stat (me,stat:Stamina,maximum stat))
set variable (h,m--2)
set hero stat (0,stat:Stamina,h,current stat)
sl := create rect((mx),10,14) #The bottom Health slice is as long as the hero's max HP.
set slice screen x(sl,10)
set slice screen y(sl,10)
sl := create rect((h),10,2) #The top Health slice is as long as the hero's current HP.
set slice screen x(sl,10)
set slice screen y(sl,10)
if (h<=0)
then,begin( #YOUR JAMES OVER
game over
)
end
)
end
)
end
end |
EDIT: Someone mentioned a "handle." Please elaborate.
EDIT2: VERY IMPORTANT
The above code has been edited, and most of the aforementioned problems have been fixed. Here is the last remaining problem:
The bottom Hydration slice lingers when the Health slices appear. I need to get rid of it. |
|
Back to top |
|
 |
Baconlabs PURPLE IS MANLY

Joined: 15 Mar 2009 Posts: 335 Location: Tennessee
|
Posted: Fri Jul 24, 2009 12:15 pm Post subject: |
|
|
Bumping this topic.
As I said above, I need to know how to get rid of old slices.
In particular, I'll need this for other scripts so as to get rid of the HUD when it's no longer necessary. |
|
Back to top |
|
 |
Bob the Hamster OHRRPGCE Developer

Joined: 22 Feb 2003 Posts: 2526 Location: Hamster Republic (Southern California Enclave)
|
Posted: Mon Jul 27, 2009 7:40 am Post subject: |
|
|
Baconlabs wrote: | Bumping this topic.
As I said above, I need to know how to get rid of old slices.
In particular, I'll need this for other scripts so as to get rid of the HUD when it's no longer necessary. |
Okay, the problem is that you are creating new rectangle slices every single time the Dehydration script is run. They pile up on top of each other.
Instead of using the sl local variable, you need to store your slice handles in a global variable.
Code: |
global variable(1234, HUD)
|
then you will make a new script that just gets called once to create the HUD
Code: |
script, create hud, begin
if (check tag(tag:pryo)==ON) then,begin
HUD := create rect(150,10,13) #Each hero has a different Max Hydration level, which is the bottom slice here. 150 for Ryo...
end
if (check tag(tag:ppayton)==ON) then,begin
HUD := create rect(210,10,13) #And 210 for Payton.
end end
|
then in your dehydration script you will manipulate the rectangle using the global handle. You will not create new ones with "create rectangle".
Then you have a script that removes the HUD, which is only run once when you are done.
Code: |
script, remove hud, begin
free slice(HUD)
end
|
Does that make sense? |
|
Back to top |
|
 |
Baconlabs PURPLE IS MANLY

Joined: 15 Mar 2009 Posts: 335 Location: Tennessee
|
Posted: Wed Jul 29, 2009 6:51 pm Post subject: |
|
|
Thanks James, I've adjusted the code so that slice creation/destruction occurs in a distinct script, not an Each-Step script.
The HUD has now undergone a few changes.
First, I've decided to display both the Hydration and Health meters at the same time, which makes things a bit simpler.
Second, I've eliminated the underlying slices representing Maximum Hydration/Health, because it changes when you switch the lead hero and I haven't gotten around to implementing this changeability in the script. |
|
Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|