Sure!Zalkyria wrote:I am stumped as to how to add in a love meter to my game. Can you please help me?
-- First of all, you'll need some Graphics. -- WARNING: The code listed is for a 1024x768 game. If you're using a different size, adjustments WILL be necessary.
-- Also! The Blank Spaces; the indentation at the beginning of each line, is very important! Make sure you leave them intact!!!
To use those bar graphics in the Love Meter, add this code to your script.rpy file, at the very top, or at the bottom of your options.rpy page:
Code: Select all
init -5 python:
#custom bar -----------------------
style.my_bar = Style(style.default)
style.my_bar.xalign = 0.5
style.my_bar.xmaximum = 315 # bar width
style.my_bar.ymaximum = 30 # bar height
style.my_bar.left_gutter = 5
style.my_bar.right_gutter = 5
# I have all my User Interface graphics stored in one file called ui.
# To access them in my code, I put ui/ in front of all images in that file.
style.my_bar.left_bar = Frame("ui/bar_full.png", 0, 0)
style.my_bar.right_bar = Frame("ui/bar_empty.png", 0, 0)
style.my_bar.hover_left_bar = Frame("ui/bar_hover.png", 0, 0)
style.my_bar.thumb = "ui/thumb.png"
style.my_bar.thumb_shadow = None
style.my_bar.thumb_offset = 5
Code: Select all
init -2 python:
## Character Giselle --------------
giselle_love = 10 #The number of points she Starts with.
max_love = 150 #The maximum points she can get.
init python:
## ------------ Love Points Activation Code-------------------
#This controls when the love-points floater appears.
show_giselle=False
## ------------ Love Points Floating Meter --------------------
def stats_overlay():
# --- Giselle's Love Bar -------
if show_giselle:
ui.frame(
xalign = 0.5, #centered
ypos = 400,) #400 px Down from the Top
ui.vbox(xalign = 0.5)
ui.text ("Giselle's Love Points: %d" %giselle_love,
xalign = 0.5)
ui.bar(max_love, giselle_love,
style="my_bar")
ui.close()
config.overlay_functions.append(stats_overlay)
Code: Select all
$ show_giselle=True
# This makes the Meter appear.
pause 0.5
# This makes the meter sit there for half a second, so that when the points
# are added, the player can actually 'see' the meter extend.
$ giselle_love+=50
#This adds points to the meter.
show expression Text("{color=ffffff}{font=LHFmisterkookyREG_0.TTF}+50 Love Points{/font}{/color}",
size=50,
yalign=0.5, # Centers the text -- Toward Bottom.
xalign=0.5, # Centers the text -- Toward Right.
drop_shadow=(2, 2)) as text
with dissolve
# This is the Announcement Text for the Love Meter, including a specific font, and font color.
# This states how many points Giselle is being awarded.
# Note the FONT! If you use this code without replacing the font Name with one In Your Game,
# you will get an error message.
$ show_giselle=True
# This is a Refresh that shows the increase in points ON the meter.
$ renpy.pause()
#This keeps the bar visible until the player hits a key.
hide text with dissolve
# This hides the Text.
$ show_giselle=False
# This hides the Meter.
LoveMeter.rpy:
Code: Select all
init python:
#This controls when the love-points floater appears.
show_giselle=False
show_arthur=False
show_shino=False
## ------------ Love Points Floater ----------------------
def stats_overlay():
# --- Giselle's Love Bar -------
if show_giselle:
ui.frame(
xalign = 0.5, #centered
ypos = 400,) #400 px Down from the Top
ui.vbox(xalign = 0.5)
ui.text ("Giselle's Love Points: %d" %giselle_love,
xalign = 0.5)
ui.bar(max_love, giselle_love,
style="my_bar")
ui.close()
# --- Arthur's Love Bar -------
if show_arthur:
ui.frame(
xalign = 0.5,
ypos = 400,)
ui.vbox()
ui.text ("Arthur's Love Points: %d" %arthur_love,
xalign = 0.5)
ui.bar(max_love, arthur_love,
style="my_bar")
ui.close()
# --- Shino's Love Bar -------
if show_shino:
ui.frame(
xalign = 0.5,
ypos = 400,)
ui.vbox()
ui.text ("Shino's Love Points: %d" %shino_love,
xalign = 0.5)
ui.bar(max_love, shino_love,
style="my_bar")
ui.close()
config.overlay_functions.append(stats_overlay)
init -2 python:
giselle_love=10
max_love = 150
arthur_love=10
max_love = 150
shino_love =10
max_love = 150
init -5 python:
#custom bar
style.my_bar = Style(style.default)
style.my_bar.xalign = 0.5
style.my_bar.xmaximum = 315 # bar width
style.my_bar.ymaximum = 30 # bar height
style.my_bar.left_gutter = 5
style.my_bar.right_gutter = 5
# I have all my User Interface graphics stored in one file called ui.
# To access them in my code, I put ui/ in front of all images in that file.
style.my_bar.left_bar = Frame("ui/bar_full.png", 0, 0)
style.my_bar.right_bar = Frame("ui/bar_empty.png", 0, 0)
style.my_bar.hover_left_bar = Frame("ui/bar_hover.png", 0, 0)
style.my_bar.thumb = "ui/thumb.png"
style.my_bar.thumb_shadow = None
style.my_bar.thumb_offset = 5