renpy/doc/cookbook/A frame for RPGs
From Ren'Py Visual Novel Engine
RPG frame
This is a frame you can use for your RPG project if you intend to create a hybrid project (renpy+minigames).
It might be a good introduction to style editing and game loops notions.
In the init section
init python: def stats_frame(name, level, hp, maxhp, **properties): ui.frame(xfill=False, yminimum=None, **properties) ui.hbox() # (name, "HP", bar) from (level, hp, maxhp) ui.vbox() # name from ("HP", bar) ui.text(name, size=20) ui.hbox() # "HP" from bar ui.text("HP", size=20) ui.bar(maxhp, hp, xmaximum=150, left_bar=Frame("rrslider_full.png", 12, 0), right_bar=Frame("rrslider_empty.png", 12, 0), thumb=None, thumb_shadow=None) ui.close() ui.close() ui.vbox() # Level from (hp/maxhp) ui.text("Lv. %d" % level, xalign=0.5, size=20) ui.text("%d/%d" % (hp, maxhp), xalign=0.5, size=20) ui.close() ui.close()
In the game script
label start: with None jump fight label fight: python: charmax_HP = 1000 char_HP = 1000 tigermax_HP = 2000 tiger_HP = 2000 while True: while tiger_HP >= 1000: tiger_HP = tiger_HP - 10 stats_frame("Tiger", 4, tiger_HP, tigermax_HP, xalign=0.75, yalign=0.0) stats_frame("Hero", 1, 86, 86, xalign=0.0, yalign=0.0) renpy.pause(0.05) break "Tiger" "Gao gao! You're strong!"
