Programming Macaw OS
Every program in Macaw OS is a Lua file, from the Calculator to the level editor to the games. You can open any of them in Code to see how it works. Your own programs run the same way. Each gets a window on the desktop and uses the same drawing, sound and 3D calls.
This guide shows you how to write your own. If you've never written a program before, start at the top. If you already know Lua, skip to the page for what you want to make.
Start here
- Your first program shows you how to make a window, draw in it and move something with the keys. It also explains how a program runs and what to do when it goes wrong.
- Make a game builds a small game called Seed Catcher, one step at a time.
What you can make
| Page | What's in it |
|---|---|
| Drawing | Shapes, text, colours, pictures, drawing into pictures, the screen's size and colours |
| Input and sound | The keyboard and mouse, sound effects, notes, and songs from the Music app |
| Game carts | A game in a folder with its sprites, map, sounds and music, and the editors for each |
| 3D | Textured meshes, a camera and lights, and scenes of objects that move, collide and can be clicked |
| The graphics chip | OpenGL-style 3D with matrices, draw calls, lighting and reflecting water |
| Levels | Levels built in Brushwork that you walk round in your own program |
| Apps | Buttons, text boxes and lists, menus, dialogs, drag and drop |
| Files and the system | The disk, what Lua can do here, busy programs, saved passwords, System Extensions |
| Memory | Your program's own memory, with addresses, peek and poke, malloc and free, and the window's picture |
| C | Writing programs in C, with pointers, structs, the C library and Macaw OS's calls |
| Networking | Talking to other people's computers on the Macaw network |
Where to look
- The programs that come with Macaw OS are in
/system/apps. The games are in/games. Each game is a cart folder, so right-click it in Files and choose Show Contents to look inside. - Examples are in
/home/examples. There's Seed Catcher (the game the tutorial builds), Worm (a game written in C), a greeter, a to-do list, a program that shows every UI widget, and a System Extension. - The Read Me on the desktop is the short version of this guide. It lists every call.
- In Terminal,
new mygame.luastarts a program,newcart mygamestarts a cart andnewapp myapp.luastarts an app with buttons.
The machine
| Screen | 640x360 to start with, or 640x480, 800x600 or 1024x768. It shows 256 colours, 8 colours or thousands |
| Sound | 4 effect voices, plus the S16 music chip with 16 voices of synth or recorded instruments |
| Input | Keyboard and mouse |
| Language | Lua 5.4, and C89 (see C) |
| Disk | /system and /games come with Macaw OS and can't be changed. /home is yours |
Macaw OS runs the same programs on Windows, on PowerPC Macs (Mac OS X and Mac OS 9), on the Raspberry Pi and in a web browser. A program can't reach the computer underneath. It only sees the Macaw disk and the Macaw network (and shares the clipboard).