Renpy Basics

Download as pdf or txt
Download as pdf or txt
You are on page 1of 36

create your own visual novel

Ren'Py is a visual novel engine that helps you use


words, images, and sounds to tell stories with the
computer. These can be both visual novels and life
simulation games.

http://www.youtube.com/watch?v=YZ1Kwu0kGMc

Go to the folder renpy-6.12.1

and click the RenPy icon.


Choose New Project.
Choose your folder.
Choose "template".
Choose a color theme
(dont worry, you can
change it later)

Click on Edit Script

Your script and images

should all be in the same


folder as your script. To
see where your script is
saved, click on File, Save
As and look at the Path.

Instead of functions, we have labels in RenPy.

You still need to indent.

Ex.
label start :
First msg
Second msg

Start by deleting everything in the script editor

When entering text, remember to encapsulate it in

double quotes. If you want double quotes to appear in


the visual novel, you should put a forward slash before
each one.
Hi, \The Phantom of the Artemis\ will be displayed
as:
Hi The Phantom of the Artemis

Go to RenPy

and click
Launch to
see what your
game looks
like! (click to
make the
game go
forward)

You dont want you keeps typing the name of the

character (in our example, Me) whenever they speak.


You can also choose a color for the name.
BEFORE label start, you can define characters like
this:

define m = Character(me, color = #c8ffc8)


label start:
m blah blah haha

Define a character for Me and Durrah and place


them at their respective locations (use m and d)
Dont forget the single quotes for the name!
Dont worry about the color, there are reference tables
online (you dont have to memorize the values :D)

Your code should look like this: (note the alignment)

And this is what you should see when you launch your

game again:

What kind of visual novel would this be without any

visuals?
If you store the images in your game directory inside
your projects folder , you will just need to write the
name and extension ( like HTML) BEFORE label start:
image bg bu = bu.jpg
Image bg outerSpace = space.jpg

You can use that in the background as a scene AFTER

label start:
Scene bg bu= bu.jpg

The first part of an image name is the image tag. If an

image is being shown, and another image with the


same tag is on the screen, then the image that's on the
screen is replaced with the one being shown.

You are allowed to use spaces!

For the background: .jpg or .jpeg

For the foreground: .gif

Saving the character in GIF format allows you to better

integrate it with its surroundings, because GIF


supports transparency.

You want to be able to see the characters, because that

makes it more engaging! (And its simple to


implement)
Declare the image like you did with the scene
(BEFORE label start) and then make it show.
image d happy = "durhappy.gif
Show d happy

Just like the scene can change from BU to outer space,

the characters can go from happy to any other


emotion.
If you type a different show x yy a second time, It will
overwrite the current one, and show you the new
picture!
You can also hide pictures (good practice) if youre
making another picture show in the same location, or
if the character is leaving.

Add an at-clause to a show statement. Simply say:


show d happy at right
Or:
show d happy at left

Most games play music in the background. In Ren'Py,

music files automatically loop until they are stopped


by the user.
play music "illurock.ogg

When changing music, one can supply a fadeout

clause, which is used to fade out the old music when


new music is played.
play music "illurock.ogg" fadeout 1.0

Music can be stopped with the stop music statement,

which can also optionally take a fadeout clause.


stop music

Sound effects can be played with the play sound

statement
play sound "effect.ogg"

RenPy supports formats other than .ogg for sound and

music e.g. mp3, but make sure you check the copy
rights before using the music.

Like functions/methods (chunks of code you can call

from anywhere in your program).


label is a keyword for functions (like def).
You must have noticed that we had a label start
before the game code. It is a keyword that signals
where the program begins. If you want a function to
run, you will need to call it (or call a function that calls
it).

To call a label, you


jump to it.
Keep your start
label at the top,
that is good
coding style and
makes it easier to
see how things
flow.

Remember to jump

back to where you were


if you want to continue
executing the code that
is after the jump.
RenPy will NOT
automatically jump
back to the label you
jumped from.

The menu statement introduces an in-game-menu.

It takes a block of lines, each consisting of a string

followed by a colon. These are the menu choices


which are presented to the user.
Each menu choice should be followed by a block of
one or more Ren'Py statements. When a choice is
chosen, the statements following it are run.

Lets see what the play with the visual


novel that now has a simple menu.
(Code on next slide)

After a point it becomes necessary to store the user's

choices in variables, and access them again later.


Based on the users choices, the value stored in the
variable changes, for example:
The number of answers you get right
True or False flags

You can end the game by running the return

statement, without having called anything.


it's best to put something in the game that indicates
that the game is ending, and perhaps giving the user
an ending number or ending name.

Design a game that has:


Three Characters.
Four backgrounds.

Three menus.
Five labels
Three different ending

You might also like