Ren’py 7.0 «for all mankind.»

Additional Downloads

Raspberry Pi Support: renpy-7.4.0-raspi.tar.bz2
Contains files required to allow Ren’Py to run on the Raspberry Pi. This should be untarred in the Ren’Py sdk directory.
Ren’Py Source Code: renpy-7.4.0-source.tar.bz2
Contains the source code of the Ren’Py distribution without any binary components.
Pygame_SDL2 Source Code: pygame_sdl2-2.1.0-for-renpy-7.4.0.tar.gz
Contains the source code for the version of pygame_sdl2 required to run this version of Ren’Py. This may be newer than any released version of pygame_sdl2.
Other Dependencies: https://www.renpy.org/doc/html/license.html
Ren’Py contains free software licensed under a number of licenses, including the GNU Lesser
General Public License. A full list of software and links to git repositories from which the software
can be downloaded is linked above.
Checksums: checksums.txt
Checksums for the various files making up the Ren’Py distribution.

We also maintain a complete list of releases.

Unsanctioned Translations link

Note

It’s best to ask a game’s creators for permission before
creating an unsanctioned translation.

Ren’Py includes a small amount of support for creating translations
without the active assistance of the game’s creators. This support
consists of the ability to automatically create a string translation
file from all of the strings in the game. Since string translations
are used for untranslated dialogue, this technique makes it possible
to translate a game.

To create a string translation file, perform the following steps:

  • Set the RENPY_LANGUAGE environment variable to the language you want
    to translate to.
  • Set the RENPY_UPDATE_STRINGS environment variable to a non-empty
    value.
  • Play through the game until all text is seen.

This will update the «game/tl/language/strings.rpy» file with a
translation template that contains all of the strings in it.

If a game doesn’t include support for changing the language, it may be
appropriate to use an block to set
to the target language.

Along with the use of string translations for dialogue, unsanctioned
translators may be interested in using the techniques described above
to translate images and styles.

Announcement

I’m happy to announce Ren’Py 7.2.1, a patch release. This release consists
primarily of fixes. It also adds support for generating the icon and
launchimage on iOS.

Ren’Py 7.2 adds new features to Ren’Py, including:

  • Menus now take arguments, and so do menu choices.
  • The say statement can now take a temporary image attribute, making is
    possible to change a character’s emotion for a single statement.
  • The new im.Blur image manipulator can blur static images.
  • Layeredimage groups can now contain non-conflicting attributes while
    still being automatically declared.
  • It’s possible to display a non-looping Movie displayable, and to have
    a movie display a static image before the first frame renders.
  • A fullscreen Ren’Py will not minimize when the mouse changes monitors.
  • Text now takes renpy.BASELINE as a yanchor, which allows one to position
    the text’s baseline.
  • The CTC screen now takes additional arguments, including the kind of
    click-to-continue indicator being shown.

Ren’Py 7.2 updates Ren’Py to work with the current Android SDK, and contains
a number of other bugfixes.

Ren’Py 7.2.1 is brought to you by:

  • Andy_kl
  • Craig P. Donson
  • Eric Ahn
  • Enerccio
  • Frédéric Chapoton
  • Mal Graty
  • Moshibit
  • Sergey Musiyenko
  • Shayne Officer
  • Sylvain Beucler
  • Xavi-mat

and myself, Tom «PyTom» Rothamel.

Downloads of Ren’Py 7.2.1 can be found at:

A full list of changes to Ren’Py can be found at:

A list of changes that may require you to update your game can be found at:

Show Statement link

The statement is used to display an image on a layer. A show
statement consists of a single logical line beginning with the
keyword , followed by an image name, followed by zero or
more properties.

If the show statement is given the exact name of an existing image,
that image is the one that is shown. Otherwise, Ren’Py will attempt to
find a unique image that:

  • Has the same tag as the one specified in the show statement.
  • Has all of the attributes given in the show statement.
  • If an image with the same tag is already showing, shares the largest
    number of attributes with that image.

If a unique image cannot be found, an exception occurs.

