Skip to content

Instantly share code, notes, and snippets.

@dimmduh
Created June 14, 2012 13:12
Show Gist options
  • Save dimmduh/2930222 to your computer and use it in GitHub Desktop.
Save dimmduh/2930222 to your computer and use it in GitHub Desktop.
function bullet:enterFrame(e)
if ( self:isOut() ) then
self:destroy();
end
...
self:checkCollision()
end
function bullet:checkCollision()
if (#worms > 0) then
for key, worm in pairs( worms ) do
local distance = utils.getDistance( self.x, self.y, worm.x, worm.y )
if ( distance < (24 * worm.xScale / 2 + self.width) ) then
self:destroy()
worm:kill();
end
end
end
end
function bullet:destroy()
Runtime:removeEventListener("enterFrame", self)
self:removeSelf();
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment