I'm working on a farming simulator game. In the _init() function it should randomly generate the pattern on the grass tile and then randomly place the grass tile on the map (replacing any empty tiles.) However, a strange bug is occurring where some map tiles are corrupt. Can somebody explain what's going on? Use arrow keys to move around.
![](/gfx/set_like0.png)
![](/gfx/top_drop.png)
![](/media/82211/7_realshadowcaster.png)
Pico-8 has 256 8x8 sprites, and and 64lines times 128 colums map...
Except the sprites 129-255 and the bottom 32 lines of the map share the same space in memory.
Since you seem to want to use the 64 lines of the map, you should limit yourself to using sprites in the safe 0-127 range. Otherwise, changing the map in lines 64 to 127 will corrupt sprites in the 128-255 range.
A simple way so "see" this is to look in the editor the supposedly empty bottom half of the map.
You can somewhat recognize the sprites that are 128 and after.
Edit :
You are in the very comfortable situation that the entirety of the map is generated by code.
This means that you can use all 256 tiles for your sprite, and just have to tell pico-8 to use the upper memory for the map instead of the normal one that overlaps with the sprite data.
in _init
poke(0x5f56,128)
to set the map address to 0x8000
This also means you get to choose your map width up to 256 (default is 128):
poke(0x5f57,200) for example for a 200 tiles wide map.
The map total size is 4 times the standard 64l 128c one.
[Please log in to post a comment]