If an image with the same image tag is already showing on the layer,
the new image replaces it. Otherwise, the image is placed above all
other images in the layer. (That is, closest to the user.) This order
may be modified by the and properties.

The show statement does not cause an interaction to occur. For the
image to actually be displayed to the user, a statement that causes an
interaction (like the say, menu, pause, and with statements) must be
run.

The show statement takes the following properties:

The property takes a name. This name is used in place of the
image tag when the image is shown. This allows the same image
to
be on the screen twice.

The property takes one or more comma-separated
simple expressions. Each expression must evaluate to a
transform. The transforms are applied to the image in
left-to-right order.

If no at clause is given, Ren’Py will retain any existing
transform that has been applied to the image. If no transform
exists, the image will be displayed using the
transform.

See the section on
for information about
how replacing the transforms associated with
a tag can change the transform properties.

Takes a comma-separated list of one or more names. Each name is
taken as an image tag. The image is shown behind all images with
the given tags that are currently being shown.
Takes a name. Shows the image on the named layer.
Takes an integer. The integer specifies the relative ordering of
images within a layer, with larger numbers being closer to the
user. This isn’t generally used by Ren’Py games, but can be useful
when porting visual novels from other engines.

Assuming we have the following images defined:

image mary night happy = "mary_night_happy.png"
image mary night sad = "mary_night_sad.png"
image moon = "moon.png"

Some example show statements are:

# Basic show.
show mary night sad

# Since 'mary night sad' is showing, the following statement is
# equivalent to:
# show mary night happy
show mary happy

# Show an image on the right side of the screen.
show mary night happy at right

# Show the same image twice.
show mary night sad as mary2 at left

# Show an image behind another.
show moon behind mary, mary2

# Show an image on a user-defined layer.
show moon onlayer user_layer

Show Expression.
A variant of the show statement replaces the image name with the
keyword , followed by a simple expression. The
expression must evaluate to a displayable, and the displayable
is shown on the layer. To hide the displayable, a tag must be
given with the as statement.

For example:

show expression "moon.png" as moon

Uniforms and Attributes link

The following uniforms are made available to all Models.

The width and height of the model.
The level of detail bias to apply to texture lookups. This may be
set in a Transform. The default value, taken from
and defaulting to -0.5, biases Ren’Py to always pick the next bigger
level and scale it down.
The transform used to project virtual pixels to the OpenGL viewport.
The time of the frame. The epoch is undefined, so it’s best to treat
this as a number that increases by one second a second. The time is
modulo 86400, so it will reset to 0.0 once a day.
Four random numbers between 0.0 and 1.0 that are (with incredibly high
likelyhood) different from frame to frame.
, ,
If textures are available, the corresponding samplers are placed in
this variable.
, ,
If textures are available, the size of the textures are placed in these
variables. When the texture is loaded from disk, this is the size of the
image file. After a render to texture, it’s the number of drawable pixels
the rendered texture covered.

The following attributes are available to all models:

The position of the vertex being rendered.

If textures are available, so is the following attribute:

Dialogue Window Management link

Ren’Py includes several statements that allow for management of the
dialogue window. As dialogue window is always shown during dialogue,
these statements control the presence or absence of the window during
non-dialogue interactions.

The window show statement causes the window to be shown.
It takes as an argument an optional transition, which is used to show the
window. If the transition is omitted,
is used.
The window hide statement causes the window to be hidden. It takes as an
argument an optional transition, which is used to hide the window. If
the transition is omitted, is
used.
This enables automatic management of the window. The window is shown
before statements listed in – by default,
say statements. The window is hidden before statements listed in
– by default, and
statements, and statements without a caption.
(Only statements are considered, not statement equivalent
functions.)
,
These statements show or hide the window, with an optional transition,
like or do. However, unlike those
statements, this keeps automatic management enabled.

The statement uses
and to show and hide the window,
respectively. is cancelled by and .

For example:

window show # shows the window with the default transition, if any.
pause       # the window is shown during this pause.
window hide # hides the window.
pause       # the window is hidden during this pause.

