Scena

Tutorials

Each tutorial builds a real script, step by step. For readers who already know basic Python. Em português

Six games from the tutorials: Ships IV (08), Plane III (17), Connect Four (21), Ninja IV (27), Duel (31) and Race (32).
01

First script

Window, shapes, color, visual, sprite, keyboard, click and @when.

02

Catch stars

A bar, @every, a group, collision, destroy and a scoreboard.

03

Geometry

Handles, Anchor, live lines and a midpoint with a compass.

04

UI widgets

Slider, CheckBox, DropDown, Button, Menu and TextInput. Three scripts: the chain with a panel; a drawing with the mouse (Contrail, every); a banner that travels along a track (Track, move_along).

05

Ships

A simple space shooter: a ship, a fleet, shots from both sides — no classes.

Interlude

Groups

What a group can do: a set that keeps itself up to date, one order for all (destroy, move_by), questions (count, empty, nearest) and picking some (filter, count_where, any).

06

Ships II · Classes

Classes and objects: bubbles made from one mold, each with its own speed (setup, on_update, why not __init__); then the space shooter reorganized into classes, with a thruster (Jet).

07

Ships III · Atlas, explosion, lives

The pictures on one sheet (Sheet, frame), an explosion in frames (clip, play), sound and three lives.

08

Ships IV · Shield

A falling gift turns on a shield that wears out: active, @on_change, collision with info and an impact where the laser hit.

09

Formulas

A machine of linked shapes, like a spreadsheet: fields and formulas, brackets × dot (st["x"] × st.x), = × @=, @on_change, @when, unlink and the rules of the reactive system. Not a game.

10

Balls

Balls that bounce off the walls and off each other: resolve, vel, mass, a trail with Tail, camera zoom and a speed bar with @= and Colormap.

11

Interaction

The mouse in one place: click, hover (@hover), the right button, drag, drop on a trash can (@drop_by) and a grid that marks the cell under the mouse (Box, cell_at). At the end, the mouse on the canvas with no object at all (on_mouse_click, double click, wheel). No game: one feature per step.

Interlude

Hooks in the class

Each top-of-file hook inside a class: on_click, on_hover, @every and @leave_playfield for each object, @when(lambda self: …), and an Entity with no drawing that owns its own time.

12

Movement

A ship that goes where you click: place or travel (move_to with time= or speed=), speed up and slow down (ease=), facing forward (face=), the arrival event (on_done=), the handle of the trip (cancel) and a chase every frame (approach).

13

Tracks

A showcase of tracks (Track): ready-made shapes, your own paths, there and back (yoyo), a pendulum (ease), a queue (phase) and the tip that follows the path (face).

14

Orbits

A solar system: planets in orbit, a moon that leaves a trail of dots (History), a pulsing sun (tween) and a probe that points at the nearest planet (nearest, heading).

Interlude

Turn and grow

Turn to and turn by (rotate_to, rotate_by), the angle field and the point that stays still, about=, a box held by two anchors next to a loose one, and the same pair for size (scale_to, scale_by).

15

Plane

A plane between pillars: a sheet made of files with two clips, a control stick with inertia (chase), points, the crash and restarting.

16

Plane II · Depth

Scenery in layers that move at different speeds (parallax), filled forever by Endless; fire on the fall and music.

17

Plane III · Endless Landscape

A landscape that never repeats: random images, trees and houses built by a function (slot.rng) and a layer in front of the plane.

18

Ninja

A platform game: gravity written by hand, the floor that holds (resolve), jumping only with the feet on the floor (touching_sides) and animations from files of different sizes.

19

Ninja II · The world

A world for the ninja: a pit with water, some slack at the ledge (recently), stars, patrolling robots, kunais and three lives.

20

Collision

A lab, no game: the three phases of a touch (@collide, @collide_stay, @collide_exit) and questions on the spot: who is at this point (query_point), in this area (query_circle), and what a line hits first (raycast).

21

Connect Four

A board game: the cells of a grid (Box, grid), a ball you drag and drop into a column (@drag_to), the fall with move_to and the rules in one list per column.

