## Screen Control


### SCREEN - Initialize Graphics Mode
Initialize SDL2 graphics window with specified resolution and title.

```vb
SCREEN mode                      ' Standard BASIC mode
SCREEN 0, width, height          ' Custom resolution
SCREEN 0, width, height, "Title" ' Custom resolution with window title
```

### Standard BASIC Modes
| Mode | Resolution | Description |
|------|-----------|-------------|
| 0 | 640×400 | Text emulation mode |
| 1 | 320×200 | Low resolution |
| 2 | 640×350 | Medium resolution |
| 7 | 320×200 | VGA low-res |
| 9 | 640×350 | EGA enhanced |
| 12 | 640×480 | VGA standard (recommended) |
| 13 | 320×200 | MCGA mode |


#### Examples
```vb
SCREEN 12                        ' 640×480 VGA mode
SCREEN 0, 800, 600               ' 800×600 custom size
SCREEN 0, 1024, 768, "My Game"   ' 1024×768 with custom title
```


### CLS
Clear entire screen to background color.  
**Note:** See performance tips for graphics
```vb
CLS                 ' Clear screen
COLOR 0, 1          ' Set blue background
CLS                 ' Clear to blue
```


### FULLSCREEN
Toggle fullscreen mode (borderless window).
**Note:** Fullscreen is only supported in graphics modes (not console mode).
```vb
SCREEN 0, 640, 480, "My title"
FULLSCREEN TRUE   ' borderless fullscreen on
' ...
FULLSCREEN FALSE  ' Windowed mode
```


### LOCATE
Move text cursor to specified row and column (1-based).
```vb
LOCATE row, column

LOCATE 10, 20       ' Row 10, Column 20
PRINT "Centered"

LOCATE 1, 1         ' Top-left corner
PRINT "Header"
```
**Note:**
- In graphics mode, character positions are based on 8×8 pixel font cells.
- While PRINT works, it is recommended to use DRAWSTRING since PRINT can make graphic screen to blink if FPS rate is high.


### COLOR
Set foreground (text) and background colors. Accepts palette indices 0–15 only — for full RGB on graphics primitives, use `RGB()` or a built-in color constant like `RED#` with `LINE`, `CIRCLE`, etc. instead.
```vb
COLOR foreground, background

COLOR 14, 1         ' Yellow text on blue background
PRINT "Warning!"

COLOR 15, 0         ' White on black (default)
```

### Color Palette (0-15)

| Value | Color | Value | Color |
|-------|-------|-------|-------|
| 0 | Black | 8 | Dark Gray |
| 1 | Blue | 9 | Light Blue |
| 2 | Green | 10 | Light Green |
| 3 | Cyan | 11 | Light Cyan |
| 4 | Red | 12 | Light Red |
| 5 | Magenta | 13 | Light Magenta |
| 6 | Brown | 14 | Yellow |
| 7 | Light Gray | 15 | White |

### SCREENLOCK
Control when graphics are displayed to prevent flickering.
```vb
SCREENLOCK ON       ' Lock screen (start buffering)
SCREENLOCK OFF      ' Unlock and display (present buffer)
SCREENLOCK          ' Same as SCREENLOCK ON
```

**Why use SCREENLOCK?**
Without screen locking, each graphics command immediately updates the display, causing visible flickering during animation. SCREENLOCK buffers all drawing commands and displays them at once.

#### Example - Smooth Animation

```vb
[inits]
	' declarations and initialisations before loops etc.
	LET angle$ = 0
	SCREEN 12

[main]
	WHILE INKEY <> 27

		' keep logic and math out of SCREENLOCK ON/OFF
		angle$ = angle$ + 5
		
		' Start buffering. Indents helps with SCREENLOCK ON/OFF
		SCREENLOCK ON
			' clear with LINE...BF
			 LINE (0, 0)-(640, 480), 0, BF

			' Draw multiple shapes
			LINE (100,100)-(200,200), 15
			CIRCLE (320, 240), 50, 12
		SCREENLOCK OFF          ' Display all at once
		SLEEP 16                ' ~60 FPS
	WEND
END
```

### VSYNC
Control vertical synchronization (VSync) to limit or maximize frame rate.

```vb
VSYNC(TRUE)         ' Enable VSync (default)
VSYNC(FALSE)        ' Disable VSync
```

**Parameters:**
- `TRUE` or any non-zero value - Enable VSync
- `FALSE` or `0` - Disable VSync

