(Solved) Questions on how to implement HP/MP Bars

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
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.
Post Reply
Message
Author
10kNing
Regular
Posts: 51
Joined: Fri Apr 29, 2011 9:37 pm
Projects: Revenance (RPG), Mad-Love (GxB, on hold)
Location: NYC
Contact:

(Solved) Questions on how to implement HP/MP Bars

#1 Post by 10kNing »

I'm trying to show the HP and MP of each of the characters in the corner of the screen, like this, but I don't understand how the interface in the tutorial works, so I'm a bit hesitant to edit it. How do you edit the color of the bar, how do you place one bar below another in the same box, and how is it that you assign variable to them? Thank you in advance!
Last edited by 10kNing on Tue Jun 28, 2011 11:02 am, edited 1 time in total.

User avatar
Showsni
Miko-Class Veteran
Posts: 563
Joined: Tue Jul 24, 2007 12:58 pm
Contact:

Re: Questions on how to implement HP/MP Bars

#2 Post by Showsni »

It's best to use screen language. Let's say you have a variable for each character's current and max HP and MP; say, currenthp, maxhp, currentmp, maxmp. A simple screen to show this could look like this:

Code: Select all

    screen hpbars:
        frame:
            xalign 1.0
            yalign 0.0
            hbox: 
                vbox: 
                    hbox:
                        text "HP" size 20
                        bar value currenthp range maxhp xmaximum 200
                    hbox:
                        text "SP" size 20
                        bar value currentmp range maxmp xmaximum 200
                vbox:
                    text ("%d/%d" % (currenthp, maxhp)) xalign 0.5 size 20
                    text ("%d/%d" % (currentmp, maxmp)) xalign 0.5 size 20
Place that code somewhere, then use show screen hpbars and hide screen hpbars to show and hide it. The bars will update when the variables change. You can change it how you like; for instance, make the text say different things, add a line of text that shows the character's name, etc. The xaligna nd yalign show where on the screen it will be positioned; the xmaximum values show how long the bar will be on the screen. Make it longer for more detail...

To change the colour, I guess it would have something to do with the bar style... Or change the colours your theme uses in the options.rpy...
Last edited by Showsni on Tue Jun 28, 2011 2:56 pm, edited 1 time in total.

10kNing
Regular
Posts: 51
Joined: Fri Apr 29, 2011 9:37 pm
Projects: Revenance (RPG), Mad-Love (GxB, on hold)
Location: NYC
Contact:

Re: (Solved) Questions on how to implement HP/MP Bars

#3 Post by 10kNing »

Thank you!

Post Reply

Who is online

Users browsing this forum: No registered users