Log In  


I’ve seen many games with maps (in the editor) that are different from the game when I press play. I think it’s some kind of compression. How is this done? How do they place enemies, items, and other things on the map?



To display the map on the screen, you can use map() in the _draw() function. But I assume what you mean is how: things are placed in the map editor, but once the game is started, they behave like things, like coins or enemies. mget(x, y) returns a Sprite number of the x, y tile in the editor.

--this will check if tile 0,0 is sprite 1

if mget(0,0)==1 then
 do_stuff()
end

If you want to spawn coins only on the first screen, when you place them in the editor,
You need to go through all tile positions and check if there is a coin-sprite tile. If so, then
remove the coin by using mset(x, y, 0) and spawn a coin as an object at x, y.

for x=0,15 do
 for y=0,15 do

   if mget(x,y)==coin_sp then
    spawn_coin(x,y)
    mset(x,y,0)
   end

 end
end

I hope I answered your question. You can always check the manual or the wiki, there is also an active Discord server.


I'm guessing they're talking more about PX9 compression, which you can read about here: https://www.lexaloffle.com/bbs/?tid=34058

Some carts, like Celeste Classic 2, have what looks like random noisy pixels on the second half of the spritesheet (and map). It then uses functions to decompress this into usable data.



[Please log in to post a comment]