text stringlengths 0 406 |
|---|
player$("score") = 9999 |
player$("address,city") = "New York" |
[main] |
LET json$ = ASJSON(player$) |
PRINT FN ProcessPlayer$(json$) |
END |
``` |
**Notes:** |
- The function receives a full independent copy — changes inside do not affect the original array |
- Nested keys work normally: `arr$("address,city")` etc. |
- Overhead is similar to copying an array manually; acceptable for most use cases |
--- |
## Program Structure |
```basic |
' ---- 1. FUNCTIONS (or INCLUDE "functions.bas") ---- |
DEF FN Clamp$(v$, lo$, hi$) |
IF v$ < lo$ THEN RETURN lo$ |
IF v$ > hi$ THEN RETURN hi$ |
RETURN v$ |
END DEF |
' ---- 2. INIT (declare ALL constants & variables here, not inside loops) ---- |
' Performance: variables declared outside loops avoid repeated existence checks. |
[inits] |
LET SCREEN_W# = 640 |
LET SCREEN_H# = 480 |
LET MAX_SPEED# = 5 |
SCREEN 0, SCREEN_W#, SCREEN_H#, "My Game" |
LET x$ = 320 |
LET y$ = 240 |
LET running$ = TRUE |
' ---- 3. MAIN LOOP ---- |
[main] |
WHILE running$ |
IF INKEY = KEY_ESC# THEN running$ = FALSE |
GOSUB [sub:update] |
GOSUB [sub:draw] |
SLEEP 16 |
WEND |
SOUNDSTOPALL |
END |
' ---- 4. SUBROUTINES (or INCLUDE "subs.bas") ---- |
[sub:update] |
IF KEYDOWN(KEY_LEFT#) THEN x$ = x$ - MAX_SPEED# |
IF KEYDOWN(KEY_RIGHT#) THEN x$ = x$ + MAX_SPEED# |
RETURN |
[sub:draw] |
SCREENLOCK ON |
LINE (0,0)-(SCREEN_W#, SCREEN_H#), 0, BF |
CIRCLE (x$, y$), 10, RGB(0, 255, 0), 1 |
SCREENLOCK OFF |
RETURN |
``` |
**Key conventions:** |
- Variables: `camelCase$` | Constants: `UPPER_SNAKE_CASE#` | Functions: `PascalCase$` |
- Labels: `[gameLoop]` for jump targets, `[sub:name]` for subroutines |
- Image/sound/shape IDs are stable integer handles — **always** store as constants: `LET MY_IMG# = LOADIMAGE("x.png")` — never use `$` variables for these |
- Group many IDs → use arrays: `DIM sprites$` / `sprites$("player") = LOADIMAGE(...)` — but prefer named constants when count is small |
--- |
## Performance Tips |
- `LINE (0,0)-(W,H), 0, BF` to clear — much faster than `CLS` |
- Always wrap draw code in `SCREENLOCK ON` / `SCREENLOCK OFF` |
- Store `RGB()` results in constants/variables — don't call RGB in hot loops |
- Declare all variables in `[inits]`, not inside loops or subroutines |
- Use `FastTrig` for any loop calling trig hundreds of times per frame |
- `SLEEP 16` in game loop → ~60 FPS |
--- |
## IDE Features (v1.3) |
### New File Template |
When the IDE opens with no file (or a new file), this template is auto-inserted: |
```basic |
' BazzBasic version 1.3 |
' https://ekbass.github.io/BazzBasic/ |
``` |
### Beginner's Guide |
- **IDE:** Menu → **Help** → **Beginner's Guide** — opens `https://github.com/EkBass/BazzBasic-Beginners-Guide/releases` in default browser |
- **CLI:** `bazzbasic.exe -guide` or `bazzbasic.exe -help` — prints URL to terminal |
### Check for Updates |
- **IDE:** Menu → **Help** → **Check for updated...** — IDE reports if a newer version is available |
- **CLI:** `bazzbasic.exe -checkupdate` |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.