Ren'Py Tutorial: How to Add Backgrounds, Character Sprites and Images

Now that we've learned how to create characters and write dialogue, let's make our visual novel a little more... visual! -> previous episode: Ren'Py Tutorial: How to Create Characters and Write Dialogue - YoruBox
After all, a visual novel without any backgrounds or character sprites would be a pretty unusual experience.
In this tutorial, we'll go through how to add background images, display character sprites, change character expressions and control where your characters appear on the screen.
We'll also cover a few useful image statements that you'll probably end up using quite often when working on your Ren'Py project.
If you haven't read our previous tutorial yet, you can check it out here:
Let's get started!
1. Preparing Your Image Files
Before adding images to your game, it's a good idea to organize your files.
Ren'Py automatically recognizes images inside your game's game folder, but I personally prefer keeping them in separate folders. It makes things much easier to manage once your project starts getting bigger.
For example, you could organize your images like this:
game/
│
├── images/
│ ├── backgrounds/
│ │ ├── classroom.png
│ │ ├── bedroom.png
│ │ └── park.png
│ │
│ └── characters/
│ ├── eileen/
│ │ ├── happy.png
│ │ ├── sad.png
│ │ └── angry.png
│ │
│ └── mika/
│ ├── happy.png
│ └── surprised.png
│
├── script.rpy
└── options.rpyYou don't have to use exactly this structure, of course. It's just an example of how I like to keep things organized.
For backgrounds, PNG and JPG are both commonly used formats. For character sprites, PNG is usually the better choice because it supports transparent backgrounds.
One more thing: try to keep your image dimensions consistent with your game's resolution. If your game uses 1920 × 1080, preparing backgrounds at that resolution will generally give you a good starting point.
2. Adding Background Images
Let's start with something simple: adding a background.
In Ren'Py, you can use the scene statement to display a background image.
For example, if you have a classroom background, you can write:
label start:
scene classroom
"It was a quiet afternoon at school."
"Most of the students had already gone home."
returnRen'Py will display the classroom image as the background.
You can also use scene to change backgrounds during a conversation:
label start:
scene classroom
e "Are you ready to go?"
m "Just a second!"
scene park
"A few minutes later, we arrived at the park."
e "It's really nice here, isn't it?"
returnWhenever you use scene, the previous scene is cleared and replaced with the new one.
This is especially useful when your story takes place in different locations.
Using Image Definitions
You can also define images beforehand
For example:
image bg classroom = "images/backgrounds/classroom.png"
image bg park = "images/backgrounds/park.png"
image bg bedroom = "images/backgrounds/bedroom.png"Then you can simply write:
scene bg classroomI recommend always defining your background image first. It also makes it easier to replace images later without having to edit every single line of your script.
3. Adding Character Sprites
Now let's add some characters to the screen!
Unlike backgrounds, character sprites usually have transparent backgrounds so they can appear on top of the scene.
First, let's define a character image:
image eileen happy = "images/characters/eileen/happy.png"
image eileen sad = "images/characters/eileen/sad.png"
image eileen angry = "images/characters/eileen/angry.png"Notice that we have three images for the same character, each representing a different expression.
To display Eileen, use the show statement:
label start:
scene bg classroom
show eileen happy
e "Hey! How are you doing?"
returnThe background (bg classroom) will appear first, followed by Eileen's sprite.
You can also display multiple characters at the same time:
scene bg classroom
show eileen happy
show mika happy
e "Oh, there you are!"
m "I've been waiting for you."Both characters will appear on the screen.
One thing to remember is that show doesn't clear the previous images. It adds an image to the current scene or replaces an existing image with the same image tag.
We'll look at image tags and positioning in the next sections.
4. Changing Character Expressions
This is probably one of the most frequently used features when writing a visual novel.
You don't want your character to keep smiling throughout the entire story
Let's say Eileen has three expressions:
- Happy
- Sad
- Angry
We've already defined these images:
image eileen happy = "images/characters/eileen/happy.png"
image eileen sad = "images/characters/eileen/sad.png"
image eileen angry = "images/characters/eileen/angry.png"Now, you can change her expression simply by using another show statement:
show eileen happy
e "It's so nice to see you!"
show eileen sad
e "Actually, I've been having a pretty bad day."
show eileen angry
e "And I'm really tired of this!"Ren'Py recognizes eileen as the image tag, so showing another image with the same tag replaces the previous one.
You don't have to write hide eileen every time before changing her expression.
5. Positioning Character Sprites
By default, Ren'Py places characters near the center of the screen.
But what if you want one character on the left and another on the right?
You can use built-in positions such as:
show eileen happy at left
show mika happy at rightHere are some of the positions you can use:
| Position | Description |
|---|---|
left | Left side of the screen |
right | Right side of the screen |
center | Center of the screen |
truecenter | Exact center of the screen |
offscreenleft | Outside the left edge |
offscreenright | Outside the right edge |
For example:
scene bg classroom
show eileen happy at left
show mika happy at right
e "So, what do you think?"
m "I think it's a great idea!"This makes conversations between two or more characters look much more natural.
Creating Custom Positions
The built-in positions are useful, but sometimes you might want a little more control.
For example, you may want a character slightly closer to the center or a little lower on the screen.
You can define your own positions using Position():
transform left_position:
xalign 0.25
yalign 1.0
transform right_position:
xalign 0.75
yalign 1.0Then use them like this:
show eileen happy at left_position
show mika happy at right_positionYou can adjust xalign and yalign to change where the sprite appears.
Both values normally range from 0.0 to 1.0:
0.0means the left or top edge.0.5means the center.1.0means the right or bottom edge.
For example, xalign 0.25 places the character around a quarter of the way across the screen.
This is particularly useful if you're designing a game with a custom resolution or a specific character layout.
6. Resizing Character Sprites
Sometimes your character sprites might be too large or too small for your game's resolution.
You can resize them using a transform.
For example:
transform small_sprite:
zoom 0.7
transform large_sprite:
zoom 1.2Then:
show eileen happy at small_spriteOr you can combine resizing and positioning:
transform eileen_position:
xalign 0.25
yalign 1.0
zoom 0.8And use:
show eileen happy at eileen_positionYou can also use xzoom and yzoom if you want to resize an image horizontally or vertically.
For example:
transform flip_character:
xzoom -1.0This flips the character horizontally.
It's a quick way to make a character face the opposite direction without having to create another image file.
Just be careful when flipping images that contain text, accessories or asymmetrical details!
7. Hiding Character Sprites
Sometimes a character needs to leave the scene.
For this, use the hide statement:
show eileen happy
e "I'll see you later!"
hide eileenSince eileen is the image tag, Ren'Py knows which character to remove.
You can also hide all currently displayed images using:
scene bg classroomRemember that scene clears the previous scene, including character sprites, before displaying the new background.
8. Adding Transitions Between Images
A simple image change can sometimes feel a little abrupt.
Luckily, Ren'Py has several built-in transitions that you can use to make scene changes smoother.
For example:
scene bg classroom with fade
show eileen happy with dissolveHere are some commonly used transitions:
| Transition | Description |
|---|---|
fade | Fades the screen to black and then into the new scene |
dissolve | Smoothly blends between images |
pixellate | Creates a pixelated transition |
move | Moves images between positions |
ease | Smoothly moves images between positions |
You can also control how long a transition takes:
scene bg park with Dissolve(1.5)This makes the transition last 1.5 seconds.
For character sprites, you can also use:
show eileen happy with dissolve
e "Hey!"A little transition can make your game feel much more polished without requiring complicated code.
We'll explore transitions and animations in more detail in a separate tutorial.
9. Putting Everything Together
Let's try combining everything we've learned into one small example.
For this example, we'll use a classroom background and two characters with different expressions.
define e = Character("Eileen", color="#E8A0BF")
define m = Character("Mika", color="#9DBCE8")
image bg classroom = "images/backgrounds/classroom.png"
image bg park = "images/backgrounds/park.png"
image eileen happy = "images/characters/eileen/happy.png"
image eileen sad = "images/characters/eileen/sad.png"
image mika happy = "images/characters/mika/happy.png"
image mika surprised = "images/characters/mika/surprised.png"
transform left_position:
xalign 0.25
yalign 1.0
transform right_position:
xalign 0.75
yalign 1.0
label start:
scene bg classroom with fade
show eileen happy at left_position with dissolve
show mika happy at right_position with dissolve
e "Hey! Do you have any plans for today?"
m "Not really. Why?"
show eileen sad
e "I was hoping we could go somewhere together..."
show mika surprised
m "Oh! Sure, I'd love to!"
scene bg park with fade
show eileen happy at left_position
show mika happy at right_position
e "This place is really beautiful, isn't it?"
m "Yeah! I'm glad we came here."
returnMake sure all the image paths match your actual files. You can replace the example images with your own artwork.
And that's it! You now have a basic scene with backgrounds, multiple characters, expressions, custom positions and transitions.
What's Next?
We've now covered the basics of adding backgrounds, displaying character sprites, changing expressions and positioning images in Ren'Py.
In the next tutorial, we'll take a closer look at Ren'Py transitions and ATL animations, including how to make characters move, fade in and out, and add a little more life to your scenes.
If you're following along with this series, you're already one step closer to making your own visual novel!
Need Custom Character Sprites or Visual Novel UI?
Working on a visual novel often means dealing with more than just scripting. Sometimes you need custom character expressions, interface elements or a little help getting everything implemented properly.
At YoruBox, we work on indie visual novels and offer help with Ren'Py development, custom UI design and other game-related tasks.
If you need a hand with your project, feel free to check out our services!