**What is VSync?**

VSync synchronizes frame rendering with your monitor's refresh rate (typically 60Hz = 60 FPS). This prevents screen tearing (horizontal lines during fast motion) but limits maximum frame rate.

**When to use:**
- `VSYNC(TRUE)` - Normal gameplay (smoother, no tearing)
- `VSYNC(FALSE)` - Benchmarking, performance testing, FPS measurement

**Important:**
- VSync is **enabled by default** when you call `SCREEN`
- Call `VSYNC` **after** the `SCREEN` command
- If rendering takes longer than 16.67ms (1/60s), VSync will lock to 30 FPS instead of 60 FPS

#### Performance Impact

```vb
' With VSync enabled (default):
' - FPS capped at monitor refresh rate (usually 60)
' - Smooth rendering, no screen tearing
' - If frame takes > 16.67ms → drops to 30 FPS

' With VSync disabled:
' - Unlimited FPS (can exceed 100+ FPS)
' - May show screen tearing
' - Better for performance benchmarking
```

#### Example - FPS Testing

```vb
' BazzBasic version 1.3
' https://ekbass.github.io/BazzBasic/

[inits]
    LET frameCount$     = 0
    LET lastTime$       = TICKS
    LET frameCount$     = 0
    LET currentTime$    = 0
    LET fps$

    SCREEN 12
    VSYNC(FALSE)        ' Disable for true FPS measurement
    LET MY_COLOR# = RGB(255, 255, 255)

[main]
    WHILE INKEY <> KEY_ESC#

        ' Calculate FPS
        frameCount$ = frameCount$ + 1
        currentTime$ = TICKS
        
        IF currentTime$ - lastTime$ >= 1000 THEN
            fps$ = frameCount$ / ((currentTime$ - lastTime$) / 1000)
            frameCount$ = 0
            lastTime$ = currentTime$
        ENDIF

        SCREENLOCK ON
            ' clear
            LINE (0, 0)-(640, 480), 0, BF
            ' filled circle
            CIRCLE (320, 240), 50, 12, 1
            ' fps
            DRAWSTRING "FPS: " + STR(INT(fps$)), 0, 0, MY_COLOR#
        SCREENLOCK OFF
    WEND

    VSYNC(TRUE)         ' Restore default before exit
END
```

#### Example - Toggle VSync at Runtime

```vb
' BazzBasic version 1.3
' https://ekbass.github.io/BazzBasic/

[inits]
    SCREEN 12
    LET vSyncStatus$ = TRUE
    VSYNC(vSyncStatus$)
    LET vColor$ = RGB(255, 255, 255)
    LET vString$
    LET key$
    LET running$ = TRUE
[main]
    WHILE running$
        
        IF KEYDOWN(KEY_ESC#) THEN running$ = FALSE
        IF KEYDOWN(KEY_SPACE#) THEN
            vSyncStatus$ = NOT vSyncStatus$
            VSYNC(vSyncStatus$)
            ' Wait until space is released or it gets buffered and in problems
            WHILE KEYDOWN(KEY_SPACE#) : WEND
            IF vSyncStatus$ = TRUE THEN
                vString$ = "VSync: ON "
            ELSE
                vString$ = "VSync: OFF "
            END IF
        END IF
        
        SCREENLOCK ON
            LINE (0,0)-(639,479), 0, BF
            DRAWSTRING vString$, 0, 16, vColor$
        SCREENLOCK OFF
        SLEEP 16
    WEND
END
```

**Troubleshooting:**

If your game runs at 30 FPS instead of 60 FPS with VSync enabled:
1. Your rendering takes > 16.67ms per frame
2. VSync forces wait for next refresh (60 FPS ÷ 2 = 30 FPS)
3. Solutions:
   - Reduce number of rays in raycaster
   - Lower screen resolution
   - Optimize rendering code
   - Use `VSYNC(FALSE)` to test maximum achievable FPS

## Basic Graphics Primitives

### About `color` parameters

Every drawing command in this section (`PSET`, `LINE`, `CIRCLE`, `PAINT`, `DRAWSTRING`, `LOADSHAPE`) accepts a `color` parameter that can be either:

- **A palette index 0–15** — the classic 16-color EGA/VGA palette (`0` = black, `15` = white, etc.)
- **An `RGB(r, g, b)` value** — any of the 16 million colors, each channel `0–255`
- **A built-in color constant** — `BLACK#` … `TRANSPARENT#` are 32-bit ARGB values (since 1.8), e.g. `RED#` = 0xFFFF0000 = RGB(255, 0, 0)

