Skip to content

Stage and sound

The stage statements say what should be seen and heard. The engine hands each one to the game, and the game decides what it looks like. This page gives the syntax, and what the classic-vn template does with it; other templates may do something else (in text-rpg, scene sets the illustration).

scene clears the stage and sets a new background:

scene bg station
scene bg station night with fade
scene black

In classic-vn, the words name an image file: scene bg station shows images/bg station.png (or .jpg, .webp), and every character on stage leaves. black and white need no image.

show puts an image on stage, usually a character:

show mila smile
show mila smile at left
show mila surprised
show mila laughing at right with dissolve
  • The first word is the tag. Showing an image with a tag that is already on stage replaces it, so show mila surprised swaps Mila’s expression without moving her.
  • at places it. Without at, a new image goes to the default position and a replaced one keeps its place.
  • In classic-vn, images are found by name like scenes (images/mila smile.png) and stand on the bottom edge. The positions are left, midleft, center, midright and right; add your own in game/config.luau.
  • An image that doesn’t exist yet shows as a labelled gray box, so you can write first and draw later.

hide takes an image off stage by its tag:

hide mila
hide mila with dissolve

with makes a change happen through a transition instead of at once. Put it on the statement that makes the change, and only that change transitions:

scene bg station with fade
show mila smile at left with dissolve

On a line of its own, with transitions everything that changed since the player last clicked, so several changes arrive together:

scene bg platform
show mila smile at left
show theo at right
with dissolve

classic-vn has fade, dissolve, wipeleft, wiperight, wipeup, wipedown and swirl, defined in game/config.luau. A transition can also follow any grayscale image as a mask, darkest parts first; the config shows how.

play music "audio/rain theme.ogg"
play music "audio/station.ogg" fadein 2
play sound "audio/door.ogg"
play sound "audio/clock.ogg" loop
play voice "voice/mila_012.ogg"
stop music fadeout 1.5
stop sound

There are three channels:

Channel Plays Loops by default
music one track at a time; a new one crossfades from the old yes
sound many at once, overlapping no
voice one line at a time no
  • The file is a path from the game’s folder, in quotes. WAV, OGG, MP3 and FLAC work.
  • fadein 2 fades in over two seconds; fadeout 1.5 on stop fades out.
  • loop and noloop override the channel’s default.
  • Saves and rollback remember what music was playing.

These lines are handled by the engine itself, the same in every template.

pause waits for a click; pause 2 waits two seconds. Handy for letting a transition or a sound land:

play sound "audio/thunder.ogg"
pause 1.2
"The lights flickered."

movie plays a video over everything and waits for it. A click, tap, key or gamepad button skips it.

movie "movies/intro.mp4"
"Three years later."

Use MP4 with H.264 video and AAC sound, the one format every system plays. Its sound plays on the music channel, so it stops the music, which stays stopped afterwards. Loading a save or rolling back onto a movie plays it again from the start. Skip mode passes over videos in classic-vn.

To play a video on a sprite, see kulisa.video.

A transform describes movement, and animate plays it on something shown:

transform bob:
y -20 over 0.5 in_out_sine
y 0 over 0.5 in_out_sine
repeat
transform pop:
scale 1.2 rotation 5 over 0.3 out_back
label start:
show kitty happy at left
animate kitty bob
"Kitty bounces on the spot."
animate kitty
"Now she stops."

Each line reaches its values together, over the time you give it, with an optional ease. Without over, they apply at once.

Line Meaning
x 30, y -20 Moves that far from where it stands.
scale 1.2, scale_x, scale_y Times its size.
rotation 15 Turns it, in degrees.
opacity 0.5 How visible it is, from 0 to 1.
pause 1 Waits.
repeat, repeat 3 Last line: loops forever, or that many times.

Eases are the same as for tweens, like out_quad, in_out_sine and out_bounce. Animations are remembered in saves and rollback: a loop starts again, and a one-shot lands where it ended.

Instead of drawing every combination of face and outfit, give a character a folder. In classic-vn:

images/kitty/base.png
images/kitty/face/default.png
images/kitty/face/happy.png
images/kitty/hat/crown.png

show kitty happy crown stacks the base, the happy face and the crown. A layer’s default.png shows when no look is asked for, and folders stack in name order. All the images are the size of the base.

An image can hold the frames of an animation. In classic-vn, name it in game/config.luau:

config.sheets = { ["kitty walk"] = { cols = 4, rows = 2, fps = 8 } }

Then show kitty walk plays images/kitty walk.png. Frames run across, then down.