window show dissolve # shows the window with dissolve.
pause                # the window is shown during this pause.
window hide dissolve # hides the window with dissolve.
pause                # the window is hidden during this pause.


window auto

"The window is automatically shown before this line of dialogue."
pause                # the window is shown during this pause.

scene bg washington  # the window is hidden before the scene change.
with dissolve

window auto show     # Shows the window before it normally would be shown.

show eileen
with dissolve

"Without window auto show, the window would have been shown here."

The Ren’Py Launcher link

Before you begin making a game, you should first take some time to
learn how the Ren’Py launcher works. The launcher lets you create,
manage, edit, and run Ren’Py projects.

Getting Started. To get started you’ll want to
download Ren’Py.

Once you’ve downloaded Ren’Py, you’ll want to extract and run it.

  • On Windows, double click on the executable file you download. It will
    extract Ren’Py into a folder named . You can change
    into that folder and run . (The renpy.exe file may be presented
    as renpy if extensions are hidden.)
  • On Mac OS X, double-click on the downloaded drive image to mount it as a
    drive. When the drive opens, copy the folder named
    somewhere else. (Where does not matter, but it has to be moved out of
    the read-only drive image. Do not move the renpy app out of the folder it’s in
    – it won’t work elsewhere.) Then change into it, and run the
    application.
  • On Linux, unpack the tarball, change into the
    directory, and then run .

After running this, the Ren’Py launcher should run.

The Ren’Py launcher has been translated to multiple languages. To
change the language, choose «preferences» at the bottom right, and then
select the language.

Choosing and Launching a Project. You should first see what the
completed
The Question game looks like. To do this, start the Ren’Py
launcher, and choose «The Question» from the first screen. Choose
«Launch Project» to start The Question.

You can get back to the Ren’Py demo by doing the same thing, but
choosing «Tutorial» instead of «The Question».

The main screen of the Ren’Py launcher.

Naming a new project.

Selecting the project resolution.

Selecting the accent and background colors for the default theme.

Creating a new Project.
Create a new project by choosing «Create New Project» from the
launcher.

If this is your first time creating a project, Ren’Py may ask you to
select the projects directory. This is a directory (also called a folder)
where new projects are created, and is scanned for existing projects. The
directory chooser might pop up below Ren’Py, so be sure to look for it
there.

The launcher will then ask you for a project name. Since
«The Question» is already taken, you should enter something different,
like «My Question», and type enter.

After that, the launcher will ask you to select the project resolution. The
default of 1280×720 is a good compromise between game size and image quality.
For the purpose of this tutorial, we will select 1280×720 to match
«The Question» game art, then click «Continue».

The launcher will then ask you to choose a color scheme – an accent and
background color for the new GUI. It doesn’t matter what you pick at
this point, so just pick something you find appealing, and then click
«Continue».

Cross Platform — Computer and Mobile

One of Ren’Py’s biggest advantages is that runs on almost every computer. There are three primary platforms we support:

  • Windows Vista+ (x86, x86_64)
  • Mac OS X 10.10+ (x86_64)
  • Linux (x86, x86_64)

The Ren’Py launcher makes it possible to build versions of Ren’Py games for all three from any of these three platforms, making it possible to develop (for example) Mac and Linux versions on Windows.

Ren’Py games are not dependent on any other software on these platforms. There’s no need for your users to download runtimes, drivers, codecs, or anything like that. If a user has one of the supported platforms, Ren’Py will run. (Even if not, Ren’Py is written using portable technologies like pygame, and so can probably be made to run.)

Additional Downloads

Ren’Py Source Code: renpy-6.99.11-source.tar.bz2
Contains the source code of the Ren’Py distribution without any binary components.
Pygame_SDL2 Source Code: pygame_sdl2-2.1.0-for-renpy-6.99.11.tar.gz
Contains the source code for the version of pygame_sdl2 required to run this version of Ren’Py. This may be newer than any released version of pygame_sdl2.
Other Dependencies: https://www.renpy.org/doc/html/license.html
Ren’Py contains free software licensed under a number of licenses, including the GNU Lesser
General Public License. A full list of software and links to git repositories from which the software
can be downloaded is linked above.