You can mix and match freely:

```vb
PSET (100, 100), 12              ' Palette index 12 = light red
PSET (100, 100), RGB(255, 64, 0) ' Custom orange-red
PSET (100, 100), RED#           ' Built-in constant (since 1.8)
```

The `COLOR` text-mode command is the exception — it only accepts palette indices 0–15.

### PSET - Draw Pixel
Draw a single pixel at coordinates (x, y).
```vb
PSET (x, y), color

PSET (100, 100), 15     ' White pixel
PSET (320, 240), 12     ' Red pixel at center
```

### LINE - Draw Lines and Boxes
Draw lines or filled/unfilled rectangles.
```vb
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
```

Both corners are **inclusive** in all three forms: `(x2, y2)` is drawn as part of the line or box. `LINE (10, 10)-(12, 12), c, BF` fills a 3×3 area. Corners can be given in any order. To cover a 640×480 screen exactly, use `LINE (0, 0)-(639, 479), 0, BF` — coordinates outside the window are clipped, so `(640, 480)` also works.

#### Examples
```vb
LINE (10, 10)-(100, 50), 15             ' White line
LINE (50, 50)-(150, 150), 12, B         ' Red box outline
LINE (200, 100)-(300, 200), 9, BF       ' Blue filled box
```

### CIRCLE - Draw Circle
Draw circle or filled circle at center point.
```vb
CIRCLE (centerX, centerY), radius, color
CIRCLE (centerX, centerY), radius, color, filled

CIRCLE (320, 240), 50, 14               ' Yellow circle outline
CIRCLE (100, 100), 30, 12, 1            ' Red filled circle
```

### PAINT - Fill Area
Flood-fill starting at (x, y), like in QB/FreeBASIC: the contiguous area of the starting pixel's color is painted with `fillColor`, stopping at pixels of `borderColor`. The border color is optional — without it the fill color is used as the border, so the fill stops at any pixel already in the fill color.
```vb
PAINT (x, y), fillColor[, borderColor]

' Draw and fill a box
LINE (100, 100)-(200, 200), 15, B       ' White border
PAINT (150, 150), 12, 15                ' Fill red inside the white border
PAINT (300, 150), 10                    ' Fill green; border = fill color (10)
```

### RGB - Create Color Value
Create custom RGB color (0-255 per channel). The returned value can be used with any drawing command (`PSET`, `LINE`, `CIRCLE`, `PAINT`, `DRAWSTRING`, `LOADSHAPE`) in place of a palette index.
```vb
LET color$ = RGB(red, green, blue)

LET purple$ = RGB(128, 0, 128)
PSET (100, 100), purple$

LET orange$ = RGB(255, 165, 0)
CIRCLE (320, 240), 50, orange$
```

### POINT - Read pixel color from screen
Returns a RGP color value from certain point of the screen.
```vb
LET c$ = POINT(100, 100)
```

### SAVESCREEN - Save the screen as PNG
Saves everything drawn on the graphics screen to a PNG file.

```vb
SCREEN 0, 320, 200
CIRCLE (160, 100), 50, RGB(255, 0, 0), 1
SAVESCREEN "circle.png"
```

- Relative paths resolve against the program's folder (same as `PRG_ROOT#`). The folder must already exist.
- Only `.png` is supported; any other extension is an error.
- An existing file with the same name is overwritten.
- The image has the program's screen size (as set with `SCREEN`), also in fullscreen. It is always fully opaque.
- It saves what has been drawn, including drawing done after `SCREENLOCK ON` that has not been shown yet.
- Requires graphics mode: without `SCREEN`, it stops with `SAVESCREEN: graphics mode not initialized. Use SCREEN first.`

Handy for screenshots, saving generated art, and checking the output of drawing programs (e.g. Rosetta Code tasks) without looking at the window.

### DRAWSTRING & LOADFONT

Render text directly to the SDL2 graphics surface. Requires `SDL2_ttf.dll` in the same directory as the interpreter.

```basic
' Default font (Arial, size 16)
DRAWSTRING "Hello!", 100, 200, RGB(255, 255, 255)

' Load alternative font — becomes the new active font
LOADFONT "myfont.ttf", 24
DRAWSTRING "Hello!", 100, 200, RGB(255, 255, 255)

' Reset to default (Arial, size 16)
LOADFONT
```

