What do you mean by dead game? If you mean exit you could use close().
There is lots of Lua collision detection code available - just google it. For example, this function will detect if two rectangular objects overlap. It returns true if there is a collision, and false otherwise:
-- Collision detection function. -- Checks if a and b overlap. -- w and h are width and height. function CheckCollision(ax1,ay1,aw,ah, bx1,by1,bw,bh) local ax2,ay2,bx2,by2 = ax1 + aw, ay1 + ah, bx1 + bw, by1 + bh return ax1 < bx2 and ax2 > bx1 and ay1 < by2 and ay2 > by1 end
Or implement a state machine and switch screens when the game ends, back to a title screen.