diff options
author | Luiz Irber <luiz.irber@gmail.com> | 2007-11-11 16:16:53 (GMT) |
---|---|---|
committer | Luiz Irber <luiz.irber@gmail.com> | 2007-11-11 16:16:53 (GMT) |
commit | f6febb026f1c0ba6faba25454109706e1121fb4e (patch) | |
tree | c5ce76a594d631ae823a6733b5f3217c88930a17 | |
parent | f1d9d6245ef8ab5d19adde2d52c59a625a30792a (diff) |
V11, 14 horas
-rw-r--r-- | Gambiarra/gambiarra.py | 82 | ||||
-rw-r--r-- | Gambiarra/levels.py | 25 | ||||
-rw-r--r-- | Gambiarra/objects/animals.py | 5 | ||||
-rw-r--r-- | Gambiarra/objects/balls.py | 14 | ||||
-rw-r--r-- | Gambiarra/objects/elastica.py | 3 | ||||
-rw-r--r-- | Gambiarra/objects/esteira.py | 3 | ||||
-rw-r--r-- | Gambiarra/objects/target.py | 3 | ||||
-rw-r--r-- | Gambiarra/objects/things.py | 30 | ||||
-rw-r--r-- | Gambiarra/objects/wall.py | 16 | ||||
-rw-r--r-- | MANIFEST | 3 | ||||
-rw-r--r-- | activity/activity.info | 2 | ||||
-rw-r--r-- | data/snd/cama_elastica.wav | bin | 0 -> 239976 bytes | |||
-rw-r--r-- | data/snd/dummy.wav | bin | 0 -> 39212 bytes | |||
-rw-r--r-- | data/snd/penguin.wav | bin | 0 -> 39212 bytes |
14 files changed, 132 insertions, 54 deletions
diff --git a/Gambiarra/gambiarra.py b/Gambiarra/gambiarra.py index 9c074e0..234ce30 100644 --- a/Gambiarra/gambiarra.py +++ b/Gambiarra/gambiarra.py @@ -41,7 +41,7 @@ def check_collision(sprite_list, wall_list): obj.add(new_objects) for s in sprite_list: - hitbox = obj.rect.inflate(5,5) + """hitbox = obj.rect.inflate(5,5) if hitbox.colliderect(s.rect): if obj.rect.left < s.rect.right: aux = obj.speed[0] @@ -51,66 +51,86 @@ def check_collision(sprite_list, wall_list): if obj.rect.left > s.rect.right : aux = obj.speed[0] obj.speed[0]=s.speed[0] - s.speed[0]=aux + s.speed[0]=aux obj.rect.right = srect.left-1 if obj.rect.bottom > s.rect.top: aux = obj.speed[1] obj.speed[1]=s.speed[1] - s.speed[1]=aux + s.speed[1]=aux obj.rect.bottom = s.rect.top-1 if obj.rect.top < s.rect.bottom: aux = obj.speed[1] obj.speed[1]=s.speed[1] - s.speed[1]=aux + s.speed[1]=aux obj.rect.top = s.rect.bottom+1 - + """ #TODO: verifica colisao de objetos dinamicos pass for w in wall_list: - hitbox = obj.rect.inflate(5,5) - if hitbox.colliderect(w.rect): +# hitbox = obj.rect.inflate(-5,-5) +# if hitbox.colliderect(w.rect): + if obj.rect.colliderect(w.rect): + obj.play() + w.play() if isinstance(w, DownWall): if obj.rect.bottom > w.rect.top: - obj.rect.bottom = w.rect.top - 1 + obj.rect.bottom = w.rect.top - 5 if isinstance(obj,Penguin): obj.speed[1] = 0 else: - obj.speed[1] = -0.7*obj.speed[1] + obj.speed[1] *= -0.75*obj.elasticity/100 #1. a**n + b**n = c**n ? if isinstance(w, UpWall): - if obj.rect.top < w.rect.bottom: - obj.rect.top = w.rect.bottom + 1 - obj.speed[1] = -0.7*obj.speed[1] - + if obj.rect.top <= w.rect.bottom: + obj.rect.top = w.rect.bottom + 5 + obj.speed[1] *= -0.95*obj.elasticity/100 + if isinstance(w, LeftWall): - if obj.rect.left < w.rect.right: - obj.rect.left = w.rect.right + 1 - obj.speed[0] = -0.9*obj.speed[1] + if obj.rect.left <= w.rect.right: + obj.rect.left = w.rect.right + 5 + obj.speed[0] *= -0.95*obj.elasticity/100 if isinstance(w, RightWall): - if obj.rect.right > w.rect.left: - obj.rect.right = w.rect.left - 1 - obj.speed[0] = -0.9*obj.speed[1] + if obj.rect.right >= w.rect.left: + obj.rect.right = w.rect.left - 5 + obj.speed[0] *= -0.95*obj.elasticity/100 if isinstance(w, Esteira): - if (obj.rect.midbottom > w.rect.top and - obj.rect.bottom < w.rect.bottom): - obj.rect.bottom = w.rect.top + if (obj.rect.bottom >= w.rect.top and obj.speed[1] > 0): + obj.rect.bottom = w.rect.top - 5 obj.speed[0] = w.sentido*15 if isinstance(obj,Penguin): obj.speed[1] = 0 else: - obj.speed[1] = -0.7*obj.speed[1] + obj.speed[1] *= -0.75*obj.elasticity/100 if isinstance(w, Elastica): - if (obj.rect.midbottom > w.rect.top and - obj.rect.bottom < w.rect.bottom): - obj.rect.bottom = w.rect.top - obj.speed[1] *= -1.07 + if (obj.rect.bottom >= w.rect.top and obj.speed[1] > 0): + obj.rect.bottom = w.rect.top - 1 + elif (obj.rect.top <= w.rect.bottom): + obj.rect.top = w.rect.bottom + 1 + obj.speed[1] *= -0.99 if isinstance(w, Target): - pass + pass + + if isinstance(w,DownWall) : + if obj.rect.bottom >= w.rect.top: + obj.rect.bottom = w.rect.top - 5 + obj.speed[1] *= -0.75*obj.elasticity/100 + if isinstance(w,UpWall) : + if obj.rect.top <= w.rect.bottom: + obj.rect.top = w.rect.bottom + 5 + obj.speed[1] *= -0.95*obj.elasticity/100 + if isinstance(w,LeftWall) : + if obj.rect.left <= w.rect.right: + obj.rect.left = w.rect.right + 5 + obj.speed[0] *= -0.95*obj.elasticity/100 + if isinstance(w,RightWall) : + if obj.rect.right >= w.rect.left: + obj.rect.right = w.rect.left - 5 + obj.speed[0] *= -0.95*obj.elasticity/100 return new_objects @@ -168,7 +188,10 @@ class Game(object): if obj.mobility: newpos = obj.rect.move((obj.speed[0],obj.speed[1])) obj.rect = newpos - obj.speed[0] *= 0.99 + if not(isinstance(obj,Penguin)): + obj.speed[0] *= 0.99 + if obj.speed[1] <= obj.rect[3]*0.04 and obj.speed[1] > 0: + obj.speed[1] = 0 obj.speed[1] += obj.gravity else: if self.selected_element: @@ -246,6 +269,7 @@ class Game(object): self.selected_element = None def show_congratulations(self): + pygame.mixer.stop() self.congratsSnd.play() self.screen.blit(self.congrats, (600 - self.congrats.get_width()/2, 450 - self.congrats.get_height()/2) ) diff --git a/Gambiarra/levels.py b/Gambiarra/levels.py index b1206d2..b0a031f 100644 --- a/Gambiarra/levels.py +++ b/Gambiarra/levels.py @@ -181,12 +181,29 @@ def init_levels(): level4ObjInPlace = [ BowlingBall((20,20), editable=False), SoccerBall((800, 300),editable=False), - Target((1100, 20), editable=False)] + Target((900, 90), editable=False)] level4ObjToAdd = [ Esteira(), Esteira()] level4Goal = level4ObjInPlace[-1] level4ToGoal = level4ObjInPlace[0] level4HelpImage = pygame.image.load("../data/images/obj-level3.png") + level5ObjInPlace = [ BowlingBall((1000,300), editable=False), + Esteira((1000,500), editable=False), + Target((1100, 650), editable=False)] + level5ObjToAdd = [ Esteira(), Esteira()] + level5Goal = level5ObjInPlace[-1] + level5ToGoal = level5ObjInPlace[0] + level5HelpImage = pygame.image.load("../data/images/obj-level3.png") + + level6ObjInPlace = [ BeachBall((800,50),editable = False), + Elastica((800,400),editable = False), + Elastica((900,200),editable = False), + Target((1070,650),editable = False)] + level6ObjToAdd = [ Esteira(), Esteira() ] + level6Goal = level6ObjInPlace[-1] + level6ToGoal = level6ObjInPlace[0] + level6HelpImage = pygame.image.load("../data/images/obj-level3.png") + level1 = Level( level1ObjInPlace, level1ObjToAdd, level1Goal, level1ToGoal, level1HelpImage) level2 = Level( level2ObjInPlace, level2ObjToAdd, level2Goal, @@ -195,5 +212,9 @@ def init_levels(): level3ToGoal, level3HelpImage) level4 = Level( level4ObjInPlace, level4ObjToAdd, level4Goal, level4ToGoal, level4HelpImage) + level5 = Level( level5ObjInPlace, level5ObjToAdd, level5Goal, + level5ToGoal, level5HelpImage) + level6 = Level( level6ObjInPlace, level6ObjToAdd, level6Goal, + level6ToGoal, level6HelpImage) - return [level1, level2, level3, level4]
\ No newline at end of file + return [level1, level2, level3, level4, level5, level6]
\ No newline at end of file diff --git a/Gambiarra/objects/animals.py b/Gambiarra/objects/animals.py index 148171a..ab65dfb 100644 --- a/Gambiarra/objects/animals.py +++ b/Gambiarra/objects/animals.py @@ -29,6 +29,7 @@ class Penguin(Thing): def __init__(self, initialPosition=None, editable=True): super(Penguin, self).__init__( pygame.image.load(abspath("../data/images/penguin.png")), - editable, initialPosition, elasticity = 100, mobility = True, - gravity = 1) + editable, pygame.mixer.Sound(abspath("../data/snd/penguin.wav")), + initialPosition, elasticity = 100, mobility = True, + gravity = 5) self.speed=[5,0] diff --git a/Gambiarra/objects/balls.py b/Gambiarra/objects/balls.py index 1e40f92..cff55c6 100644 --- a/Gambiarra/objects/balls.py +++ b/Gambiarra/objects/balls.py @@ -29,20 +29,20 @@ class BowlingBall(Thing): def __init__(self, initialPosition=None, editable=True): super(BowlingBall, self).__init__( pygame.image.load(abspath("../data/images/bolaBoliche.png")), - editable, initialPosition, elasticity = 100, mobility = True, - gravity = 10) - self.snd = pygame.mixer.Sound(abspath("../data/snd/BowlingBall.wav")) + editable, pygame.mixer.Sound(abspath("../data/snd/BowlingBall.wav")), + initialPosition, elasticity = 60, mobility = True, gravity = 5) class BeachBall(Thing): def __init__(self, initialPosition=None, editable=True): super(BeachBall, self).__init__( pygame.image.load(abspath("../data/images/bola.png")), - editable, initialPosition, elasticity = 100, mobility = True, - gravity = 10) + editable, pygame.mixer.Sound(abspath("../data/snd/BowlingBall.wav")), + initialPosition, elasticity = 90, mobility = True, gravity = 5) class SoccerBall(Thing): def __init__(self, initialPosition=None, editable=True): super(SoccerBall, self).__init__( pygame.image.load(abspath("../data/images/futebol.png")), - editable, initialPosition, elasticity = 100, mobility = True, - gravity = 10) + editable, pygame.mixer.Sound(abspath("../data/snd/BowlingBall.wav")), + initialPosition, elasticity = 70, mobility = True, + gravity = 5) diff --git a/Gambiarra/objects/elastica.py b/Gambiarra/objects/elastica.py index 94567ef..67527da 100644 --- a/Gambiarra/objects/elastica.py +++ b/Gambiarra/objects/elastica.py @@ -30,5 +30,6 @@ class Elastica(Thing): def __init__(self, initialPosition = [0,0], editable=True): super(Elastica, self).__init__( pygame.image.load(abspath("../data/images/cama_elastica.png")), - editable, initialPosition, elasticity = 100, mobility = False, + editable, pygame.mixer.Sound(abspath("../data/snd/cama_elastica.wav")), + initialPosition, elasticity = 100, mobility = False, gravity = 10) diff --git a/Gambiarra/objects/esteira.py b/Gambiarra/objects/esteira.py index 11170c6..55be56b 100644 --- a/Gambiarra/objects/esteira.py +++ b/Gambiarra/objects/esteira.py @@ -32,7 +32,8 @@ class Esteira(Thing): def __init__(self, initialPosition = [0,0], editable=True): super(Esteira, self).__init__( pygame.image.load(abspath("../data/images/esteira_dir.png")), - editable, initialPosition, elasticity = 100, mobility = False, + editable, pygame.mixer.Sound(abspath("../data/snd/dummy.wav")), + initialPosition, elasticity = 100, mobility = False, gravity = 10) self.sentido = 1 self.image_dir = pygame.image.load( diff --git a/Gambiarra/objects/target.py b/Gambiarra/objects/target.py index 284315a..e935fde 100644 --- a/Gambiarra/objects/target.py +++ b/Gambiarra/objects/target.py @@ -29,5 +29,6 @@ class Target(Thing): def __init__(self, initialPosition = [0,0], editable=True): super(Target, self).__init__( pygame.image.load(abspath("../data/images/target.png")), - editable, initialPosition, elasticity = 100, mobility = False, + editable, pygame.mixer.Sound(abspath("../data/snd/dummy.wav")), + initialPosition, elasticity = 100, mobility = False, gravity = 10)
\ No newline at end of file diff --git a/Gambiarra/objects/things.py b/Gambiarra/objects/things.py index b1d1e37..f1ebf04 100644 --- a/Gambiarra/objects/things.py +++ b/Gambiarra/objects/things.py @@ -19,8 +19,31 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# Bowling ball bouncing +# http://freesound.iua.upf.edu/samplesViewSingle.php?id=22744 +# Updated at September 12th, 2006. +# Published under Creative Commons Sampling Plus 1.0 License. + +# Congratulations +# http://freesound.iua.upf.edu/samplesViewSingle.php?id=25293 +# Updated at November 09th, 2006. +# Published under Creative Commons Sampling Plus 1.0 License. + +# Penguin bouncing +# http://freesound.iua.upf.edu/samplesViewSingle.php?id=34316 +# Updated at May 01st, 2007. +# Published under Creative Commons Sampling Plus 1.0 License. + +# Trampoline bouncing +# http://freesound.iua.upf.edu/samplesViewSingle.php?id=19347 +# Updated at May 30th, 2006. +# Published under Creative Commons Sampling Plus 1.0 License. + import pygame +class NoSound(): + def play(self): return + class Thing(pygame.sprite.Sprite): img = None @@ -32,8 +55,8 @@ class Thing(pygame.sprite.Sprite): snd = None elasticity = None # * 1%, from 0 up to 100 - def __init__(self, image, editable, initialPosition=None, - elasticity = 100, mobility = False, gravity = 10 ): + def __init__(self, image, editable, snd, initialPosition=None, + elasticity = 70, mobility = False, gravity = 5 ): pygame.sprite.Sprite.__init__(self) #call Sprite intializer self.image = image self.rect = image.get_rect() @@ -46,6 +69,7 @@ class Thing(pygame.sprite.Sprite): self.speed = [0,0] self.mobility = mobility self.gravity = gravity + self.snd = snd def draw(self, screen, pos ): # temos a imagem na variavel <img> e @@ -53,4 +77,4 @@ class Thing(pygame.sprite.Sprite): screen.blit(self.image, (pos[0],pos[1])) def play(self): - snd.play() + self.snd.play() diff --git a/Gambiarra/objects/wall.py b/Gambiarra/objects/wall.py index a6c40fb..0bb3d44 100644 --- a/Gambiarra/objects/wall.py +++ b/Gambiarra/objects/wall.py @@ -23,32 +23,34 @@ from os.path import abspath import pygame -from things import Thing +from things import Thing, NoSound class LeftWall(Thing): def __init__(self, initialPosition = [0,0], editable=False): super(LeftWall, self).__init__( pygame.image.load(abspath("../data/images/leftwall.png")), - editable, initialPosition, elasticity = 100, mobility = False, - gravity = 10) + editable, NoSound(), + initialPosition, elasticity = 100, mobility = False, gravity = 10) class RightWall(Thing): def __init__(self, initialPosition = [1185,0], editable=False): super(RightWall, self).__init__( pygame.image.load(abspath("../data/images/rightwall.png")), - editable, initialPosition, elasticity = 100, mobility = False, - gravity = 10) + editable, NoSound(), + initialPosition, elasticity = 100, mobility = False, gravity = 10) class UpWall(Thing): def __init__(self, initialPosition = [15,0], editable=False): super(UpWall, self).__init__( pygame.image.load(abspath("../data/images/upwall.png")), - editable, initialPosition, elasticity = 100, mobility = False, + editable, NoSound(), + initialPosition, elasticity = 100, mobility = False, gravity = 10) class DownWall(Thing): def __init__(self, initialPosition = [15,755], editable=False): super(DownWall, self).__init__( pygame.image.load(abspath("../data/images/downwall.png")), - editable, initialPosition, elasticity = 100, mobility = False, + editable, NoSound(), + initialPosition, elasticity = 100, mobility = False, gravity = 10) @@ -34,7 +34,10 @@ data/images/target.png data/images/upwall.png data/snd/BowlingBall.wav +data/snd/cama_elastica.wav data/snd/Congrats.wav +data/snd/dummy.wav +data/snd/penguin.wav Gambiarra/__init__.py Gambiarra/gambiarra.py diff --git a/activity/activity.info b/activity/activity.info index 36a81e1..bf438a5 100644 --- a/activity/activity.info +++ b/activity/activity.info @@ -4,4 +4,4 @@ activity_version = 1 host_version = 1 service_name = org.laptop.Gambiarra icon = activity-gambiarra -class = GambiarraActivity.GambiarraActivity
\ No newline at end of file +class = GambiarraActivity
\ No newline at end of file diff --git a/data/snd/cama_elastica.wav b/data/snd/cama_elastica.wav Binary files differnew file mode 100644 index 0000000..3203091 --- /dev/null +++ b/data/snd/cama_elastica.wav diff --git a/data/snd/dummy.wav b/data/snd/dummy.wav Binary files differnew file mode 100644 index 0000000..36eedac --- /dev/null +++ b/data/snd/dummy.wav diff --git a/data/snd/penguin.wav b/data/snd/penguin.wav Binary files differnew file mode 100644 index 0000000..36eedac --- /dev/null +++ b/data/snd/penguin.wav |