`DRAWSTRING` positions text by its **top-left corner**. Prefer it over `PRINT` in graphics mode — `PRINT` bypasses the SDL2 rendering pipeline and causes flickering at higher frame rates.

#### Fonts

SDL2_ttf loads any standard `.ttf` or `.otf` font file. BazzBasic defaults to **Arial** (size 16). To use a different font, call `LOADFONT` with a font filename and point size. The loaded font stays active until you call `LOADFONT` again or reset it.

**Bundling fonts with your program (recommended)**

Copy the `.ttf` file into the same folder as your `.bas` file and reference it by filename:

```basic
LOADFONT "PressStart2P.ttf", 16
DRAWSTRING "GAME OVER", 200, 200, RGB(255, 0, 0)
```

This makes your program portable and not dependent on the fonts installed on the user's system. Free fonts are widely available — [Google Fonts](https://fonts.google.com) offers hundreds under the OFL open-source licence.

**Using Windows system fonts**

You can also reference fonts already installed on Windows by full path:

```basic
LOADFONT "C:\\Windows\\Fonts\\consola.ttf", 14   ' Consolas (monospace)
LOADFONT "C:\\Windows\\Fonts\\times.ttf", 18     ' Times New Roman
```

Note: this works only on Windows and only if the font is installed — not recommended for distributed programs.

#### Font sizes

The size parameter is a point size — any positive integer is valid:

| Use | Size |
|-----|------|
| Small UI / HUD text | 12–14 |
| Normal text | 16–20 |
| Subheadings | 24–32 |
| Titles / headings | 48–64 |
| Splash screens | 72–96 |

## Shape System (Sprites)

### LOADSHAPE - Create Shape

Create or load a new shape and return its ID.
```vb
id$ = LOADSHAPE(type$, width, height, color)
```

**Shape types:**
- `"RECTANGLE"` - Rectangle shape
- `"CIRCLE"` - Circle shape  
- `"TRIANGLE"` - Triangle shape

#### Examples

```vb
LET SQUARE# = LOADSHAPE("RECTANGLE", 50, 50, RGB(255, 0, 0))
LET BALL#   = LOADSHAPE("CIRCLE", 40, 40, RGB(0, 255, 0))
LET ARROW#  = LOADSHAPE("TRIANGLE", 30, 40, RGB(0, 0, 255))
```

### LOADSHEET - Load Sprite Sheet
Reads an image file and splits it into sprites according to the specification. The original image size must be divisible by the given size parameters

- Relative paths resolve against the program's folder (same as `PRG_ROOT#`), e.g. `"assets/sheet.png"` works no matter where you launch from. Absolute paths are used as-is.
- A missing or unloadable file halts the program with an `Error at line N: ...` message (`File not found: <path>`), exit code 1.
```vb
' BazzBasic version 1.3
' https://ekbass.github.io/BazzBasic/

' ============================================
' LOADSHEET demo: countdown 9 -> 0
' sheet_numbers.png: 640x256, 128x128 sprites
' ============================================

[inits]
	' Center position for a 128x128 sprite on 640x480 screen
	LET x# = 256
	LET y# = 176
	DIM sprites$

	SCREEN 0, 640, 480, "Countdown!"
	LOADSHEET sprites$, 128, 128, "Examples/images/sheet_numbers.png"

[main]
	' Count down from 9 to 0
	FOR i$ = ROWCOUNT(sprites$()) - 1 TO 0 STEP -1
		SCREENLOCK ON
			LINE (0, 0)-(640, 480), 0, BF
			MOVESHAPE sprites$(i$), x#, y#
			DRAWSHAPE sprites$(i$)
		SCREENLOCK OFF
		SLEEP 500
	NEXT
END
```

### MOVESHAPE - Position Shape

Move shape to absolute screen position.

```vb
MOVESHAPE ID#, x, y
```

