text stringlengths 0 721 |
|---|
LINE (x1,y1)-(x2,y2), color ' Line |
LINE (x1,y1)-(x2,y2), color, B ' Box outline |
LINE (x1,y1)-(x2,y2), color, BF ' Box filled (FAST — use instead of CLS) |
CIRCLE (cx,cy), radius, color ' Circle outline |
CIRCLE (cx,cy), radius, color, 1 ' Circle filled |
PAINT (x, y), fillColor, borderColor ' Flood fill |
LET c$ = POINT(x, y) ' Read pixel color |
LET col$ = RGB(r, g, b) ' Create color (0–255 each) |
``` |
**Color values:** Every drawing primitive (`PSET`, `LINE`, `CIRCLE`, `PAINT`, `DRAWSTRING`, `LOADSHAPE`) accepts a `color` parameter that is either a palette index 0–15 or an `RGB(r, g, b)` value — mix freely. The `COLOR` text command is the exception: it accepts palette indices 0–15 only, so `COLOR RGB(...)` does **no... |
**Palette (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 |
> Do **not** hand-construct packed RGB integers (e.g. `16711680`). `RGB()` tags its return value internally so it can be told apart from a palette index; a raw integer lacks that tag and will be misread as a palette index. Always use `RGB(r, g, b)`. |
### 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 |
' Use CLS only with console, in graphics screen its slow |
' With graphics screen, prefer LINE BF |
``` |
### Shapes & Images |
```basic |
' Create shape |
' LOADSHAPE and LOADIMAGE return a stable integer handle — never reassigned. |
' SDL2 owns the resource; your code only ever holds this one reference. Use constants. |
LET RECT# = LOADSHAPE("RECTANGLE", w, h, color) ' or "CIRCLE", "TRIANGLE" |
LET IMG_PLAYER# = LOADIMAGE("player.png") ' PNG (alpha) or BMP |
LET IMG_REMOTE# = 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 RECT#, x, y ' Position by center point |
ROTATESHAPE RECT#, angle ' Degrees (absolute) |
SCALESHAPE RECT#, scale ' 1.0 = original size |
DRAWSHAPE RECT# ' Render to buffer |
SHOWSHAPE RECT# / HIDESHAPE RECT# ' Toggle visibility |
REMOVESHAPE RECT# ' Free memory (always clean up) |
``` |
--- |
### Text Rendering (SDL2_ttf.dll required) |
#### DRAWSTRING & LOADFONT |
```basic |
' Default font (Arial) |
DRAWSTRING "Hello!", 100, 200, RGB(255, 255, 255) |
' Load alternative font — becomes the new default |
LOADFONT "comic.ttf", 24 |
DRAWSTRING "Hello!", 100, 200, RGB(255, 255, 255) |
' Reset to Arial |
LOADFONT |
``` |
`DRAWSTRING x, y` positions the top-left of the text. Requires `SDL2_ttf.dll` in the same directory as the interpreter. Prefer this over PRINT, which makes graphic screen easily blinking. |
--- |
## Sound |
```basic |
' LOADSOUND returns a stable integer handle — SDL2 manages the resource. |
' The handle never changes; store it in a constant to protect it from accidental reassignment. |
LET SND_JUMP# = LOADSOUND("jump.wav") ' Load (WAV recommended) |
SOUNDONCE(SND_JUMP#) ' Play once, non-blocking |
SOUNDONCEWAIT(SND_JUMP#) ' Play once, wait for finish |
SOUNDREPEAT(SND_JUMP#) ' Loop continuously |
SOUNDSTOP(SND_JUMP#) ' 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 |
``` |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.