We also maintain a complete list of releases.

Supporting Flags using the Default, Python and If Statements link

While some games can be made by only using the statements given above,
other games requires data to be stored and recalled later. For example,
it might make sense for a game to remember a choice a player has made,
return to a common section of the script, and act on the choice later. This
is one of the reasons why Ren’Py has embedded Python support.

Here, we’ll show how to store a flag containing information about a choice
the player has made. To initialize the flag, use the default statement, before
label start.

# True if the player has decided to compare a VN to a book.
default book = False

label start

    s "Hi there! How was class?"

The book flag starts off initialized to the special value
(as with the rest of Ren’Py, capitalization matters), meaning that
it is not set. If the book path is chosen, we can set it to True
using a Python assignment statement.

label book

    $ book = True

    m "It's like an interactive book that you can read on a computer or a console."

    jump marry

Lines beginning with a dollar-sign are interpreted as Python statements. The
assignment statement here assigns a value to a variable. Ren’Py has support
for other ways of including Python, such as a multi-line Python statement,
that are discussed in other sections of this manual. Ren’Py supports Python 2.7,
though we strongly recommend you write Python that runs in Python 2 and Python 3.

To check the flag, use the statement:

if book

    "Our first game is based on one of Sylvie's ideas, but afterwards I get to come up with stories of my own, too."

If the condition is true, the block of script is run. If not, it is skipped.
The statement can also take an clause, that introduced a block of
script that is run if the condition is false.

if book

    "Our first game is based on one of Sylvie's ideas, but afterwards I get to come up with stories of my own, too."

else

    "Sylvie helped with the script on our first video game."

Ren’Py Script Statements link

ATL can be included as part of three Ren’Py script statements.

Transform Statement

The statement creates a transform that can be supplied as part of an
at clause. The syntax of the transform statement is:

atl_transform ::=  "transform"  "("  ")" ":"
                      

The transform statement must be run at init time. If it is found outside an
block, then it is automatically placed inside an block with a
priority of 0. The transform may have a list of parameters, which must be
supplied when it is called.

Name must be a Python identifier. The transform created by the ATL block is
bound to this name.:

transform left_to_right
    xalign 0.0
    linear 2.0 xalign 1.0
    repeat

Image Statement With ATL Block

The second way to use ATL is as part of an statement with ATL block.
This binds an image name to the given transform. As there’s no way to supply
parameters to this transform, it’s only useful if the transform defines an
animation. The syntax for an image statement with ATL block is:

atl_image ::=  "image"  ":"
                  
image eileen animated
    "eileen_happy.png"
    pause 1.0
    "eileen_vhappy.png"
    pause 1.0
    repeat

Text Displayables link

Text can also be used as a , which
allows you to apply transforms to text, displaying it as if it was an
image and moving it around the screen.

(style=u’default’, **properties)

This is a displayable that can be shown with an additional string
parameter, which then shows that string as if it was an image.
This is usually used as part of the pre-defined image.

For example, one can do:

show text "Hello, World" at truecenter
with dissolve
pause 1
hide text
with dissolve

You can use ParameterizedText directly to define similar images with
different style properties. For example, one can write:

image top_text = ParameterizedText(xalign=0.5, yalign=0.0)

Announcement

I’m mildly chagrined to announce Ren’Py 7.3.2. This is a patch release to Ren’Py
7.3, mostly intended to fix bugs and address issues that people have
reported. As some of the bugs have significant performance and correctness
impact, everyone who upgraded to Ren’Py 7.3.0 or 7.3.1 should move on to this version.

Ren’Py 7.3.1 added a few minor new features, including the ability to
customize descriptive text.

Ren’Py 7.3 is the first release of
Ren’Py with support for running on the web platform, inside a web browser
supporting HTML 5, Web Assembly, and WebGL. Right now, this support is in
beta, as it’s limited by the capabilities of the web platform itself, but
it’s suitable for making web demos of Ren’Py games.

