Cross-platform game and app development for new programmers
Easy Does It
Ren'Py helps you create Android, Linux, macOS, Windows, and HTML5 games and apps.
Although you can find some excellent cross-platform development tools, many of these tools come with a steep learning curve for new programmers. Ren'Py [1] is a visual novel engine that has been around for more than 10 years, and it is one of the easiest packages to learn for game and app development.
The nice thing about Ren'Py is that you don't need any previous programming experience. Ren'Py uses a simple "screen language" that allows you to add backgrounds, images, character dialogs, and menus. For more complex requirements, Ren'Py supports inline Python and Python blocks.
The Ren'Py software development kit (SDK) is supported on Linux, macOS, and Windows, with final applications that can be built to run on Android, iOS, Linux, macOS, and Windows and in browsers with HTML5 (Figure 1).
In this article, I introduce Ren'Py with three examples. The first example will be the start of a visual novel. The second example will be a tourist guide with graphic menus, and the final example uses Python to create a dashboard screen that shows dynamic values and bars.
Getting Started
If you want to play with Ren'Py on a Raspberry Pi or an Ubuntu/Debian system, you can load a lightweight installation with:
sudo apt-get install renpy
The apt-get
version of Ren'Py, however, does not have any tutorials or extra build features, so it is recommended that you go to the Ren'Py site for the complete installation directions [2].
The Ren'Py user interface creates new projects with all of the required files and supports all of the different build options (Figure 2). The script.rpy
text file contains all the logic for an application.
Visual Novel
A visual novel is sort of like a comic book that can have multiple paths and story lines that users select as they work their way through the novel. The first step is to define some characters and background images. Creating character drawings from scratch can be a lot of work; luckily, you can find some open source solutions that can help out.
Character Creator [3] is an excellent free website you can use to generate male or female head, torso, and full-body images. It also supports a variety of facial expressions (Figure 3). The character image files and all background images are stored in the project's game/images
directory.
The next step is to use a standard text editor and add screen language code to the script.rpy
file. Figure 4 and Listing 1 show the code required to display a background with a character and some dialog. Lines 3 and 4 define two characters cop
and me
. These definitions are used to output or show dialog text. Ren'Py uses labels to jump between code segments. The application begins at the start
label (line 10).
Listing 1
Visual Novel
01 # darkstreet - script.rpy 02 03 define cop = Character("Cop") 04 define me = Character("Me") 05 06 image darkstreet = im.Scale("darkstreet.jpg",config.screen_width,config.screen_height) 07 08 # The game starts here. 09 10 label start: 11 12 # Show a background. 13 show darkstreet 14 15 show cop_head at truecenter 16 17 # These display lines of dialogue. 18 19 cop "Hey Kid! Stop right there!\n 20 Why do you have blood on your hands?" 21 22 hide cop_head 23 show me_crying_head at truecenter 24 25 me "It wasn't me...I don't know what happened." 26 27 28 return
Images in the game/images
directory can be displayed simply with:
show image_name at position
In this example, cop_head.png
is displayed at the center of the screen (line 15) by:
show cop_head at truecenter
Images can also be resized, rotated, moved, or adjusted. In line 6, the background (darkstreet.jpg
) is sized to fill the screen. Dialog is shown by referencing the character and then the dialog text (lines 19-20).
Figure 5 shows the next phase of the story. The policeman is hidden with the hide
statement (line 22) and an image of a crying girl (me_crying_head
) is shown with some dialog (line 25). The use of hide
and show
statements allow you to present different characters and backgrounds.
At the end of the story, the application finishes with a return
statement (line 28).
Tourist Guide
Most apps and games require menus that allow multiple branches or outcomes. A Ren'Py menu is created simply with a menu:
statement. Each menu item is defined with button text and a jump
statement, which is like an old-school Basic GOTO
statement. Each jump
has a label to which the code links.
Figure 6 shows the start of a tourist guide for the Bruce Peninsula [4]. A menu is called at the start of the program. Each menu item jumps to a specific section of the code with a label. Within a subsection, (e.g., the beach), a new background and text are shown. After the user sees this information, a jump start
statement puts the user back to the main menu.
For smaller applications (Figure 7), you can put the submenus, display logic, and Python code directly in the menu:
logic.
Buy this article as PDF
(incl. VAT)
Buy Linux Magazine
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters
Support Our Work
Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.
News
-
Budgie 10.10 Scheduled for Q1 2025 with a Surprising Desktop Update
If Budgie is your desktop environment of choice, 2025 is going to be a great year for you.
-
Firefox 134 Offers Improvements for Linux Version
Fans of Linux and Firefox rejoice, as there's a new version available that includes some handy updates.
-
Serpent OS Arrives with a New Alpha Release
After months of silence, Ikey Doherty has released a new alpha for his Serpent OS.
-
HashiCorp Cofounder Unveils Ghostty, a Linux Terminal App
Ghostty is a new Linux terminal app that's fast, feature-rich, and offers a platform-native GUI while remaining cross-platform.
-
Fedora Asahi Remix 41 Available for Apple Silicon
If you have an Apple Silicon Mac and you're hoping to install Fedora, you're in luck because the latest release supports the M1 and M2 chips.
-
Systemd Fixes Bug While Facing New Challenger in GNU Shepherd
The systemd developers have fixed a really nasty bug amid the release of the new GNU Shepherd init system.
-
AlmaLinux 10.0 Beta Released
The AlmaLinux OS Foundation has announced the availability of AlmaLinux 10.0 Beta ("Purple Lion") for all supported devices with significant changes.
-
Gnome 47.2 Now Available
Gnome 47.2 is now available for general use but don't expect much in the way of newness, as this is all about improvements and bug fixes.
-
Latest Cinnamon Desktop Releases with a Bold New Look
Just in time for the holidays, the developer of the Cinnamon desktop has shipped a new release to help spice up your eggnog with new features and a new look.
-
Armbian 24.11 Released with Expanded Hardware Support
If you've been waiting for Armbian to support OrangePi 5 Max and Radxa ROCK 5B+, the wait is over.