**Anchor point depends on shape type:**
- `LOADSHAPE` primitives (`RECTANGLE`, `CIRCLE`, `TRIANGLE`) are positioned by their **center point** — `x, y` is the middle of the shape.
- `LOADIMAGE` images are positioned by their **top-left point** — see [Image Transformations](#image-transformations) below.

### ROTATESHAPE - Rotate Shape

Rotate shape to specified angle in degrees.

```vb
ROTATESHAPE id$, angle

ROTATESHAPE SQUARE#, 45         ' 45 degrees
ROTATESHAPE ARROW#, 180         ' Upside down
ROTATESHAPE ARROW#, 270         ' 90 degrees counter-clockwise
```

**Note:** Rotation is absolute, not cumulative. To spin continuously:

```vb
DIM angle$
LET angle$ = 0

WHILE 1
    angle$ = angle$ + 5
    IF angle$ >= 360 THEN
        angle$ = 0
    ENDIF
    ROTATESHAPE SQUARE#, angle$
    SLEEP 16
WEND
```

### SCALESHAPE - Scale Shape Size

Scale shape by multiplier (1.0 = original size).

```vb
SCALESHAPE id$, scale

SCALESHAPE BALL#, 0.5           ' Half size
SCALESHAPE SQUARE#, 2.0         ' Double size
SCALESHAPE ARROW#, 1.5          ' 150% size
```

**Pulsing effect:**

```vb
DIM scale$
DIM direction$
LET scale$ = 1
LET direction$ = 0.01

WHILE 1
    scale$ = scale$ + direction$
    
    IF scale$ >= 1.5 OR scale$ <= 0.5 THEN
        direction$ = direction$ * -1
    ENDIF
    
    SCALESHAPE BALL#, scale$
    SLEEP 16
WEND
```

### DRAWSHAPE - Render Shape

Draw shape to screen at current position/rotation/scale.

```vb
DRAWSHAPE SQUARE#

SCREENLOCK ON
	LINE (0, 0)-(640, 480), 0, BF
	DRAWSHAPE SQUARE#
	DRAWSHAPE BALL#
	DRAWSHAPE ARROW#
SCREENLOCK OFF
```

**Important:** Use with SCREENLOCK for smooth rendering!

### SHOWSHAPE / HIDESHAPE - Toggle Visibility

Show or hide shape without removing it.

```vb
SHOWSHAPE id$
HIDESHAPE id$

HIDESHAPE ENEMY#                ' Temporarily hide
' ... do something ...
SHOWSHAPE ENEMY#                ' Show again
```

### REMOVESHAPE - Delete Shape

Permanently remove shape from memory.

```vb
REMOVESHAPE ID#

REMOVESHAPE SQUARE#             ' Delete and free memory
```

**Note:** Always remove shapes when done to free memory!

### LOADIMAGE
**Note:** Images can be handled just as shapes

- Relative paths resolve against the program's folder (same as `PRG_ROOT#`), e.g. `"assets/plane.png"` works no matter where you launch from. Absolute paths are used as-is. `http(s)://` URLs are also accepted (downloaded into the program's folder first — see below).
- A missing or unloadable file halts the program with `Error at line N: Failed to load image: File not found: <path>` (exit code 1).
```vb
[inits]
	SCREEN 12
	LET SPRITE# = LOADIMAGE("temp.bmp")

	MOVESHAPE SPRITE#, 320, 240
	ROTATESHAPE SPRITE#, 45      ' Rotate 45
	SCALESHAPE SPRITE#, 2.0      ' Scale by 2

[main]
	SCREENLOCK ON
		DRAWSHAPE SPRITE#
	SCREENLOCK OFF
	SLEEP 3000
	REMOVESHAPE SPRITE#          ' Free mem
END
```

#### LOADIMAGE with url
```vb
LET SPRITE# = LOADIMAGE("https://example.com/sprite.png")
' → downloads "sprite.png" to root of your program
' → sprite$ works just as with normal file load

' to remove or move the downloaded file
SHELL("move sprite.png images\sprite.png")   ' move to subfolder
' or
FILEDELETE "sprite.png"                       ' just delete it
```

## Drawing on Screen

## Complete Examples

### Example 1: Rotating Shapes

