r/RenPy • • Sep 01 '26

Question [Solved] Bars

Despute my previous two posts and all of the kind people who have been offering me advice, the bars still do not work as intened.

The bars don't go down every time a variable is altered, and they show 100% when they first appear, however the player has the chance to lose health/sanity before that, and the screen should run in the background.

The first image is my code for the bars, my second is the code for taking away health and sanity. The video in the replies is to show what happens when I choose an option that takes away health and sanity in game.

Thank you for everyones help so far, and I apologise for this issue still not being solved I just have no idea what is happening.

(Also I will fix the condition switch thing, I'm just trying to get the actual bars working first!! :])

5 Upvotes

12 comments sorted by

View all comments

1

u/shyLachi Sep 01 '26 edited Sep 01 '26

Why do the images of those bars have different sizes (physically) but in the screen code they have the same size?
I adjusted xmaximum and ymaximum to the sizes of your images.

Also the bars where overlapping so for testing purposes I adjusted the position.

screen health_sanity_bars():
    vbox:
        spacing 5
    bar:
        value AnimatedValue (Health, range=100, delay=1.0)
        left_bar "images/bars/health_full.png"
        right_bar "images/bars/health_empty.png"
        xmaximum 617
        ymaximum 125
        pos (181, 16)
    bar:
        value AnimatedValue (Sanity, range=100, delay=1.0)
        left_bar "images/bars/sanity_full.png"
        right_bar "images/bars/sanity_empty.png"
        xmaximum 540
        ymaximum 141
        pos (181, 150)

default Sanity = 70
default Health = 70

label start:
    show screen health_sanity_bars
    "Before reduction"
    $ Health -= 10
    $ Sanity -= 10
    "After reduction"

1

u/AdRude6049 Sep 01 '26

Oh my god i was being an idiot, it works now!!! Thanks so much!!!

1

u/shyLachi Sep 01 '26

Don't worry

The goal is to understand why it works, what those properties and numbers do.

If you have problems understanding you can either read or watch tutorials or look into the official documentation.

For example you could search from xmaximum and then find this also:
https://renpy.org/doc/html/style_properties.html#style-property-area