Health screen with Transform properties I think

A place for Ren'Py tutorials and reusable Ren'Py code.
Forum rules
Do not post questions here!

This forum is for example code you want to show other people. Ren'Py questions should be asked in the Ren'Py Questions and Announcements forum.
Post Reply
Message
Author
mrf_22
Newbie
Posts: 1
Joined: Sat May 28, 2022 4:29 pm
Contact:

Health screen with Transform properties I think

#1 Post by mrf_22 »

I just figured out how to make a screen that has that has the player's and enemies health on it so here it is (along with the variables so that the stats are displayed).

Code: Select all


# Flags.

default cur_health = 85
default max_health = 85

default cur_energy = 120
default max_energy = 120

default cur_speed = 10
default max_speed = 10

default cur_strength = 55
default max_strength = 55


default gen_cur_health = 60
default gen_max_health = 60

default gen_cur_energy = 80
default gen_max_energy = 80

default gen_cur_speed = 25
default gen_max_speed = 25

default gen_cur_strength = 20
default gen_max_strength = 20

#-----

# Battle screens here.

screen battle_and_health(): #This is an example of having 2 frames inside 1 screen.
    frame at up_and_down:
        # 
        grid 2 4:
            # spacing 0
            text "HEALTH"
            textbutton _("[cur_health]/[max_health]"):
                action NullAction()

            text "ENERGY"
            textbutton _("[cur_energy]/[max_energy]"):
                action NullAction()

            text "SPEED"
            textbutton _("[cur_speed]/[max_speed]"):
                action NullAction()

            text "STRENGTH"
            textbutton _("[cur_strength]/[max_strength]"):
                action NullAction()

    frame at up_and_down2: # This is gen's health screen.
        xalign 1.0
        grid 2 4:
            # spacing 0
            text "HEALTH"
            textbutton _("[gen_cur_health]/[gen_max_health]"):
                action NullAction()

            text "ENERGY"
            textbutton _("[gen_cur_energy]/[gen_max_energy]"):
                action NullAction()

            text "SPEED"
            textbutton _("[gen_cur_speed]/[gen_max_speed]"):
                action NullAction()

            text "STRENGTH"
            textbutton _("[gen_cur_strength]/[gen_max_strength]"):
                action NullAction()
                
#-----

# Transforms

transform up_and_down: # This is for you, the player's health screen.
    ypos 10
    linear 0.8 ypos 5
    linear 0.8 ypos 10
transform up_and_down2: # This is for gen's, the enemy, health screen.
    ypos 10
    linear 0.8 ypos 5
    linear 0.8 ypos 10
    repeat
So if you wanted to call/show the health screen (the transform script is already coded with the screen itself), you would do:

Code: Select all


label start: #-- I fixed it so that it's just start.
    show screen battle_and_health
    "Generic Enemy" "Wow."
    "Generic Enemy "Let's fight!"
    return
    
Hopefully somebody else can find use from this as well. :D

Post Reply

Who is online

Users browsing this forum: No registered users