Permalink
Browse files

Initializing the collision

  • Loading branch information...
1 parent 538af7d commit 0b412e1e718c80328ac9471c9224c3dcce255abe @flavioribeiro flavioribeiro committed Aug 27, 2010
Showing with 18 additions and 5 deletions.
  1. +17 −5 jailbreakerz/actions.py
  2. +1 −0 jailbreakerz/game.py
@@ -31,11 +31,18 @@ def start( self ):
self.delta = Vector2(*self.position)
def update(self, t):
- y = self.height * abs( math.sin( t * math.pi * self.jumps ) )
- y = int(y+self.delta[1] * t)
- x = self.delta[0] * t
- self.target.position = self.start_position + Point2(x,y)
- print self.target.position, ':', director.scene.catcher.position
+
+ self.target.alive = self.collide( self.target.position, \
+ director.scene.catcher.position )
+
+ if self.target.alive:
+ y = self.height * abs( math.sin( t * math.pi * self.jumps ) )
+ y = int(y+self.delta[1] * t)
+ x = self.delta[0] * t
+ self.target.position = self.start_position + Point2(x,y)
+
+ else:
+ self.target_position = self.target_position[0], self.target_position[1]-10
def __reversed__(self):
return CustomJump( (-self.position[0],-self.position[1]), self.height, self.jumps, self.duration)
@@ -50,6 +57,11 @@ def step(self, dt):
def done(self):
return self._elapsed >= self.duration
+ def collide((thief_x, thief_y), (catcher_x, catcher_y)):
+ print 'Thief pos: ', thief_x, thief_y
+ print 'Catcherpos: ', catcher_x, catcher_y
+ return True
+
class CustomMove(Move):
def step(self, dt):
@@ -65,6 +65,7 @@ def __init__(self, *args, **kwargs):
self.thief_type = random.choice(thiefs.items())
self.thief = Sprite(self.thief_type[1])
+ self.thief.alive = True
self.thief.position = 100, 190
self.add(self.thief)
self.fall()

0 comments on commit 0b412e1

Please sign in to comment.