From 1f261f263f863b623d10bd980f7acb0735e890d8 Mon Sep 17 00:00:00 2001 From: Luiz Irber Date: Sat, 19 Apr 2008 20:06:18 +0000 Subject: Removed abspath() calls and renamed some params in objects --- diff --git a/Gambiarra/command.py b/Gambiarra/command.py index 2310c95..694f251 100644 --- a/Gambiarra/command.py +++ b/Gambiarra/command.py @@ -19,8 +19,6 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -from os.path import abspath - import pygame class Command(pygame.sprite.Sprite): @@ -38,15 +36,15 @@ class Command(pygame.sprite.Sprite): class Play(Command): def __init__(self): - super(Play, self).__init__( pygame.image.load( - abspath("data/images/playButton.png") ) ) + Command.__init__(self, + pygame.image.load("data/images/playButton.png") ) class Help(Command): def __init__(self): - super(Help, self).__init__( pygame.image.load( - abspath("data/images/helpButton.png") ) ) + Command.__init__(self, + pygame.image.load("data/images/helpButton.png") ) class Quit(Command): def __init__(self): - super(Quit, self).__init__( pygame.image.load( - abspath("data/images/quitButton.png") ) ) + Command.__init__(self, + pygame.image.load("data/images/quitButton.png") ) diff --git a/Gambiarra/objects/animals.py b/Gambiarra/objects/animals.py index f1a86e6..b22f146 100644 --- a/Gambiarra/objects/animals.py +++ b/Gambiarra/objects/animals.py @@ -23,17 +23,15 @@ import pygame from things import Thing -from os.path import abspath - class Penguin(Thing): - def __init__(self, initialPosition=None, editable=True): + def __init__(self, initial_pos=None, editable=True): if pygame.mixer.get_init(): - snd = pygame.mixer.Sound(abspath("data/snd/penguin.wav")) + snd = pygame.mixer.Sound("data/snd/penguin.wav") else: snd = None - super(Penguin, self).__init__( - pygame.image.load(abspath("data/images/penguin.png")), + Thing.__init__(self, + pygame.image.load("data/images/penguin.png"), editable, snd, - initialPosition, elasticity = 100, mobility = True, + initial_pos, elasticity = 100, mobility = True, gravity = 5) self.speed=[5,0] diff --git a/Gambiarra/objects/balls.py b/Gambiarra/objects/balls.py index 4fa7530..e0607eb 100644 --- a/Gambiarra/objects/balls.py +++ b/Gambiarra/objects/balls.py @@ -19,42 +19,40 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -from os.path import abspath - import pygame from things import Thing class BowlingBall(Thing): - def __init__(self, initialPosition=None, editable=True): + def __init__(self, initial_pos=None, editable=True): if pygame.mixer.get_init(): - snd = pygame.mixer.Sound(abspath("data/snd/BowlingBall.wav")) + snd = pygame.mixer.Sound("data/snd/BowlingBall.wav") else: snd = None - super(BowlingBall, self).__init__( - pygame.image.load(abspath("data/images/bolaBoliche.png")), + Thing.__init__(self, + pygame.image.load("data/images/bolaBoliche.png"), editable, snd, - initialPosition, elasticity = 60, mobility = True, gravity = 5) + initial_pos, elasticity = 60, mobility = True, gravity = 5) class BeachBall(Thing): - def __init__(self, initialPosition=None, editable=True): + def __init__(self, initial_pos=None, editable=True): if pygame.mixer.get_init(): - snd = pygame.mixer.Sound(abspath("data/snd/BowlingBall.wav")) + snd = pygame.mixer.Sound("data/snd/BowlingBall.wav") else: snd = None - super(BeachBall, self).__init__( - pygame.image.load(abspath("data/images/bola.png")), + Thing.__init__(self, + pygame.image.load("data/images/bola.png"), editable, snd, - initialPosition, elasticity = 90, mobility = True, gravity = 5) + initial_pos, elasticity = 90, mobility = True, gravity = 5) class SoccerBall(Thing): - def __init__(self, initialPosition=None, editable=True): + def __init__(self, initial_pos=None, editable=True): if pygame.mixer.get_init(): - snd = pygame.mixer.Sound(abspath("data/snd/BowlingBall.wav")) + snd = pygame.mixer.Sound("data/snd/BowlingBall.wav") else: snd = None - super(SoccerBall, self).__init__( - pygame.image.load(abspath("data/images/futebol.png")), + Thing.__init__(self, + pygame.image.load("data/images/futebol.png"), editable, snd, - initialPosition, elasticity = 70, mobility = True, + initial_pos, elasticity = 70, mobility = True, gravity = 5) diff --git a/Gambiarra/objects/elastica.py b/Gambiarra/objects/elastica.py index 9a7a2cd..7395e22 100644 --- a/Gambiarra/objects/elastica.py +++ b/Gambiarra/objects/elastica.py @@ -19,23 +19,21 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -from os.path import abspath - import pygame from things import Thing class Elastica(Thing): - def __init__(self, initialPosition = [0,0], editable=True): + def __init__(self, initial_pos = None, editable=True): if pygame.mixer.get_init(): - snd = pygame.mixer.Sound(abspath("data/snd/cama_elastica.wav")) + snd = pygame.mixer.Sound("data/snd/cama_elastica.wav") else: snd = None - super(Elastica, self).__init__( - pygame.image.load(abspath("data/images/cama_elastica.png")), + Thing.__init__(self, + pygame.image.load("data/images/cama_elastica.png"), editable, snd, - initialPosition, elasticity = 100, mobility = False, + initial_pos, elasticity = 100, mobility = False, gravity = 10) def collide(self, obj): diff --git a/Gambiarra/objects/esteira.py b/Gambiarra/objects/esteira.py index 5fcb5ae..cb2812c 100644 --- a/Gambiarra/objects/esteira.py +++ b/Gambiarra/objects/esteira.py @@ -19,8 +19,6 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -from os.path import abspath - import pygame from things import Thing @@ -29,17 +27,15 @@ class Esteira(Thing): sentido = None - def __init__(self, initialPosition = [0,0], editable=True): - super(Esteira, self).__init__( - pygame.image.load(abspath("data/images/esteira_dir.png")), + def __init__(self, initial_pos = (0, 0), editable=True): + Thing.__init__(self, + pygame.image.load("data/images/esteira_dir.png"), editable, None, - initialPosition, elasticity = 100, mobility = False, + initial_pos, elasticity = 100, mobility = False, gravity = 10) self.sentido = 1 - self.image_dir = pygame.image.load( - abspath("data/images/esteira_dir.png")) - self.image_esq = pygame.image.load( - abspath("data/images/esteira_esq.png")) + self.image_dir = pygame.image.load("data/images/esteira_dir.png") + self.image_esq = pygame.image.load("data/images/esteira_esq.png") def draw(self, screen, pos): # temos a imagem na variavel e diff --git a/Gambiarra/objects/target.py b/Gambiarra/objects/target.py index eae95bd..c455995 100644 --- a/Gambiarra/objects/target.py +++ b/Gambiarra/objects/target.py @@ -19,18 +19,16 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -from os.path import abspath - import pygame from things import Thing class Target(Thing): - def __init__(self, initialPosition = [0,0], editable=True): - super(Target, self).__init__( - pygame.image.load(abspath("data/images/target.png")), + def __init__(self, initial_pos=None, editable=True): + Thing.__init__(self, + pygame.image.load("data/images/target.png"), editable, None, - initialPosition, elasticity = 100, mobility = False, + initial_pos, elasticity = 100, mobility = False, gravity = 10) def collide(self, obj): diff --git a/Gambiarra/objects/things.py b/Gambiarra/objects/things.py index b008947..f39ba36 100644 --- a/Gambiarra/objects/things.py +++ b/Gambiarra/objects/things.py @@ -44,7 +44,7 @@ import pygame class Thing(pygame.sprite.Sprite): img = None - initialPosition = None + initial_pos = None mobility = None editable = None speed = None @@ -52,15 +52,15 @@ class Thing(pygame.sprite.Sprite): snd = None elasticity = None # * 1%, from 0 up to 100 - def __init__(self, image, editable, snd, initialPosition=None, + def __init__(self, image, editable, snd, initial_pos=None, elasticity = 70, mobility = False, gravity = 5 ): pygame.sprite.Sprite.__init__(self) #call Sprite intializer self.image = image self.rect = image.get_rect() - if initialPosition: - self.initialPosition = initialPosition - self.rect.topleft = initialPosition[0], initialPosition[1] + if initial_pos: + self.initial_pos = initial_pos + self.rect.topleft = initial_pos[0], initial_pos[1] self.elasticity = elasticity self.editable = editable self.speed = [0,0] diff --git a/Gambiarra/objects/wall.py b/Gambiarra/objects/wall.py index a2a0e2d..ec6c1de 100644 --- a/Gambiarra/objects/wall.py +++ b/Gambiarra/objects/wall.py @@ -19,19 +19,17 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -from os.path import abspath - import pygame from things import Thing class LeftWall(Thing): - def __init__(self, initialPosition = [0,0], editable=False): + def __init__(self, initial_pos=(0, 0), editable=False): image = pygame.Surface( (15, 770) ) - image.fill( (255,255,255) ) - super(LeftWall, self).__init__( + image.fill( (255, 255, 255) ) + Thing.__init__(self, image, editable, None, - initialPosition, elasticity = 100, mobility = False, + initial_pos, elasticity = 100, mobility = False, gravity = 10) def collide(self, obj): @@ -43,12 +41,12 @@ class LeftWall(Thing): return False class RightWall(Thing): - def __init__(self, initialPosition = [1185,0], editable=False): + def __init__(self, initial_pos=(1185, 0), editable=False): image = pygame.Surface( (15, 770) ) - image.fill( (255,255,255) ) - super(RightWall, self).__init__( + image.fill( (255, 255, 255) ) + Thing.__init__(self, image, editable, None, - initialPosition, elasticity = 100, mobility = False, gravity = 10) + initial_pos, elasticity = 100, mobility = False, gravity = 10) def collide(self, obj): if obj.rect.colliderect(self.rect): @@ -59,12 +57,12 @@ class RightWall(Thing): return False class UpWall(Thing): - def __init__(self, initialPosition = [15,0], editable=False): + def __init__(self, initial_pos = (15, 0), editable=False): image = pygame.Surface( (1770, 15) ) - image.fill( (255,255,255) ) - super(UpWall, self).__init__( + image.fill( (255, 255, 255) ) + Thing.__init__(self, image, editable, None, - initialPosition, elasticity = 100, mobility = False, + initial_pos, elasticity = 100, mobility = False, gravity = 10) def collide(self, obj): @@ -76,12 +74,12 @@ class UpWall(Thing): return False class DownWall(Thing): - def __init__(self, initialPosition = [15,755], editable=False): + def __init__(self, initial_pos = (15, 755), editable=False): image = pygame.Surface( (1770, 15) ) - image.fill( (255,255,255) ) - super(DownWall, self).__init__( + image.fill( (255, 255, 255) ) + Thing.__init__(self, image, editable, None, - initialPosition, elasticity = 100, mobility = False, + initial_pos, elasticity = 100, mobility = False, gravity = 10) def collide(self, obj): -- cgit v0.9.1