[RotatingShapesDemo.bas](https://github.com/EkBass/BazzBasic/blob/main/Examples/RotatingShapesDemo.bas)

### Example 2: Bouncing Ball
[BouncingBall.bas](https://github.com/EkBass/BazzBasic/blob/main/Examples/BouncingBall.bas)


## Performance Tips

1. **Always use SCREENLOCK for animation:**
   ```vb
   WHILE 1
   	' Math and logic here
   		
		SCREENLOCK ON
		' All drawing here
		SCREENLOCK OFF
	
		' Delay here
       SLEEP 16
   WEND
   ```

2. **Clear only what you need:**
   ```vb
   ' Clear only draw area, not text
   COLOR 0, 0
   LINE (0, 50)-(640, 480), 0, BF
   ```

3. **LINE... BF is much faster than CLS**
   ```vb
	' Filling screen with LINE... BF is faster than CLS
	' CLS works fine with console
    COLOR 0, 0
    LINE (0, 80)-(640, 480), 0, BF
	```


4. **Remove unused shapes:**
   ```vb
   REMOVESHAPE OLD_SHAPE#  ' Free memory
   ```

5. **Use RGB() once, store value:**
   ```vb
   LET MY_COLOR# = RGB(128, 64, 200)
   ' Use MY_COLOR# multiple times
   ```

6. **Target 60 FPS with SLEEP 16:**
   ```vb
   SLEEP 16  ' ~60 FPS (1000ms / 60 ≈ 16ms)
   ```


---

## Image Support

### LOADIMAGE Function

Load images as shapes that can be moved, rotated, and scaled.

#### Supported Formats

| Format | Transparency | Notes |
|--------|--------------|-------|
| **PNG** | Full alpha (0-255) | Recommended for sprites |
| **BMP** | None | Legacy support |

#### Usage

```vb
LET ID# = LOADIMAGE("filepath")
```

**Parameters:**
- `filepath` - Path to image file (PNG or BMP)

**Returns:**
- Shape ID string (use with MOVESHAPE, ROTATESHAPE, etc.)

#### Example

```vb
[inits]
	SCREEN 12

	REM Load PNG image with transparency
	LET SPRITE# = LOADIMAGE("player.png")

	REM Position and transform
	MOVESHAPE SPRITE#, 320, 240
	ROTATESHAPE SPRITE#, 45
	SCALESHAPE SPRITE#, 2.0

[main]
	REM Draw
	SCREENLOCK ON
		DRAWSHAPE SPRITE#
	SCREENLOCK OFF

	SLEEP 3000

	REM Cleanup when done
	REMOVESHAPE SPRITE#
END
```

### PNG Transparency (Alpha Channel)

PNG images support full alpha transparency. Each pixel can have an alpha value from 0 to 255:

| Alpha Value | Result |
|-------------|--------|
| 255 | Fully opaque (solid) |
| 128 | 50% transparent |
| 0 | Fully transparent |

Transparency is read directly from the PNG file - no color key needed.

### Image Transformations

Once loaded, images work exactly like other shapes:

```vb
LET IMG# = LOADIMAGE("logo.png")

MOVESHAPE IMG#, x, y           ' Position (top-left point)
ROTATESHAPE IMG#, angle        ' Rotate (degrees)
SCALESHAPE IMG#, scale         ' Scale (1.0 = original size)
SHOWSHAPE IMG#                 ' Make visible
HIDESHAPE IMG#                 ' Make invisible
DRAWSHAPE IMG#                 ' Render to screen
REMOVESHAPE IMG#               ' Delete and free memory
```

### Notes

- Images are positioned by their **top-left point**
- PNG is recommended for all new projects
- Larger images use more memory

## Why Constants, Not Variables?

IDs returned by `LOADIMAGE` are text handles (such as `SHAPE1`). BazzBasic uses them only to point to the correct image resource — they never change during program execution.

Storing them in constants (`#` suffix) communicates this intent clearly:

```basic
LET PISTOL# = LOADIMAGE("pistol.png")
LET GAME_OVER# = LOADIMAGE("gameOver.png")
```

Using a mutable variable (`$` suffix) would work, but it implies the value *could* change — which is misleading and leaves the door open for accidental reassignment bugs.

**The rule of thumb:** if a value is set once and never modified, it belongs in a constant.

---

### When to Use an Array Instead

If your program loads many images at once, individual constants become verbose. In that case, a named array is cleaner and self-documenting:

```basic
DIM images$
	images$("shoot") 		= LOADIMAGE("shoot.png")
	images$("explosion") 	= LOADIMAGE("explosion.png")
	images$("pickup") 		= LOADIMAGE("pickup.png")
```

For larger projects with categorized images, multidimensional string keys scale even better:

```basic
DIM images$
	images$("weapons", "shotgun") 	= LOADIMAGE("shotgun.png")
	images$("weapons", "ak47")    	= LOADIMAGE("ak47.png")
	images$("explosions", "small") 	= LOADIMAGE("explosion_small.png")
	images$("explosions", "large") 	= LOADIMAGE("explosion_large.png")
```

This keeps image assets organized by category and type — easy to extend without renaming anything.