In addition to that, this release adds many new features to Ren’Py. These
include:

  • Many improvements to creator-defined statements, allowing the parsing
    of Ren’Py statements and block, the catching of errors, and the ability
    to execute a second function after Ren’Py in the body of a statement
    has finished.
  • Screen language improvements, like the ability to capture screen language
    displayables into a variable and to use a property to determine if a screen
    is sensitive to input.
  • Text improvements, with self-closing text tags and the ability to control
    the capitalization of interpolated text.
  • Mobile platforms now support non-rectangular focus masks, and 64-bit Android
    is supported in time for the Google Play deadline.
  • There is a new Turkish translation of the launcher and Spanish translation of
    the tutorial game, while several of the other translations have been updated.

There are also a number of other changes, so check out the changelog for all
of what’s new.

Ren’Py 7.3 is brought to you by:

  • Andy_kl
  • Arda Güler
  • DragoonHP
  • Jan Beich
  • Kobaltcore
  • Lee Yunseok
  • Mal Graty
  • Moshibit
  • Nyaatrap
  • Pionere
  • Sylvain Beucler

and myself, Tom «PyTom» Rothamel.

Downloads of Ren’Py 7.3.2 can be found at:

A full list of changes to Ren’Py can be found at:

A list of changes that may require you to update your game can be found at:

Announcement

I’m happy to announce Ren’Py 7.3.3. This release is intended to improve
performance and compatibility, fix bugs, and make available minor features
that have been added since Ren’Py 7.3.2 was released.

Some highlights are:

  • An audio directory that allows audio files to define themselves, similar
    to images.
  • The ability for Ren’Py to accept audio files generated at runtime.
  • A lowering of the version of android needed to run Ren’Py.
  • Many improvements to Web platform support.
  • Improved render-to-texture performance.
  • The ability of renpy.input to take custom screens.
  • Ren’Py is now signed and notarized to run on macOS.

Ren’Py 7.3.2 is a patch release to Ren’Py
7.3, mostly intended to fix bugs and address issues that people have
reported. As some of the bugs have significant performance and correctness
impact, everyone who upgraded to Ren’Py 7.3.0 or 7.3.1 should move on to this version.

Ren’Py 7.3.1 added a few minor new features, including the ability to
customize descriptive text.

Ren’Py 7.3 is the first release of
Ren’Py with support for running on the web platform, inside a web browser
supporting HTML 5, Web Assembly, and WebGL. Right now, this support is in
beta, as it’s limited by the capabilities of the web platform itself, but
it’s suitable for making web demos of Ren’Py games.

In addition to that, this release adds many new features to Ren’Py. These
include:

  • Many improvements to creator-defined statements, allowing the parsing
    of Ren’Py statements and block, the catching of errors, and the ability
    to execute a second function after Ren’Py in the body of a statement
    has finished.
  • Screen language improvements, like the ability to capture screen language
    displayables into a variable and to use a property to determine if a screen
    is sensitive to input.
  • Text improvements, with self-closing text tags and the ability to control
    the capitalization of interpolated text.
  • Mobile platforms now support non-rectangular focus masks, and 64-bit Android
    is supported in time for the Google Play deadline.
  • There is a new Turkish translation of the launcher and Spanish translation of
    the tutorial game, while several of the other translations have been updated.

There are also a number of other changes, so check out the changelog for all
of what’s new.

Ren’Py 7.3 is brought to you by:

  • Alisha Taylor
  • Andy_kl
  • Arda Güler
  • Ben Wright
  • DragoonHP
  • Donghyeok Tak
  • Herpior
  • Jan Beich
  • Joshua Fehler
  • Julian Uy
  • Kobaltcore
  • Lee Yunseok
  • Mal Graty
  • Moshibit
  • Nyaatrap
  • Pionere
  • Psunbury
  • Remix
  • Roope Herpiö
  • Sylvain Beucler

and myself, Tom «PyTom» Rothamel.

Downloads of Ren’Py 7.3.3 can be found at:

A full list of changes to Ren’Py can be found at:

