Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

some things

  • Loading branch information...
commit 02d974888fc4f8582b7fec33412195a6ef7284b0 1 parent 4ab588c
Andrews Medina authored
82 jailbreakerz/actions.py
View
@@ -12,14 +12,13 @@
def collide(a, b):
distance = math.sqrt((a.x-b.x)**2 + (a.y-b.y)**2)
return distance < (a.width/2 + b.width/2)
-
-class ThiefJump(JumpBy):
- def __init__(self, *args, **kwargs):
- super(ThiefJump, self).__init__(*args, **kwargs)
- self.freedom = False
- self.is_dead = False
-
+def collide_on_trampoline(a, b):
+ x_center_a = a.x + (a.width/2)
+ return a.y < 150 and x_center_a > b.x and x_center_a < b.x + b.width
+
+class CustomJump(IntervalAction):
+
def freedom_checking(self):
if not self.freedom and collide(self.target, director.scene.kombi):
score.score_points += 10
@@ -31,20 +30,21 @@ def dead_checking(self):
self.is_dead = True
def saved(self):
- if not self.freedom and collide(self.target, director.scene.catcher):
- pass
- #self.stop()
+ if not self.freedom and collide_on_trampoline(self.target, director.scene.catcher):
+ return True
- def step(self, dt):
- super(ThiefJump, self).step(dt)
- self.saved()
- self.dead_checking()
- self.freedom_checking()
-
-
-class CustomJump(IntervalAction):
+ return False
+
+ #if not self.freedom and collide(self.target, director.scene.catcher):
+ # return True
+
+ #return False
+ #self.stop()
def init(self, thief_type=None):
+
+ self.freedom = False
+ self.is_dead = False
if thief_type == 'fat':
self.position = (500, 0)
@@ -63,24 +63,47 @@ def init(self, thief_type=None):
self.height = 100
self.duration = 15
self.jumps = 3
+
+ self.jumps = 1
+ self.height = 200
+ self.duration = 3
+ self.position = (200, -250)
+
def start( self ):
self.start_position = self.target.position
self.delta = Vector2(*self.position)
+
+ def done(self):
+ return False
def update(self, t):
+ self.dead_checking()
+ self.freedom_checking()
+
+
+ if self.saved():
+ pass
+ # inverte jump ou rejump
- self.target.alive = self.collide( self.target.position, \
- director.scene.catcher.position )
+ 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)
- 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
+ # 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)
@@ -95,11 +118,6 @@ def step(self, dt):
def done(self):
return self._elapsed >= self.duration
- def collide(self, thief_pos, catcher_pos):
- print 'Thief pos: ', thief_pos
- print 'Catcherpos: ', catcher_pos
- return True
-
class CustomMove(Move):
def step(self, dt):
10 jailbreakerz/game.py
View
@@ -18,6 +18,7 @@
import random
import cocos
+
class Game(Scene):
is_event_handler = True
@@ -46,6 +47,7 @@ def load_catcher(self):
self.catcher.do( CustomMove(300, 500) )
self.add(self.catcher)
+
def load_scenario(self):
self.prison = Sprite('media/imgs/prison.png')
self.prison.position = 100,170
@@ -72,10 +74,10 @@ def __init__(self, *args, **kwargs):
self.fall()
def fall(self):
- #action = CustomJump( self.thief_type[0] )
- #self.thief.do(action)
- self.thief.do(ThiefJump((200,-250), 200, 1, 3))
- pyglet.resource.media('media/sounds/yupi.mp3').play()
+ action = CustomJump( self.thief_type[0] )
+ self.thief.do(action)
+ #self.thief.do(ThiefJump((200,-250), 200, 1, 3))
+ #pyglet.resource.media('media/sounds/yupi.mp3').play()
if __name__ == '__main__':
director.init(resizable=False, width=800, height=600)
2  jailbreakerz/jailbreakerz.py
View
@@ -98,7 +98,7 @@ def __init__(self):
sound.player.queue(pyglet.resource.media('media/sounds/fundogame.mp3'))
sound.player.eos_action = 'loop'
- sound.player.play()
+ #sound.player.play()
def on_start(self):
game_scene = game.Game()
Please sign in to comment.
Something went wrong with that request. Please try again.