22

Studio · Piano

A piano on the keyboard and the mouse: a single note played at eight pitches (pitch=), keys that light up while the note sounds and an equalizer (audio.spectrum).

23

Studio II · Voice

Sound drives the screen: the microphone records your voice for the piano, a bar linked with @= shows how loud you speak, a star dances on a track (Track) and a clap sets off a sun.

24

Ships V · Chapters and sequences

The enemies get chapters (mode): formation, a dive with a jet, a fleet that arrives in sequence (async) and a boss that arrives, fights and falls in stages.

25

Ships VI · Acts

The game in acts (Act): title, level and game over, restarting with no cleanup code, the high score in st and the level as a sequence with until_empty.

Interlude

Events and processes

A crossing with a traffic light, cars and pedestrians: the frame, the check and the event, the Handle, the async sequence instead of after, the task (run_task) with name=, each pedestrian's mode with until and race, and the owner of each process.

26

Ninja III · The level

A level four times larger than the screen, drawn in the level editor (Level), a camera that follows the ninja with some slack (deadzone, chase) and a background that moves more slowly (pan_response).

Interlude

The level editor

A minigolf course made from scratch in the editor: the level size, the tools and the panel, each kind of piece (polygon, line, ellipse, circle, triangle, track, point) read in code with for item in level_map and make(), the level's track with move_along, an item's box as a Sprite's place, and Copy as code.

27

Ninja IV · Hazards

Planks you can pass under (only=), robots that turn at the ledge (floor_below), a box just for getting hurt (add_hitbox), electric bolts, an elevator and a restart with an act.

28

Ninja V · Sword

Crates only the sword can break: a collision box placed by hand on the pixels of the slash (px_rect), turned on only in the frames of the blade (showing), and a light that makes the ninja invincible, with an aura that blinks at the end.

29

Endless Runner

A robot runs along a track that never ends: Endless builds the ground, the pits and the platforms ahead of the camera and destroys them behind it; the ground's height is a function of x.

30

Spins

A bar that makes bars at its own ends (recursion, step by step, with the call tree) and a point with two spins added together that draws flowers with sine and cosine. Two scripts, no game.

31

Duel

Two players, one arena: ships held on curved rails that turn like a steering wheel, lasers that bounce and curve near a Warp, asteroids, bolts and power-ups that fly to whoever shot.

32

Race

A race seen from above, on a track of tiles cut from a sheet in the editor: the centerline becomes the asphalt and the lap checkpoints, the car drifts, barrels and oil have modes, and the CPU drives through the same half of the car as the keyboard. Two tracks, one program.

33

100 Lines

A piece of light and music in fewer than 100 lines, like the demoscene's intros: hexagons that open, twist and become a tunnel, all made of formulas. Knobs in st, a script of tweens, a screen effect that turns on and off, and a pulse that follows the song's kick drum. No game.

Appendixes

To look up when you need them: the parts of Scena that no game stopped to explain. Each snippet is a short program; change a number and run it again.

A

Debug keys

The Ctrl+Shift keys that show the game from the inside: panel, colliders, tracks, inspection zoom, slow motion, warnings and full screen.

B

Useful commands

Window, full screen, background, colors, random picks, the clock, defaults, values in the console and on screen, key names and volume: what every game uses and no tutorial stopped to explain.

C

Art and sound

Where to download sprites, sounds and fonts, how Scena finds a file by its name (the media folder) and the formats it opens.

D

Vectors and points

Points, offsets and arrows: adding, subtracting, measuring distance and heading, turning and moving at a speed.

E

Helpers

lerp, remap, chase and deadzone: mixing values, changing scale, chasing smoothly and giving a follower some slack.

F

Shapes

Every Scena shape and the ways to put it on screen, side by side: center, corners, two points, foci, regions and the options they all take.

G

Images and hitboxes

The common ways to load images, with figures: one image and its size, one file per frame, a strip (cols=, cell=), several animations (strip), an atlas and SVG drawings; and the shape each image collides with (hitbox_shape, hitbox_scale).