Create a Visual Novel Using Ren’Py

Maria Ramos
6 min readJan 21, 2020

--

Ren’Py is a visual novel game engine developed in Python

Screenshot by Author. Screenshot of visual novel game I made using Ren’Py.

What You’ll Learn

This blog is a tutorial for learning how to create a visual novel with basic functionality using Ren’Py.

You will learn:

  • what a visual novel is
  • what Ren’Py is
  • how to install Ren’Py
  • how to create a basic visual novel using Ren’Py, which includes: characters, inner dialog, character dialog, simple character animation, decisions, music, and sound effects

Introduction

What is a Visual Novel?

A visual novel is a video game genre in which a player goes through an interactive story described through text and images. It may be a static story or a dynamic one, in which a player can make decisions that change the storyline.

Visual novels are very popular in Japan (some examples include School Days, Danganronpa), and they have gained popularity in the United States as app games (some examples of these apps are Choices, Episode, Chapters, and Stories). There is also a popular american visual novel which came out in 2017, and was developed using Ren’Py, called Doki Doki Literature Club!

Screenshot by apkgamezone. The app ‘Choices’ is an example of a visual novel game.

What is Ren’Py?

Ren’Py is an opensource visual novel game engine developed in Python. It has a simple syntax, making it easy and accessible to use for people with varying degrees of programming knowledge and in different age groups. I find it to be a fun and simple introduction to programming.

Ren’Py allows for exporting the created visual game as an Android or iOS app.

For this tutorial I created a short visual novel with two characters called Square-san and Circle-sempai, which I drew using GIMP.

These characters live in the world of shapes. Square-san has been in love with Circle-sempai since childhood, but Circle-sempai is now dating Triangle-san, who is kind of a jerk. Square-san and Circle-sempai meet up by chance, and Circle-sempai tells Square-san that she got stood up by her boyfriend. Square-san must decide what to do next.

At the end of the tutorial you can watch a video of the playthrough of the game.

Let’s Get Started

Install and Run Ren’Py

Download the latest version of Ren’Py from here. Unzip the downloaded folder and move it to a folder of your choice (I moved it to my Desktop folder). Open your terminal, move to the downloaded folder, and run the script renpy.sh (in Linux, run by writting ./renpy.sh)

Screenshot by Author. Ren’Py GUI Launcher, comes up when you run renpy.sh.

To create a project, click on “+ Create New Project”, which is to the bottom left of the launcher. To launch/run an existing project, select the project in the “PROJECTS” list, then click on “Launch Project”, present to the bottom right of the launcher.

Once you create a project, a folder will be created within the Ren’Py folder. To develop the game’s logic, you must modify the file script.rpy which is present in the /game folder within the project’s folder.

Add Background

Visual novels have background images in order to set different scenes. To display a background image, write: scene imageFileName, where imageFileName is the name (excluding file extension) of an image file present within the /images folder (present within the /game folder).

By default, Ren’Py searches for images within the /images folder. It’s expected that you keep background and character images in that folder, but it can be placed elsewhere, just remember to add the path to the scene statement. The scene statement does not require a file extension. Avoid having multiple image files of different extensions with the same file name.

The recommended background image size is of width 1280px and height 720px.

Display Characters

Character images should be saved in the folder images which is within the folder game. A good size for the character image files is a width of 320px and a height of 720px. Feel free to test different sizes until you find the look you want in your game.

Display a character on screen by writing show and the name of the image file within the /images folder. The name of the file does not need to include its extension, Ren’Py will grab the image it finds.

For example, if I have an image for a character in the /images folder called character.png, then I can display this character in the middle of the screen by writing the line: show character

You can specify where on the screen you want the character to appear. If you want the character to appear on the left, write show character at left. If you want the character to appear on the right, write show character at right.

To remove a character from the scene, write hide character.

Basic Animation

The background image can fade in or out by writing scene town with fade.

Character can fade in or out by writing show character with dissolve.

Dialog

To define a character which will be involved in dialog, write the following code: define characterVarName = Character(“CharacterName”). For example, in the game I made I defined the Square-san character by writing define square = Character("Square-chan").

For a defined character to speak (have dialog) in the game, write the character’s variable name followed by a string with the text the character will say: characterVarName “Dialog to speak”. For example, for Square-chan to say one line, I wrote square “Hi. What are you doing this weekend?”

To write thoughts, inner dialog, or narration, you just add the string on its own, without the character variable preceding it. For example:

“Triangle sama is Circle’s on-and-off boyfriend.”“I hate that guy.”

Decisions

Decisions are placed inside a menu statement. Each decision is specified as a string followed by a colon, a new line, an indentation, and the instructions to follow if the particular decision is chosen.

Time to decide! Should Square-san confess his feelings, or stay quiet?

In the code above, each decision has a jump statement. The jump statement transfers control to the specified label, which is defined in the code using the label statement.

If the menu choice does not contain a jump statement, once the instructions within it finish running, Ren’Py will run the code of the next choice. So it is necessary to have jump statements within decisions to maintain the intended logic. It is unnecessary to have a jump statement in the last decision, since there are no decisions after it, but it does not hurt to use it.

Music and Sound Effects

Visual novels usually have background music and some sound effects.

To play a music file, write play music “/audio/bensound-buddy.mp3”. The music file will loop indefinitely, unless stopped in the code.

To stop playing the music file, write stop music.

To play a sound effect, write play sound “/audio/church.mp3”. Sound effects differ from music because they do not loop.

Final Product

Video by Author. Playthrough of visual novel game I made using Ren’Py.

Script.rpy Code

Real file extension is .rpy. The gist has an extension of .py so code is colored.

Conclusion

As you have read, you can quickly get started with programming a visual novel, for free! Now, if you haven’t already, you need to: create a story, create different decisions and storylines (if you want a player to make choices), and design and draw characters!

Get more information on Ren’Py functionality by visiting Ren’Py’s documentation.

Feel free to share a link to your visual novel in the comments!

Extra

My favorite part of visual novels is making bad decisions and being an awful protagonist (doing what I shouldn’t do in real life).

Gif from Giphy.com

If you enjoyed this article please recommend and share.

--

--

Maria Ramos
Maria Ramos

Written by Maria Ramos

Puerto Rican computer scientist who enjoys writing helpful articles and contributing to the vast content on the internet.

No responses yet