My very first project was indeed a Mad Libs game, Yaoi Story (R18!). However, you're the very first person to ask me how I did it."...I was wondering in particular about how to create a Mad Lib game. I noted that this was one of your first projects using Ren'Py, and I was curious how you approached the project."
The key to the whole thing is renpy.input.
In script.rpy, somewhere after label start:
Code: Select all
label MadLibs:
$ m1 = renpy.input("Name your hero: \n{i}Backspace to erase this name and type in your choice. \nHit ENTER to go to the next choice.{/i}", "Hero", length=20)
$ m1 = m1.strip()
$ ff = renpy.input("Name a Female Friend for the Hero:", "Female Friend", length=20)
$ ff = ff.strip()
$ home = renpy.input("Name a type of Home:\n{i}Examples: dorm, mansion, house...{/i}:", "apartment", length=20)
$ home = home.strip()
$ dinner = renpy.input("Name a Dinner Course:\n{i}Examples: pizza, roast beef, spagetti & meatballs, lasagne...{/i}", "dinner", length=20)
$ dinner = dinner.strip()
"Hero" is the default name that will appear if nothing is typed in.
length = 20 is how many characters are allowed for that name.
$ m1 = m1.strip() takes off any empty spaces after their input.
It looks like this: This is the adjusted Input code:
In screens.rpy:
Code: Select all
##############################################################################
# Input
screen input:
window:
xalign 0.5
yalign 0.5
has vbox
text prompt:
yoffset 5
style "say_dialogue"
xoffset 50
input:
id "input"
style "say_dialogue"
color "#cc9933"
yoffset 5
xoffset 70
init -2 python:
style.input_text.size = 20
style.input_window.background = Frame("textbox1.png", 0, 0)
style.input_window.left_padding = 80
style.input_window.right_padding = 100
style.input_window.bottom_padding = 20
-- You may need to adjust these numbers to suit your game.
After that, all you need to do is include [m1] in any line, and that word will appear.
Code: Select all
label gamestart:
play nature "sfx/Cityscape.wav" fadeout 1.0
scene bg_street with fade
show Arthur at left with easeinleft
"\n\n\n\nFull night had fallen by the time [m1] headed for [ff]'s [home] for dinner and a movie. She was cooking [dinner], his favorite."
n2 "The End."
hide Arthur with moveoutleft
with Pause (1.0)
return
in script.rpy:
Code: Select all
init:
# Declare characters used by this game.
# ---------- CTC blinking arrow -----------------------
image ctc_blink:
xpos 1020 ypos 763
alpha 1.0
"arrow.png"
0.75
alpha 0
0.75
repeat
define narrator = Character(None,
ctc="ctc_blink",
kind=nvl,)
define n2 = Character(None,
ctc="ctc_blink")
in options.rpy
Code: Select all
#########################################
## TEXT
## The default font:
style.default.font = "DejaVuSans.ttf"
## The default size of text:
style.default.size = 22
## -------Text Alignment ---------------
## text Justified
style.create("justify_style", "default", u"(text) Justify Style")
style.default.justify = True
#########################################
## These settings let you customize the window containing the
## dialogue and narration, by replacing it with an image.
## The background of the window. In a Frame, the two numbers
## are the size of the left/right and top/bottom borders,
## respectively.
###############################################
##-------------- Textbox ----------------------
# style.say_window.font = "bluecabin.ttf"
# style.say_label.size =30
## Frame ------------------------
style.window.background = Frame("ui/textbox1.png", 0, 0)
## No Frame --------------------
# style.window.background = "ui/textbox.png"
## Margin is space surrounding the window, where the background
## is not drawn.
style.window.left_margin = 50
style.window.right_margin = 50
style.window.top_margin = 0
style.window.bottom_margin = 50
## Padding is space inside the window, where the background is
## drawn.
style.window.left_padding = 70
style.window.right_padding = 70
style.window.top_padding = 30
style.window.bottom_padding = 30
## This is the minimum height of the window, including the margins
## and padding.
style.window.yminimum = 201
# --------------NVL Box ----------------------------
# If you want a different Font for your NVL text.
# style.nvl_dialogue.font = "LIBSA1.TTF"
# If you want a different Color for your NVL text.
# style.nvl_dialogue.color = "#ffffcc"
# If you want a different Size for your NVL text.
# style.nvl_dialogue.size =30
style.nvl_dialogue.justify = True
## Interblock spacing: ------------------
style.nvl_vbox.box_spacing = 3
## ----------- Framed NVL box ------------------------
style.nvl_window.background = Frame("ui/textbox2.png", 0, 0)
## ---------- No Frame Nvl Box--------------------
# style.nvl_window.background = "ui/NVLbox02.png"
# margins ---------------------------------
style.nvl_window.top_margin = 0
style.nvl_window.bottom_margin = 0
style.nvl_window.left_margin = 0
style.nvl_window.right_margin = 0
# padding ---------------------------------
style.nvl_window.top_padding = 30
style.nvl_window.bottom_padding = 0
style.nvl_window.left_padding = 550
style.nvl_window.right_padding = 30
# menu = nvl_menu
config.window_hide_transition = dissolve
config.window_show_transition = dissolve
# config.empty_window = nvl_show_core
config.nvl_paged_rollback = True
style.nvl_vbox.box_spacing = 10
-- You may need to adjust these numbers to suit your game.
The rest is up to you and your creativity.
Sample game: None of the files are archived, so feel free to pick it apart and make with it what you like.