language tutorial
Donate ๐ŸŽ“ For Teachers Safe by Design ๐Ÿ›  Open the Studio

LANGUAGE TUTORIAL

Every command in the Arcadia language, with a tiny example for each. Read top to bottom for a walkthrough, or jump in via the table of contents. Snippets here are reference fragments โ€” paste any of them into the Studio to see them run.

The fastest way to learn is to try things. The Studio gives you the editor, the canvas, and instant compile errors that point at the line that confused it.

๐Ÿ›  Open the Studio

Your first game

Every Arcadia program starts with a title and a stage. The stage is the playfield in pixels. Background color is optional โ€” leave it off for plain black.

game "Hello Arcade"
stage 800 by 600 color space
spawn ship at 400, 300

That's a runnable game. It draws a stationary rocket in the middle of an 800ร—600 stage on a deep-space background.

Spawning things

The general form is spawn KIND at X, Y with optional size W by H and a moving clause.

spawn ship at 400, 520
spawn coin at 300, 200 size 40 by 40
spawn asteroid at 700, 100 moving down 180

Velocity can be any expression, including two components:

spawn bullet at 400, 500 moving 500 * cos of angle, 500 * sin of angle

There is no per-instance bookkeeping. Multiple instances of the same kind share state when you assign with set x of KIND to ... โ€” that broadcasts to all of them.

The 22 roles

A kind is what a thing does: ships fly, coins get collected, bullets fly forward, baskets catch. Pick the role that matches behavior โ€” visuals are separate (see looks).

ship ufo alien asteroid ball paddle block platform bullet coin star heart gem bomb ghost frog bird fish car hero basket balloon

The 50 sprites

Sprites are what a thing looks like. Apply one to a kind and every instance of that kind, now and later, takes that appearance. Pure visual โ€” physics and collision are unchanged.

ship looks like rocket
coin looks like sun
ball looks like planet

The 50 looks are a closed set. Open the Studio's sprite picker for a visual grid, or pick from this list:

rocket ufo plane car boat frog alien robot ghost monster basketball soccer baseball tennis football coin gem star heart key bomb fire skull bolt target basket brick tree planet sun train balloon cat dog fish owl butterfly flower mushroom leaf cloud moon apple donut pizza cake book crown music lightbulb

Movement

The moving clause sets velocity at spawn time. The directional short forms are friendlier when one component is zero.

spawn asteroid at 400, -40 moving down 180
spawn ufo at -50, 120 moving right 220
spawn ball at 400, 300 moving 240, -180

Velocity can be changed at runtime with set xspeed of KIND to EXPR and set yspeed of KIND to EXPR.

Rotation

Every spawned thing has an angle in degrees, defaulting to 0. Set it to spin a sprite at draw time:

set angle of paddle to 45
set angle of bullet to angle of bullet + 6

Rotation is visual only โ€” collisions stay axis-aligned to keep the physics predictable. Read it back like any other property: angle of KIND.

Physics & containment

Three independent properties any kind can take on:

ball bounces off walls
keep ship on stage
balloon feels gravity
star wraps around stage

bounces off walls is all-or-nothing โ€” top, bottom, left and right all rebound. For an asymmetric container (e.g. pinball with an open floor), write the rebounds yourself inside every frame:

every frame
  if x of ball < 12 then set xspeed of ball to abs of xspeed of ball
  if x of ball > 788 then set xspeed of ball to -1 * abs of xspeed of ball
  if y of ball < 12 then set yspeed of ball to abs of yspeed of ball
end

Keyboard input

The fastest way to control a player kind is the arrow-keys helper:

control ship with arrows speed 320

For finer control or non-arrow keys, listen for events:

when space is pressed
  spawn bullet at x of ship, y of ship - 20 moving up 600
end

when left is held
  set xspeed of paddle to -340
end

Valid keys: left, right, up, down, space. There is no is released. For charge-and-release patterns, use a different key for "charge" and "fire".

Time & loops

Three time blocks. They all read like English.

every 0.7 seconds
  spawn asteroid at random between 30 and 770, -40 moving down 180
end

every frame
  add 1 to dist
end

after 5 seconds
  say "warming up..."
end

every frame blocks accumulate โ€” you can have several, and the compiler appends each to the main tick. Useful for keeping "physics" and "win check" in separate readable blocks.

Collisions & events

When two kinds touch, the when A hits B block fires. Inside it, it refers to the A-instance and other refers to the B-instance.

when ship hits coin
  vanish other
  add 1 to score
  play sound coin
end

when ship hits asteroid
  explode it
  game over
end

Leaving the stage is its own event:

when bullet leaves stage
  vanish it
end

Counters, score, lives

Declare your own counters with an initial value:

counter timer = 30
counter combo = 0

Two assignment forms โ€” the keywords are fixed (to for set / add; from for subtract):

set combo to 0
add 1 to combo
subtract 1 from timer

score and lives are built-in globals. Lives must be set explicitly โ€” the runtime ends the game when lives <= 0, so leaving lives unset and then subtracting will trigger immediate game over.

set lives to 3
add 100 to score

Conditions & math

One-line and block forms of if:

if score >= 1000 then win
if count of coin = 0 then
  say "all clear"
  win
end

Comparisons: < <= = != >= >. Combine with and, or, not.

Math built-ins. Unary ones take one atomic argument โ€” parenthesize compound expressions:

set d to sqrt of (dx * dx + dy * dy)
set bx to 400 + 200 * cos of angle
set by to 300 + 200 * sin of angle
set safe to max of 1 and lives
spawn coin at random between 40 and 760, -20

sin and cos take degrees, not radians. count of KIND returns how many instances of that kind are alive โ€” usable in conditions and arithmetic.

Actions & effects

Make things happen.

vanish other          # silently removes the target
explode it            # explosion VFX + removes the target
sparkle at 400, 300   # non-destructive sparkle effect
play sound coin
say "level 2"

Don't pair explode with a follow-up vanish โ€” the explode already removes the target.

Tricks (reusable bits)

A trick is a named block of statements you can run from multiple places. It's macro-style โ€” no parameters โ€” but excellent for keeping when handlers tidy.

trick give_coin
  add 10 to score
  play sound coin
  sparkle at x of it, y of it
end

when ship hits coin
  vanish other
  do give_coin
end

when ship hits gem
  vanish other
  do give_coin
  add 40 to score
end

Ending the game

Two ways to end a run, both as friendly as they sound:

game over
win

Either stops the simulation and shows the matching banner. Use if to choose when.

Colors, sounds, keys

Stage colors

Use any of these in stage W by H color NAME:

black space midnight navy dusk purple sky forest sunset charcoal ocean lava

Sounds

Use any of these with play sound NAME:

pop boom zap coin jump bounce

Keys

Use these names with when KEY is pressed / held:

left right up down space

You've seen the whole language. The fastest next step is to copy a seed game into the Studio and start changing things โ€” break it, fix it, see what happens. The compiler will tell you when you've confused it, in the same calm voice you've been reading here.

๐Ÿ›  Open the Studio