Files
prosperon/docs/quickstart.md
John Alanbrook 83b798e365 Add Hugo website and rewrite docs to match current engine
New Hugo site in website/ with prosperon.dev theme (blue/gold/castle
aesthetic), docs sidebar navigation, and content pages. Rewrote all
doc files to align with the actual codebase: compositor+film2d
rendering, use() modules (no global prosperon object), Pit language,
script+JSON entity model. Added entities.md, front matter to all
70+ API docs, and updated API index for current module architecture.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-23 18:09:55 -06:00

2.5 KiB

title, type
title type
Quickstart docs

Quickstart

This quickstart walks through creating modules, programs, and running examples.

Your First Module

A module (.cm) returns a frozen value — an API, a config, data.

Create hello.cm:

return {
  greet: function(name) {
    return `Hello, ${name}!`
  }
}

Your First Program

A program (.ce) is an entry point. It runs top-to-bottom and can register handlers.

Create hello.ce:

var hello = use('hello')

log.console(hello.greet('Prosperon'))

$receiver(function(msg) {
  if (msg.type == 'ping') {
    send(msg, {type: 'pong'})
  }
})

$delay(_ => $stop(), 0.1)

Modules vs Programs

Modules (.cm) Programs (.ce)
Must return a value Yes No
Return value frozen Yes N/A
Can register handlers No Yes ($receiver)
Can spawn children No Yes ($start)
Cached after first load Yes N/A

Spawning Actors

Programs can spawn other programs as child actors:

$receiver(function(e) {
  if (e.type == 'greet') {
    log.console('Child greeted me')
  }
})

$start(function(info) {
  if (info.type == 'greet') {
    log.console('Spawned child actor')
  }
}, 'hello.ce')

$delay(_ => $stop(), 0.5)

Actor Primitives

Primitive Purpose
$start(callback, path) Spawn a child actor from a program
$receiver(callback) Register a message handler
send(target, message) Send a message to an actor
$delay(callback, seconds) Schedule a one-shot callback
$clock(callback, interval) Schedule a repeating callback
$stop() Terminate the current actor

Module Resolution

use('path') looks for modules in this order:

  1. The current module's directory for path.cm
  2. The mounted roots (the program's directory is mounted) for path.cm
  3. Embedded/native modules if no script file is found

Modules compile to bytecode (.o files) and are cached for fast reloading.

Example Games

Prosperon ships with example games:

  • Pong — two-player paddle game
  • Snake — growing snake on a grid
  • Tetris — falling block puzzle
  • Chess — full chess with move validation
  • Bunnymark — sprite rendering benchmark

Next Steps