Permalink
Browse files

Some simple collision handlers

  • Loading branch information...
1 parent f0e2c0e commit f279e872171f1924f05a76275fdc3b64e4a60536 Ross Andrews committed Oct 23, 2012
Showing with 18 additions and 0 deletions.
  1. +8 −0 create_entities.lua
  2. +10 −0 handlers.lua
View
@@ -103,7 +103,15 @@ function methods:makeGoal()
'static')
local gb_shape = ph.newCircleShape(0, 0, SIZE/2*0.9)
+ local goal = ph.newBody(self.world,
+ goal_loc.x*SIZE+SIZE/2,
+ goal_loc.y*SIZE+SIZE/2,
+ 'static')
+ local g_shape = ph.newCircleShape(0, 0, SIZE/2*0.8)
+
+ self.manager:add(goal, g_shape, 'goal')
local _, goal_entity = self.manager:add(goal_blocker, gb_shape, 'goal_blocker')
+
return goal_entity
end
View
@@ -16,6 +16,8 @@ function methods:addHandlers()
self.manager:handler('gem', 'player', take_gem)
self.manager:handler('gem', 'crate', pushback_crate)
+ self.manager:handler('player', 'enemy', kill_player)
+ self.manager:handler('player', 'goal', end_level)
end
------------------------------------------------------------
@@ -42,4 +44,12 @@ function open_goal()
entity_manager:remove(goal)
effect_manager:add(EffectManager.fade(goal.body:getX(), goal.body:getY()))
end
+end
+
+function kill_player(player, enemy)
+ print("Player died")
+end
+
+function end_level(player, goal)
+ print("Next level")
end

0 comments on commit f279e87

Please sign in to comment.