Log In  

Cart #cratesncrushers-1 | 2021-09-07 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA

Version 0.2


  • Ledges (top only).
  • Moving platforms.
  • Crates that can push crates on moving platforms whilst you stand on top.
  • Reads the map as level geometry.
  • The above features can be removed to retrieve tokens.
  • Can probably be optimised.


  • No slopes.
  • 2618 tokens (the raw engine is 1711 but you still need to make a player, enemies, update, etc).
  • First come, first served resolution: You only get 1 collision contact (you have to be creative to get more).


Updated this page and rewrote the engine to use less tokens and be more extendable. Only saved 252 tokens sadly but every little helps.

P#66704 2019-08-15 20:27 ( Edited 2021-09-07 19:35)

Nice work!
I wonder how you handle the collision between sprites. Could you give me some hints please?

P#69359 2019-10-27 15:13
:: st33d

This block of code looks at a part of the map and returns it as a list of objects with an x,y position and a w,h size. It also returns the sprite id. These are treated like the other rectangles you collide with.

--return a table of objects describing tiles on the map
 --ignore: do not return anything with this flag
 --result: a table of results to add to
 function mapobjects(x,y,w,h,ignore,result)
   result,ignore = result or {},ignore or 0
   local xmin, ymin = flr(x/8),flr(y/8)
   -- have to deduct a tiny amount, or we end up looking at a neighbour
   local xmax, ymax = flr((x+w-0.0001)/8),flr((y+h-0.0001)/8)
   local rxmin,rymin,rxmax,rymax = blokmap.x,blokmap.y,blokmap.x+blokmap.w-1,blokmap.y+blokmap.h-1
   for c=xmin,xmax do
     for r=ymin,ymax do
       --bounds check
       if c<rxmin or r<rymin or c>rxmax or r>rymax then
         add(result, {x=c*8,y=r*8,w=8,h=8,flag=f_outside,sp=0})
         local sp=mget(c,r)
         local f = fget(sp)
         if f > 0 and band(f, ignore) == 0 then
           add(result, {x=c*8,y=r*8,w=8,h=8,flag=f,sp=sp})
   return result

So, there is no collision between sprites. There is only collision between rectangles, and the map is scanned for implicit rectangles to collide with. The sprites are all drawn afterwards.

P#69442 2019-10-29 08:21

Thank you for your explanation! Really helpful.

P#69521 2019-10-31 14:01

everyone who sees this: we should make puzzle rooms using this then share them here
IDK why but it would be cool

P#99879 2021-11-09 19:10

[Please log in to post a comment]

Follow Lexaloffle:        
Generated 2022-01-16 22:02:42 | 0.015s | Q:17