I want to make a health-bar/life system [Solved]
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
- beastcarving
- Regular
- Posts: 139
- Joined: Mon May 13, 2019 5:03 pm
- Completed: Pulse Cage https://beastcarving.itch.io/pulse-cage-the-full-series
- Projects: Your Brother's Religion
- Organization: BeastCarving Studio
- IRC Nick: BeastCarving
- Tumblr: beastcarving
- Deviantart: beastcarving
- Github: beastcarving
- itch: beastcarving
- Contact:
I want to make a health-bar/life system [Solved]
I want to know how to add a health bar type of thing that will lower every time a certain choice is maybe. (The bar would be animated through frames when lowered)I would like this to be a part of the quick menu that you can keep checking up on as you play. I want people to be surprised when it changes, not knowing what choice maybe the health bar lower, so the player has to keep checking up on it when they are curious of it being affected throughout the game. It might be impossible to make, but I would love if one of you geniuses could help me out.
Last edited by beastcarving on Tue May 28, 2019 5:51 am, edited 1 time in total.
Pulse Cage (full game) Your Brother's Religion (Demo)
PLAY HERE: https://beastcarving.itch.io/
Love my work: https://www.patreon.com/beastcarving
PLAY HERE: https://beastcarving.itch.io/
Love my work: https://www.patreon.com/beastcarving
- beastcarving
- Regular
- Posts: 139
- Joined: Mon May 13, 2019 5:03 pm
- Completed: Pulse Cage https://beastcarving.itch.io/pulse-cage-the-full-series
- Projects: Your Brother's Religion
- Organization: BeastCarving Studio
- IRC Nick: BeastCarving
- Tumblr: beastcarving
- Deviantart: beastcarving
- Github: beastcarving
- itch: beastcarving
- Contact:
Re: I want to make a health-bar/life system [HELP]
BTW I don't use GUI
Pulse Cage (full game) Your Brother's Religion (Demo)
PLAY HERE: https://beastcarving.itch.io/
Love my work: https://www.patreon.com/beastcarving
PLAY HERE: https://beastcarving.itch.io/
Love my work: https://www.patreon.com/beastcarving
Re: I want to make a health-bar/life system [HELP]
Code: Select all
init:
$ health = 100 # set the amount of health
screen healthbar:
# if you replace vbar with bar,
# that indicator will become horizontal
vbar value StaticValue (health, 100): # maximum - 100 hp
align (.05, .05) # position on the screen
xmaximum 200 sizes
ymaximum 200
left_bar "heartempty.png" # empty heart
right_bar "heart.png" # full heart
thumb None # here you can put a separator
thumb_shadow None # and shadow
label start:
show screen healthbar # display heart on screen
pause # wait for a click and start the demonstration
while health> 0: # while health is greater than 0
$ health - = 1 # decrease it by one
pause .01 # short pause
pause
return
And viewtopic.php?f=51&t=22147
Renpy textbook (in Russian). https://disk.yandex.ru/i/httNEajU7iFWHA (all information is out of date) Update 22.06.18
Sawa - a game of the Drow Nation
Honest Critique
Poses in visual novels, or how to hold a character properly in the frame
Help save articles to the webarchive. [/color]
Sawa - a game of the Drow Nation
Honest Critique
Poses in visual novels, or how to hold a character properly in the frame
Help save articles to the webarchive. [/color]
- beastcarving
- Regular
- Posts: 139
- Joined: Mon May 13, 2019 5:03 pm
- Completed: Pulse Cage https://beastcarving.itch.io/pulse-cage-the-full-series
- Projects: Your Brother's Religion
- Organization: BeastCarving Studio
- IRC Nick: BeastCarving
- Tumblr: beastcarving
- Deviantart: beastcarving
- Github: beastcarving
- itch: beastcarving
- Contact:
Re: I want to make a health-bar/life system [HELP]
Thanks for the response. It's not exactly what I wanted. I wanted the "love meter" to be accessed through the quick menu instead of displayed on the screen whenever it's affected. What I want is way too complex, so I'll probably just take this function in my game out if no one can figure it out.
Pulse Cage (full game) Your Brother's Religion (Demo)
PLAY HERE: https://beastcarving.itch.io/
Love my work: https://www.patreon.com/beastcarving
PLAY HERE: https://beastcarving.itch.io/
Love my work: https://www.patreon.com/beastcarving
- trooper6
- Lemma-Class Veteran
- Posts: 3712
- Joined: Sat Jul 09, 2011 10:33 pm
- Projects: A Close Shave
- Location: Medford, MA
- Contact:
Re: I want to make a health-bar/life system [HELP]
It isn't that complex. You just add a button to your quickmenu that brings up the love meter screen.
A Close Shave:
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?) Check out My Clock Cookbook Recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=21978
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?) Check out My Clock Cookbook Recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=21978
- beastcarving
- Regular
- Posts: 139
- Joined: Mon May 13, 2019 5:03 pm
- Completed: Pulse Cage https://beastcarving.itch.io/pulse-cage-the-full-series
- Projects: Your Brother's Religion
- Organization: BeastCarving Studio
- IRC Nick: BeastCarving
- Tumblr: beastcarving
- Deviantart: beastcarving
- Github: beastcarving
- itch: beastcarving
- Contact:
Re: I want to make a health-bar/life system [HELP]
I've connected it to the quick menu, but now the love meter is not working anymore. I really need help with this. I'd be grateful to anyone that could provide me with a solution.
Pulse Cage (full game) Your Brother's Religion (Demo)
PLAY HERE: https://beastcarving.itch.io/
Love my work: https://www.patreon.com/beastcarving
PLAY HERE: https://beastcarving.itch.io/
Love my work: https://www.patreon.com/beastcarving
- trooper6
- Lemma-Class Veteran
- Posts: 3712
- Joined: Sat Jul 09, 2011 10:33 pm
- Projects: A Close Shave
- Location: Medford, MA
- Contact:
Re: I want to make a health-bar/life system [HELP]
Provide your code, so we can see if there is some sort of error in it.
A Close Shave:
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?) Check out My Clock Cookbook Recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=21978
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?) Check out My Clock Cookbook Recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=21978
- beastcarving
- Regular
- Posts: 139
- Joined: Mon May 13, 2019 5:03 pm
- Completed: Pulse Cage https://beastcarving.itch.io/pulse-cage-the-full-series
- Projects: Your Brother's Religion
- Organization: BeastCarving Studio
- IRC Nick: BeastCarving
- Tumblr: beastcarving
- Deviantart: beastcarving
- Github: beastcarving
- itch: beastcarving
- Contact:
Re: I want to make a health-bar/life system [HELP]
I put this in the Screen page
I added this one to the Script page
Code: Select all
screen aura:
tag menu
#use navigation
imagemap:
ground "pick.png"
idle "ybr aura align 100.png"
hover "ybr aura align 90.png"
cache False
hotspot (105, 27, 218, 69) action Return()
hotspot (478, 187, 450, 434) action ShowMenu("Pure")
Code: Select all
init:
$ health = 100 # set the amount of health
screen Pure:
# if you replace vbar with bar,
# that indicator will become horizontal
vbar value StaticValue (health, 100): # maximum - 100 hp
align (.05, .05) # position on the screen
xmaximum 1400 #sizes
ymaximum 800
left_bar "ybr aura align.png"#("image.png", 0, 0) # empty heart
right_bar "ybr aura align 60.png" # full heart
thumb None # here you can put a separator
thumb_shadow None # and shadow
#show screen Pure # display heart on screen
pause # wait for a click and start the demonstration
while health> 0: # while health is greater than 0
$ health -=1 # decrease it by one
pause .01 # short pause
pause
#return
hide screen Pure
hide pick with dissolve
Pulse Cage (full game) Your Brother's Religion (Demo)
PLAY HERE: https://beastcarving.itch.io/
Love my work: https://www.patreon.com/beastcarving
PLAY HERE: https://beastcarving.itch.io/
Love my work: https://www.patreon.com/beastcarving
- trooper6
- Lemma-Class Veteran
- Posts: 3712
- Joined: Sat Jul 09, 2011 10:33 pm
- Projects: A Close Shave
- Location: Medford, MA
- Contact:
Re: I want to make a health-bar/life system [HELP]
Try something a bit more like this:
Go to your screens.rpy file. Find the Quickmenu. Add a button that will bring up your health screen.
Then create your health screen and your variables...I put this at the top of the script.rpy file, but it could in the screens.rpy file...wherever:
Then, in the game itself you can do something like:
Go to your screens.rpy file. Find the Quickmenu. Add a button that will bring up your health screen.
Code: Select all
screen quick_menu():
## Ensure this appears on top of other screens.
zorder 100
if quick_menu:
hbox:
style_prefix "quick"
xalign 0.5
yalign 1.0
textbutton _("Back") action Rollback()
textbutton _("History") action ShowMenu('history')
textbutton _("Skip") action Skip() alternate Skip(fast=True, confirm=True)
textbutton _("Auto") action Preference("auto-forward", "toggle")
textbutton _("Save") action ShowMenu('save')
textbutton _("Q.Save") action QuickSave()
textbutton _("Q.Load") action QuickLoad()
textbutton _("Prefs") action ShowMenu('preferences')
textbutton ("Health") action ToggleScreen('healthscreen')
Code: Select all
default health = 100
default max_health = 100
screen healthscreen():
frame:
align (0.05, 0.05)
xmaximum 300
bar value AnimatedValue(value=health, range=max_health, delay=2.0)
Code: Select all
label start():
"So the game has started."
"If you are interested you can click the 'Health' button in the quickmenu and pull up the health bar."
$health -= 10
"Did you just see the value decrease?"
"Anyhow, you can also click on 'Health' again, anytime you want, to make the health bar disappear again."
$health -= 10
"So if you do not want the game and bar visible at the same time, there are ways to adjust the code...but this is just the basics here."
A Close Shave:
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?) Check out My Clock Cookbook Recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=21978
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?) Check out My Clock Cookbook Recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=21978
- beastcarving
- Regular
- Posts: 139
- Joined: Mon May 13, 2019 5:03 pm
- Completed: Pulse Cage https://beastcarving.itch.io/pulse-cage-the-full-series
- Projects: Your Brother's Religion
- Organization: BeastCarving Studio
- IRC Nick: BeastCarving
- Tumblr: beastcarving
- Deviantart: beastcarving
- Github: beastcarving
- itch: beastcarving
- Contact:
Re: I want to make a health-bar/life system [HELP]
Thank you so much! It worked! That's exactly what I wanted it to do. You are amazing! I was also wondering if I could customize the health bar with an animation when it lowers. This bar will lower and change in appearance, becoming eerier in design as it empty. I made two health bars, and I want to know if I could also do it that way. Thanks.
Pulse Cage (full game) Your Brother's Religion (Demo)
PLAY HERE: https://beastcarving.itch.io/
Love my work: https://www.patreon.com/beastcarving
PLAY HERE: https://beastcarving.itch.io/
Love my work: https://www.patreon.com/beastcarving
Re: I want to make a health-bar/life system [HELP]
In this case you can use a simple ConditionSwitch instead of bar - viewtopic.php?f=51&t=19063
- beastcarving
- Regular
- Posts: 139
- Joined: Mon May 13, 2019 5:03 pm
- Completed: Pulse Cage https://beastcarving.itch.io/pulse-cage-the-full-series
- Projects: Your Brother's Religion
- Organization: BeastCarving Studio
- IRC Nick: BeastCarving
- Tumblr: beastcarving
- Deviantart: beastcarving
- Github: beastcarving
- itch: beastcarving
- Contact:
Re: I want to make a health-bar/life system [HELP]
I'm having issues connecting the Condition-switch to my quick menu. I want my Condition-switch to only be accessible through my quick menu the same as my love meter. Please help.
Pulse Cage (full game) Your Brother's Religion (Demo)
PLAY HERE: https://beastcarving.itch.io/
Love my work: https://www.patreon.com/beastcarving
PLAY HERE: https://beastcarving.itch.io/
Love my work: https://www.patreon.com/beastcarving
Re: I want to make a health-bar/life system [HELP]
Well, the only thing you need to do is replace
in your healthscreen screen with the ConditionSwitch, that changes image depending of health variable. You don't need to change other things you've already done to make a button to show/hide healthscreen screen from quick_menu.
Try
https://www.renpy.org/doc/html/screens.html#add
Code: Select all
bar value AnimatedValue(value=health, range=max_health, delay=2.0)
Try
Code: Select all
image health_meter = ConditionSwitch (
"health < 10","health_low.png",
"health < 50","health_half.png",
"True", "health_full.png"
)
screen healthscreen():
frame:
align (0.05, 0.05)
xmaximum 300
add "health_meter"
- beastcarving
- Regular
- Posts: 139
- Joined: Mon May 13, 2019 5:03 pm
- Completed: Pulse Cage https://beastcarving.itch.io/pulse-cage-the-full-series
- Projects: Your Brother's Religion
- Organization: BeastCarving Studio
- IRC Nick: BeastCarving
- Tumblr: beastcarving
- Deviantart: beastcarving
- Github: beastcarving
- itch: beastcarving
- Contact:
Re: I want to make a health-bar/life system [HELP]
Both love meters are working well. I'm grateful to all of you that helped. Thanks!
Pulse Cage (full game) Your Brother's Religion (Demo)
PLAY HERE: https://beastcarving.itch.io/
Love my work: https://www.patreon.com/beastcarving
PLAY HERE: https://beastcarving.itch.io/
Love my work: https://www.patreon.com/beastcarving
Who is online
Users browsing this forum: No registered users