-
-
Notifications
You must be signed in to change notification settings - Fork 559
Using mset() and mget() functions
In it's most basic form, the map is a way of organizing graphics.
You can draw in your sprites in the map editor...but that's only half the story.
There wouldn't be much point if you couldn't read data back from the map.
To do this we use:
mget(cell_x,cell_y)
This takes map coordinates as arguments, and returns the ID number of the sprite drawn in that cell.
In this way we can alter game behaviour based on sprites. Some options include:
collision detection
trip wires
alter player speed based on terrain
damage inflicting tiles
These gameplay mechanics are common in a variety of games.
Another useful thing to do with the map is alter the sprites.
To do that we use:
mset(cell_x,cell_y,sprite_ID)
This takes cell coordinates, and a sprite ID, and places that sprite in that cell.
Some uses for this include:
opening/closing doors
breakable walls
spiked floor traps
Again some very old stand-bys in games.
Often times you'll use both of these together.
one to read the map and the other to modify it.
Let's look at a few examples:
The easiest way to assign properties to sprites is to arrange similar tiles together.
For example:
TIC-80 tiny computer https://tic80.com | Twitter | Telegram | Terms
Built-in Editors
Console
Platform
RAM & VRAM | Display | Palette | Bits per Pixel (BPP) |
.tic
Format | Supported Languages
Other
Tutorials | Code Snippets | Libraries | External Tools | FFT
API
- BDR (0.90)
- BOOT (1.0)
- MENU
- OVR (deprecated)
- SCN (deprecated)
- TIC
- btn & btnp
- circ & circb
- clip
- cls
- elli & ellib (0.90)
- exit
- fget & fset (0.80)
- font
- key & keyp
- line
- map
- memcpy & memset
- mget & mset
- mouse
- music
- peek, peek4
- peek1, peek2 (1.0)
- pix
- pmem
- poke, poke4
- poke1, poke2 (1.0)
- rect & rectb
- reset
- sfx
- spr
- sync
- ttri (1.0)
- time
- trace
- tri & trib (0.90)
- tstamp (0.80)
- vbank (1.0)