text
stringlengths
0
275
**Color palette (COLOR command, 0–15):** 0=Black, 1=Blue, 2=Green, 3=Cyan, 4=Red, 5=Magenta, 6=Brown, 7=Lt Gray, 8=Dk Gray, 9=Lt Blue, 10=Lt Green, 11=Lt Cyan, 12=Lt Red, 13=Lt Magenta, 14=Yellow, 15=White
### Screen Control
```basic
SCREENLOCK ON ' Buffer drawing (start frame)
SCREENLOCK OFF ' Present buffer (end frame)
VSYNC(TRUE) ' Enable VSync (default, ~60 FPS)
VSYNC(FALSE) ' Disable VSync (benchmarking)
CLS ' Clear screen (slow — prefer LINE BF)
```
### Shapes & Images
```basic
' Create shape
LET id$ = LOADSHAPE("RECTANGLE", w, h, color) ' or "CIRCLE", "TRIANGLE"
LET img$ = LOADIMAGE("player.png") ' PNG (alpha) or BMP
LET img$ = LOADIMAGE("https://example.com/a.png") ' Download + load
' Sprite sheet — sprites indexed 1-based
DIM sprites$
LOADSHEET sprites$, 128, 128, "sheet.png" ' tileW, tileH, file
MOVESHAPE sprites$(1), x, y ' sprites$(1) = first sprite
' Transform
MOVESHAPE id$, x, y ' Position by center point
ROTATESHAPE id$, angle ' Degrees (absolute)
SCALESHAPE id$, scale ' 1.0 = original size
DRAWSHAPE id$ ' Render to buffer
SHOWSHAPE id$ / HIDESHAPE id$ ' Toggle visibility
REMOVESHAPE id$ ' Free memory (always clean up)
```
---
## Sound
```basic
LET snd$ = LOADSOUND("jump.wav") ' Load (WAV recommended)
SOUNDONCE(snd$) ' Play once, non-blocking
SOUNDONCEWAIT(snd$) ' Play once, wait for finish
SOUNDREPEAT(snd$) ' Loop continuously
SOUNDSTOP(snd$) ' Stop specific sound
SOUNDSTOPALL ' Stop all sounds
```
Load all sounds at startup. Call `SOUNDSTOPALL` before `END`.
---
## File I/O
```basic
LET data$ = FileRead("file.txt") ' Read as string
DIM cfg$ : LET cfg$ = FileRead("settings.txt") ' Read as key=value array
FileWrite "save.txt", data$ ' Create/overwrite
FileAppend "log.txt", entry$ ' Append
LET ok$ = FileExists("file.txt") ' 1=exists, 0=not
FileDelete "temp.dat" ' Delete file
```
**key=value parsing:** When `FileRead` assigns to a `DIM`'d array, lines `key=value` become `arr$("key")`. Lines starting with `#` are comments. Perfect for `.env` files.
```basic
DIM env$
LET env$ = FileRead(".env")
LET API_KEY# = env$("OPENAI_API_KEY")
```
**Paths:** Use `/` or `\\` — never single `\` (it's an escape char). Relative paths are from `ROOT#`.
**FileWrite with array** saves in key=value format (round-trips with FileRead).
---
## Network
```basic
LET res$ = HTTPGET("https://api.example.com/data")
LET res$ = HTTPPOST("https://api.example.com/submit", "{""key"":""val""}")
' With headers (optional last parameter)
DIM headers$
headers$("Authorization") = "Bearer mytoken"
headers$("Content-Type") = "application/json"
LET res$ = HTTPGET("https://api.example.com/data", headers$)
LET res$ = HTTPPOST("https://api.example.com/data", body$, headers$)
```
---
## Arrays & JSON
Nested JSON maps to comma-separated keys: `data$("player,name")`, `data$("skills,0")`
```basic
' Array → JSON string
LET json$ = ASJSON(arr$)
' JSON string → array (returns element count)
DIM data$
LET count$ = ASARRAY(data$, json$)