A list of changes that may require you to update your game can be found at:

Monologue Mode link

Some visual novels have extended narration, or multiple blocks of dialogue
from the same character. In these cases, typing the name of the character
and the quotes multiple times is somewhat redundant.

To cover these cases, Ren’Py supports monologue mode. When dialogue is inside
triple-quoted strings, Ren’Py will break the dialogue up into blocks at blank
lines. Each block is then used to create its own say statement. Here’s an
example, with three blocks of narration followed by three lines of dialogue:

"""
This is the first line of narration. It's longer than the other two
lines, so it has to wrap.

This is the second line of narration.

This is the third line of narration.
"""

e """
This is the first line of dialogue. It's longer than the other two
lines, so it has to wrap.

This is the second line of dialogue.

This is the third line of dialogue.
"""

While additional clauses like arguments or attributes are allowed, they are
passed to each line in the monologue, which may be less useful.

Default Shader Parts link

renpy.geometry (priority 100)

Variables:

uniform mat4 u_transform;
attribute vec4 a_position;

Vertex shader:

gl_Position = u_transform * a_position;

renpy.blur (priority 200)

Variables:

uniform sampler2D tex0;
attribute vec2 a_tex_coord;
varying vec2 v_tex_coord;
uniform float u_renpy_blur_log2;

Vertex shader:

v_tex_coord = a_tex_coord;

Fragment shader:

gl_FragColor = vec4();
float renpy_blur_norm = ;

for (float i = -5.; i < 1.; i += 1.) {
    float renpy_blur_weight = exp(-0.5 * pow(u_renpy_blur_log2 - i, 2.));
    renpy_blur_norm += renpy_blur_weight;
}

gl_FragColor += renpy_blur_norm * texture2D(tex0, v_tex_coord.xy, );

for (float i = 1.; i < 14.; i += 1.) {

    if (i >= u_renpy_blur_log2 + 5.) {
        break;
    }

    float renpy_blur_weight = exp(-0.5 * pow(u_renpy_blur_log2 - i, 2.));
    gl_FragColor += renpy_blur_weight * texture2D(tex0, v_tex_coord.xy, i);
    renpy_blur_norm += renpy_blur_weight;
}

gl_FragColor /= renpy_blur_norm;

renpy.dissolve (priority 200)

Variables:

uniform float u_lod_bias;
uniform sampler2D tex0;
uniform sampler2D tex1;
uniform float u_renpy_dissolve;
attribute vec2 a_tex_coord;
varying vec2 v_tex_coord;

Vertex shader:

v_tex_coord = a_tex_coord;

Fragment shader:

vec4 color0 = texture2D(tex0, v_tex_coord.st, u_lod_bias);
vec4 color1 = texture2D(tex1, v_tex_coord.st, u_lod_bias);

gl_FragColor = mix(color0, color1, u_renpy_dissolve);

renpy.imagedissolve (priority 200)

Variables:

uniform float u_lod_bias;
uniform sampler2D tex0;
uniform sampler2D tex1;
uniform sampler2D tex2;
uniform float u_renpy_dissolve_offset;
uniform float u_renpy_dissolve_multiplier;
attribute vec2 a_tex_coord;
varying vec2 v_tex_coord;

Vertex shader:

v_tex_coord = a_tex_coord;

Fragment shader:

vec4 color0 = texture2D(tex0, v_tex_coord.st, u_lod_bias);
vec4 color1 = texture2D(tex1, v_tex_coord.st, u_lod_bias);
vec4 color2 = texture2D(tex2, v_tex_coord.st, u_lod_bias);

float a = clamp((color0.a + u_renpy_dissolve_offset) * u_renpy_dissolve_multiplier, 0.0, 1.0);
gl_FragColor = mix(color1, color2, a);

Variables:

uniform vec4 u_renpy_solid_color;

Fragment shader:

gl_FragColor = u_renpy_solid_color;

renpy.texture (priority 200)

Variables:

uniform float u_lod_bias;
uniform sampler2D tex0;
attribute vec2 a_tex_coord;
varying vec2 v_tex_coord;

