DEV Community

Cover image for Creating characters and scripting dialouge in RenPy
Ash Freels
Ash Freels

Posted on • Updated on

Creating characters and scripting dialouge in RenPy

After getting an idea for a visual novel, time to start developing the game. RenPy is a popular choice to make a visual novel. The RenPy language takes python expressions. Python code can be also added to the project. This article is going to cover how to create a basic dialogue.

1. Create a Project

Open up the RenPy launcher and click create new project where your name and choose options for your project. After that setup, things are ready to go!

2. Adding characters to your project

When opening the project in your text editor of choice look for the script.rpy file or create a separate file for adding characters. Let's define two characters: protagonist and Jane. In the Character() function the characters name and who_color is the text color for that character's name.

# Defines the characters in the story
define p = Character("[p]", who_color = "#fff")
define j = Character("Jane", who_color = "#333")

Enter fullscreen mode Exit fullscreen mode

Note for the protagonist we have [p], the player character is nameable. Here is how we define the player's name.

    $p = renpy.input("What is your name?", "Max", length=15)
    $p = p.strip()
Enter fullscreen mode Exit fullscreen mode

Now the player character can be named , the input is limited to 15 characters. If the input is empty then it will be the default name Max.

3. Dialogue

Let's start the game by adding a short introduction and dialogue.
To end the game add the return statement.

label start:

p "Hey Jane, how was the test last week?"
j "It was rough. I struggled through it, can't believe we have another test next week."
p "How about we get together and study for it."
j "That sounds great!"


Enter fullscreen mode Exit fullscreen mode

4. Adding Menus

Adding a menu gives the players options in the game. There other options such a a menu set or menu arguments. Let's add a choice over which location to go to study at.

menu study_locations:
"Where should we go to study?"

"The library":
  p "We can go to the library."

"Jane's House":
  p "How about we study at your place?"

"My House":
p "Let's go to my place and study for the quiz."
Enter fullscreen mode Exit fullscreen mode

What's next?

This article covers some of the basics when developing a game using RenPy. Images can be added when doing scenes and other advanced customization for menus. The choices are endless when adding menus in game.


Top comments (0)