Skip to content

Commit

Permalink
Add thief types
Browse files Browse the repository at this point in the history
  • Loading branch information
flavioribeiro committed Aug 27, 2010
1 parent 2834a78 commit f57e7d6
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 8 deletions.
24 changes: 19 additions & 5 deletions jailbreakerz/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,25 @@

class CustomJump(IntervalAction):

def init(self, position, height, jumps, duration):
def init(self, thief_type=None):

self.position = position
self.height = height
self.duration = duration
self.jumps = jumps
if thief_type == 'fat':
self.position = (500, 0)
self.height = 100
self.duration = 10
self.jumps = 7

elif thief_type == 'small':
self.position = (500, 0)
self.height = 100
self.duration = 10
self.jumps = 7

elif thief_type == 'tall':
self.position = (500, 0)
self.height = 100
self.duration = 10
self.jumps = 7

def start( self ):
self.start_position = self.target.position
Expand All @@ -22,6 +35,7 @@ def update(self, t):
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

def __reversed__(self):
return CustomJump( (-self.position[0],-self.position[1]), self.height, self.jumps, self.duration)
Expand Down
10 changes: 7 additions & 3 deletions jailbreakerz/game.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,18 @@ class FallingThief(Layer):
def __init__(self, *args, **kwargs):
super(FallingThief, self).__init__()

thief_sprites = ['media/imgs/tall_thief.png', 'media/imgs/small_thief.png', 'media/imgs/fat_thief.png']
self.thief = Sprite(random.sample(thief_sprites, 1)[0])
thiefs = {'tall': 'media/imgs/tall_thief.png', \
'small' : 'media/imgs/small_thief.png', \
'fat' : 'media/imgs/fat_thief.png'}

self.thief_type = random.choice(thiefs)
self.thief = Sprite(self.thief_type[1])
self.thief.position = 100, 190
self.add(self.thief)
self.fall()

def fall(self):
action = CustomJump((500,0), 100, 10, 7)
action = CustomJump( self.thief_type[0] )
self.thief.do(action)
pyglet.resource.media('media/sounds/yupi.mp3').play()

Expand Down

0 comments on commit f57e7d6

Please sign in to comment.