Log In  

Are there any disadvantages to drawing single objects with map() rather than spr()?

I want to make a platformer but the ground landscape will change depending on what falls from the sky and lands.

Normally, for things that fall to the ground I'd draw a sprite but since the thing falling will end up being something the player can walk on, and I want to use flags for ground checking, I thought drawing with map would be a valid solution.

But then I also felt that sounded not so good because maps are there to be backgrounds and stuff, right? Something that's not really moving. And also I'm wondering if mget() will work like I want given the x/y could be outside the normal map cel grid.

I mean, if I did something like this, would that be advisable?

obj={x=40,y=0}

function _update()
   obj.y+=1
end

function _draw()
   map(0,0, obj.x,obj.y, 1,1)
end
P#26327 2016-08-02 11:35 ( Edited 2016-08-02 19:55)

Have you checked the builtin collide.p8 demo?

P#26333 2016-08-02 12:11 ( Edited 2016-08-02 16:11)

I'd assume you want to use the main map space as a sort of scratch pad, storing your falling chunks in an unused portion (or just in tables) and sort of copy-pasting them to the active part, where you could then draw and check them for flags normally.

Probably maintain a separate table/storage area for static (landed) pieces. Use that to clear the active area of the map every update, iterate through a table of falling chunks and mset() them in their current positions.

edit - I want to say map() is the same cost or just a single memory access removed from the sprite drawing. (especially considering the shared sprite/map memory space)

P#26339 2016-08-02 14:09 ( Edited 2016-08-02 18:13)

@tyroney - what you described is what was in my head, I think. An array of all the coordinates for the map drawing, just so I can use mget() stuff for platform checking.

Seemed like a lot just to get mget() to work but that seems like the best way for a platformer. I'll give it a go and see what happens.

P#26341 2016-08-02 15:55 ( Edited 2016-08-02 19:55)

[Please log in to post a comment]