Vertex shader:

v_tex_coord = a_tex_coord;

Fragment shader:

gl_FragColor = texture2D(tex0, v_tex_coord.xy, u_lod_bias);

renpy.matrixcolor (priority 400)

Variables:

uniform mat4 u_renpy_matrixcolor;

Fragment shader:

gl_FragColor = u_renpy_matrixcolor * gl_FragColor;

renpy.alpha (priority 500)

Variables:

uniform float u_renpy_alpha;
uniform float u_renpy_over;

Fragment shader:

gl_FragColor = gl_FragColor * vec4(u_renpy_alpha, u_renpy_alpha, u_renpy_alpha, u_renpy_alpha * u_renpy_over);

Music and Sound link

Most Ren’Py games play music in the background. Music is played with the
statement. The play music statement takes a filename that
is interpreted as an audio file to play. Audio filenames are interpreted
relative to the game directory. Audio files should be in opus, ogg vorbis,
or mp3 format.

For example:

    play music "audio/illurock.ogg"

When changing music, one can supply a and a clause, which
are used to fade out the old music and fade in the new music.

    play music "audio/illurock.ogg" fadeout 1.0 fadein 1.0

The statement plays an audio file after the current file
finishes playing.

    queue music "audio/next_track.opus"

Music can be stopped with the statement, which can also
optionally take a fadeout clause.

    stop music

Sound effects can be played with the statement. Unlike music, sound
effects do not loop.

    play sound "audio/effect.ogg"

When a filename is in the «game/audio» directory, and the name without the
file extension can be used as a Python variable (that is, it begins with
a letter, and contains only letters, numbers, and underscores), it is possible
to play that file without using quotes.

For example, if «game/audio/illurock.ogg» exists, we can write:

    play music illurock

Music Room link

A music room is a screen that allows the user to select and play music
tracks from the game. These tracks may start off locked when the user
first begins playing a particular game, and will be unlocked as the
user listens to the music while playing the game.

A music room is managed by an instance of the MusicRoom class. There
can be more than one MusicRoom instance in a game, allowing a game to
have multiple music rooms. Creating a music room consists of the
following four steps:

  1. Create an instance of MusicRoom. The MusicRoom constructor takes
    parameters to control the channel on which music is played back,
    and how long it takes to fade music out and back in.

  2. Add music files to the instance.

  3. Create a screen that uses the MusicRoom instance to create actions
    for buttons, imagebuttons, or hotspots. These actions can pick a
    track, the next or previous track, or stop and start the music.

    Note that the actions used are members of a MusicRoom instance,
    so if the MusicRoom instance is named , then
    is how you’d use the play action.

  4. Add the music room screen to the main menu, or an extras menu.

Here’s an example:

init python

    # Step 1. Create a MusicRoom instance.
    mr = MusicRoom(fadeout=1.0)

    # Step 2. Add music files.
    mr.add("track1.ogg", always_unlocked=True)
    mr.add("track2.ogg")
    mr.add("track3.ogg")


# Step 3. Create the music room screen.
screen music_room

    tag menu

    frame
        has vbox

        # The buttons that play each track.
        textbutton "Track 1" action mr.Play("track1.ogg")
        textbutton "Track 2" action mr.Play("track2.ogg")
        textbutton "Track 3" action mr.Play("track3.ogg")

        null height 20

        # Buttons that let us advance tracks.
        textbutton "Next" action mr.Next()
        textbutton "Previous" action mr.Previous()

        null height 20

        # The button that lets the user exit the music room.
        textbutton "Main Menu" action ShowMenu("main_menu")

    # Start the music playing on entry to the music room.
    on "replace" action mr.Play()

    # Restore the main menu music upon leaving.
    on "replaced" action Play("music", "track1.ogg")

Step 4 will vary based on how your game is structured, but one way of
accomplishing it is to add the following line:

textbutton "Music Room" action ShowMenu("music_room")

to the main menu screen.

Using the function, especially
, it’s possible to include a volume
slider on the music screen.

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *