Simple Cross Platform Apps with Ren’Py

There are some excellent cross platform development tools out there. However for new programmers many of these tools can come with a steep learning curve.

Ren’Py is a visual novel engine that has been around for over 10 years. The Ren’Py software development kit (SDK) is supported on Linux, MacOS and Window and the Ren’Py final application can be built to run on Android, iOS Linux, MacOS, Window and HTML5.

Ren’Py uses a simple “Screen Language” so no previous programming experience is required. For more complex requirements Ren’Py supports Python.

The focus of Ren’Py is visual story telling and games, but new programmers can also create some simple apps that can be run on PCs, smart phones and web servers.

This blog will introduce Ren’Py with three examples:

  1. the start of visual novel with a couple of characters
  2. a tourist guide with graphic menus
  3. a dashboard with dynamic values and bars

Getting Started

If you want to do some playing of Ren’Py on a Raspberry Pi a light weight installation can be loaded by:

sudo apt-get install renpy

The apt-get version of Ren’Py however will 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.

The Ren’Py user interface will create new projects with all the required files and prompt the user for any additional requirements.

The script.rpy file contains all the logic for an application.

A Visual Novel

A visual novel requires some characters and background images.

Creating character drawings from scratch can be a lot of work, luckily there are some open source solutions such site as:

The character creator site allows for the creation of head, torso and head images. It also supports different facial expressions.

Below is a Ren’Py example showing a background, with a policeman and a suspect.

The script.rpy file contains the Screen Language code.

The first step is to define all the characters, in this game there two characters “cop” and “me”.

Ren’py uses labels to jump between code segments. The application begins are the start label (line10).

The image files are stored in game/images directory. Images can also be resized, rotated, moved or adjusted (Line 6). The image file cop_head.png can be referenced directly, and shown by:

show cop_head at truecenter

Dialog is shown by referencing the character and then the dialog text (lines 19-20).

By using hide and show statements different characters and backgrounds can presented. The applications ends with a return statement.

A Tourist Guide

For most graphic novels menus are required. These menus allow the application to have multiple outcomes or branches.

A Ren’Py menu is created by simply using a menu: statement. Each menu item is defined with button text and a jump statement. A jump statement is like an old-school BASIC GOTO statement, each jump has a label that the code will link to.

The example below is the start of a tourist guide for the Bruce Peninsula. The menu is called at the start of program. A menu item will jump to a specific section of the code using a label. Within a subsection, (like the beach), a new background and text is shown. After the user sees this information a jump start statement puts them back to the main menu.

For main menus it is probably cleaner to have subsections defined as separate label sections. However for smaller application it is possible to put the submenus and the display logic directly in the menu: logic.

Dynamic Screens

Ren’Py supports screens and the use of Python for applications that require more complex functions.

For the next example some CPU stats will be shown. The Linux sensors command will return the CPU and Ambient temperature:

$ sensors
Adapter: Virtual device
Processor Fan: 2691 RPM
CPU:            +53.0°C  
Ambient:        +41.0°C  

# use show Bash/AWK code to get temps
$ sensors | grep CPU | awk '{ printf "%d\n" , $2}'
$ sensors | grep Ambient | awk '{ printf "%d\n" , $2}'

A Ren’Py application can be created to show the CPU stats in a dynamic screen.

The code below defines a Ren’Py screen object and some Python code is used to shell out to the Bash/AWK statements.

A Ren’Py supports Python in either a single statement or as a python block. A single Python statement is define with a leading $, for example to set a variable: $biking = “YES”. A Python block is defined with a starting python: statement, then the code is indented from this statement.

The init python: statement is a code Python code block that is used to define (import) libraries and to initialize variables.

The Ren’Py screen object supports labels, text and bars that can be arranged or oriented in horizontal (hbox) or vertical (vbox) groupings.

# The script of the game goes in this file.

screen ts():

        now =
        nowtime = now.strftime("%H:%M:%S")
        ctemp = subprocess.check_output("sensors | grep CPU | awk '{ printf \"%d\" , $2}'", shell=True)
        atemp = subprocess.check_output("sensors | grep Ambient | awk '{ printf \"%d\" , $2}'", shell=True)
        has vbox
        label "CPU Stats" text_size 120 
        text ""
            text "Time : [nowtime]" size 80
            text "Ambient temp: [atemp] C \n" size 80
            text "   CPU temp : [ctemp] C " size 60
                text "0 " size 40
                bar value atemp range 60 xalign 50 yalign 50 xmaximum 600 ymaximum 50 
                text " 60 " size 40

init python:

    import subprocess
    from datetime import datetime

label start:

    # Start with Weather screen

    show screen ts()
    # Cycle every 2 second to refresh the data

    define cycle = "True"

    while cycle == "True" :
        $ renpy.pause(2)


Building a Final Application

The Ren’Py IDE Build option supports Windows and Linux apps directly. For Mac and Android builds the user will be prompted for some dependencies that will need to be loaded.

The HTML5 Build is still in beta, it appears to work well for standard graphic novel apps, but I found that it had some issues with Python library calls.

The HTML5 Build will create a separate library structure for the Ren’Py application which will need to be mapped into your Web Server configuration.

If you are looking to do some simple testing a Python standalone webserver can be run from the Ren’Py web directory:

# Run a python standalone server on port 8042
python3 -m http.server 8042

Final Thoughts

If you’re looking to create some simple cross-platform visual presentation apps Ren’Py is a good fit. Ren’Py is super easy to learn and don’t have to have strong programming skills.

Ren’Py supports simple screens that can have dynamic bars and text, however if you’re looking to incorporate gauges or line charts Ren’Py probably isn’t the best fit.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s