diff options
author | Luiz Irber <luiz.irber@gmail.com> | 2008-04-10 21:25:37 (GMT) |
---|---|---|
committer | Luiz Irber <luiz.irber@gmail.com> | 2008-04-10 21:25:37 (GMT) |
commit | c9e517c8235a549fe32d4a9e03eed474eb981531 (patch) | |
tree | b6b0c9ef82765ef35a64fd8f13f6e7e82843f64d | |
parent | dfd7f8c5d097ac02857b66940cf6fbf77e132c05 (diff) |
Path cleanup and access
- Added the libs subdir to path, we can start to use them
- Created a gambiarra.py file on project root to start the game outside XO
- Every access to the data dir don't have a '..' prefix anymore...
-rw-r--r-- | Gambiarra/__init__.py | 30 | ||||
-rw-r--r-- | Gambiarra/command.py | 6 | ||||
-rw-r--r-- | Gambiarra/gambiarra.py | 10 | ||||
-rw-r--r-- | Gambiarra/gamemenu.py | 10 | ||||
-rw-r--r-- | Gambiarra/levels.py | 21 | ||||
-rw-r--r-- | Gambiarra/objects/animals.py | 4 | ||||
-rw-r--r-- | Gambiarra/objects/balls.py | 12 | ||||
-rw-r--r-- | Gambiarra/objects/elastica.py | 4 | ||||
-rw-r--r-- | Gambiarra/objects/esteira.py | 6 | ||||
-rw-r--r-- | Gambiarra/objects/target.py | 2 | ||||
-rw-r--r-- | Gambiarra/objects/wall.py | 8 | ||||
-rw-r--r-- | gambiarra.py | 27 |
12 files changed, 100 insertions, 40 deletions
diff --git a/Gambiarra/__init__.py b/Gambiarra/__init__.py index e69de29..2c4b1c9 100644 --- a/Gambiarra/__init__.py +++ b/Gambiarra/__init__.py @@ -0,0 +1,30 @@ +#!/usr/bin/env python +# -*- coding: UTF-8 -*- +# +# Copyright (C) 2007 by ULPM: Alexandre Yukio Harano +# Fábio Cassarotti Parronchi Navarro +# Gabriel Geraldo França Marcondes +# Luiz Carlos Irber Júnior +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +import os.path +import sys + +# add the libs subdir to the path +basedir = os.path.dirname(os.path.abspath(sys.argv[0])) +libdir = os.path.join(basedir, "libs") + +sys.path.insert(0, libdir) diff --git a/Gambiarra/command.py b/Gambiarra/command.py index 449ad55..2310c95 100644 --- a/Gambiarra/command.py +++ b/Gambiarra/command.py @@ -39,14 +39,14 @@ class Command(pygame.sprite.Sprite): class Play(Command): def __init__(self): super(Play, self).__init__( pygame.image.load( - abspath("../data/images/playButton.png") ) ) + abspath("data/images/playButton.png") ) ) class Help(Command): def __init__(self): super(Help, self).__init__( pygame.image.load( - abspath("../data/images/helpButton.png") ) ) + abspath("data/images/helpButton.png") ) ) class Quit(Command): def __init__(self): super(Quit, self).__init__( pygame.image.load( - abspath("../data/images/quitButton.png") ) ) + abspath("data/images/quitButton.png") ) ) diff --git a/Gambiarra/gambiarra.py b/Gambiarra/gambiarra.py index d52d058..dee4335 100644 --- a/Gambiarra/gambiarra.py +++ b/Gambiarra/gambiarra.py @@ -71,9 +71,9 @@ class Game(object): self.clock = pygame.time.Clock() self.levels = Levels.init_levels() self.menu = GameMenu() - self.congrats = pygame.image.load("../data/images/fim_fase.png") + self.congrats = pygame.image.load("data/images/fim_fase.png") if self.play_sounds: - self.congratsSnd = pygame.mixer.Sound(abspath("../data/snd/Congrats.wav")) + self.congratsSnd = pygame.mixer.Sound(abspath("data/snd/Congrats.wav")) self._showed_help = False self.count = 0 @@ -206,9 +206,3 @@ class Game(object): if (len(self.levels) == self.level) : self.running = False -def main(): - game = Game(play_sounds=False) - game.run() - -if __name__ == "__main__": - main() diff --git a/Gambiarra/gamemenu.py b/Gambiarra/gamemenu.py index 4624ec3..744f3cf 100644 --- a/Gambiarra/gamemenu.py +++ b/Gambiarra/gamemenu.py @@ -34,7 +34,7 @@ class GameMenu(object): # pygame.init() # pygame.display.set_mode((1280,800)) self.screen = pygame.display.get_surface() - self.background = pygame.image.load(abspath("../data/images/background.png")) + self.background = pygame.image.load(abspath("data/images/background.png")) # mudar o arquivo de logotipo # self.level = LevelButton(350) self.start = StartButton(520) @@ -121,9 +121,9 @@ class LevelButton(object): def __init__(self, position, numberOfLevels = 1): nonHover = pygame.image.load( - abspath("../data/images/nivel_normal.png") ) + abspath("data/images/nivel_normal.png") ) hover = pygame.image.load( - abspath("../data/images/nivel_hover.png") ) + abspath("data/images/nivel_hover.png") ) self.img = [nonHover,hover] self.position = [600 - nonHover.get_width()/2, position] self.level = 0 @@ -151,9 +151,9 @@ class StartButton(object): def __init__(self, position): nonHover=pygame.image.load( - abspath("../data/images/iniciar_normal.png") ) + abspath("data/images/iniciar_normal.png") ) hover = pygame.image.load( - abspath("../data/images/iniciar_hover.png") ) + abspath("data/images/iniciar_hover.png") ) self.img = [nonHover,hover] self.position = [600 - nonHover.get_width()/2 - 50, position] self.current = 0 diff --git a/Gambiarra/levels.py b/Gambiarra/levels.py index 4e90ce1..ffeac64 100644 --- a/Gambiarra/levels.py +++ b/Gambiarra/levels.py @@ -21,12 +21,18 @@ import pygame from pygame.locals import * + +import sys + +import simplejson as json + from objects.balls import * from objects.animals import * from objects.elastica import * from objects.esteira import * from objects.target import * from objects.wall import * + from command import * def _is_static(obj): @@ -169,14 +175,14 @@ def init_levels(): level1ObjToAdd = [ Penguin() ] level1Goal = level1ObjInPlace[-1] level1ToGoal = level1ObjInPlace[0] - level1HelpImage = pygame.image.load("../data/images/obj-level1.png") + level1HelpImage = pygame.image.load("data/images/obj-level1.png") level2ObjInPlace = [ Penguin((300,500),editable=False), Target((500,600), editable=False)] level2ObjToAdd = [ Esteira() ] level2Goal = level2ObjInPlace[-1] level2ToGoal = level2ObjInPlace[0] - level2HelpImage = pygame.image.load("../data/images/obj-level2.png") + level2HelpImage = pygame.image.load("data/images/obj-level2.png") level3ObjInPlace = [ BowlingBall((20,20), editable=False), Esteira((10, 300),editable=False), @@ -184,7 +190,7 @@ def init_levels(): level3ObjToAdd = [ Elastica(), Elastica()] level3Goal = level3ObjInPlace[-1] level3ToGoal = level3ObjInPlace[0] - level3HelpImage = pygame.image.load("../data/images/obj-level3.png") + level3HelpImage = pygame.image.load("data/images/obj-level3.png") level4ObjInPlace = [ BowlingBall((20,20), editable=False), SoccerBall((800, 300), editable=False), @@ -195,7 +201,7 @@ def init_levels(): level4ToGoal1 = level4ObjInPlace[0] level4Goal2 = level4ObjInPlace[-1] level4ToGoal2 = level4ObjInPlace[1] - level4HelpImage = pygame.image.load("../data/images/obj-level4.png") + level4HelpImage = pygame.image.load("data/images/obj-level4.png") level5ObjInPlace = [ BowlingBall((1000,300), editable=False), Esteira((1000,500), editable=False), @@ -203,7 +209,7 @@ def init_levels(): level5ObjToAdd = [ Esteira(), Esteira()] level5Goal = level5ObjInPlace[-1] level5ToGoal = level5ObjInPlace[0] - level5HelpImage = pygame.image.load("../data/images/obj-level5.png") + level5HelpImage = pygame.image.load("data/images/obj-level5.png") level6ObjInPlace = [ BeachBall((800,50),editable = False), Elastica((800,400),editable = False), @@ -212,7 +218,7 @@ def init_levels(): level6ObjToAdd = [ Esteira(), Esteira() ] level6Goal = level6ObjInPlace[-1] level6ToGoal = level6ObjInPlace[0] - level6HelpImage = pygame.image.load("../data/images/obj-level6.png") + level6HelpImage = pygame.image.load("data/images/obj-level6.png") level1 = Level( level1ObjInPlace, level1ObjToAdd, @@ -246,3 +252,6 @@ def init_levels(): level6HelpImage) return [level1, level2, level3, level4, level5, level6] + +def load_levels(): + pass diff --git a/Gambiarra/objects/animals.py b/Gambiarra/objects/animals.py index de64fa9..f1a86e6 100644 --- a/Gambiarra/objects/animals.py +++ b/Gambiarra/objects/animals.py @@ -28,11 +28,11 @@ from os.path import abspath class Penguin(Thing): def __init__(self, initialPosition=None, editable=True): if pygame.mixer.get_init(): - snd = pygame.mixer.Sound(abspath("../data/snd/penguin.wav")) + snd = pygame.mixer.Sound(abspath("data/snd/penguin.wav")) else: snd = None super(Penguin, self).__init__( - pygame.image.load(abspath("../data/images/penguin.png")), + pygame.image.load(abspath("data/images/penguin.png")), editable, snd, initialPosition, elasticity = 100, mobility = True, gravity = 5) diff --git a/Gambiarra/objects/balls.py b/Gambiarra/objects/balls.py index f409d38..4fa7530 100644 --- a/Gambiarra/objects/balls.py +++ b/Gambiarra/objects/balls.py @@ -28,33 +28,33 @@ from things import Thing class BowlingBall(Thing): def __init__(self, initialPosition=None, editable=True): if pygame.mixer.get_init(): - snd = pygame.mixer.Sound(abspath("../data/snd/BowlingBall.wav")) + snd = pygame.mixer.Sound(abspath("data/snd/BowlingBall.wav")) else: snd = None super(BowlingBall, self).__init__( - pygame.image.load(abspath("../data/images/bolaBoliche.png")), + pygame.image.load(abspath("data/images/bolaBoliche.png")), editable, snd, initialPosition, elasticity = 60, mobility = True, gravity = 5) class BeachBall(Thing): def __init__(self, initialPosition=None, editable=True): if pygame.mixer.get_init(): - snd = pygame.mixer.Sound(abspath("../data/snd/BowlingBall.wav")) + snd = pygame.mixer.Sound(abspath("data/snd/BowlingBall.wav")) else: snd = None super(BeachBall, self).__init__( - pygame.image.load(abspath("../data/images/bola.png")), + pygame.image.load(abspath("data/images/bola.png")), editable, snd, initialPosition, elasticity = 90, mobility = True, gravity = 5) class SoccerBall(Thing): def __init__(self, initialPosition=None, editable=True): if pygame.mixer.get_init(): - snd = pygame.mixer.Sound(abspath("../data/snd/BowlingBall.wav")) + snd = pygame.mixer.Sound(abspath("data/snd/BowlingBall.wav")) else: snd = None super(SoccerBall, self).__init__( - pygame.image.load(abspath("../data/images/futebol.png")), + pygame.image.load(abspath("data/images/futebol.png")), editable, snd, initialPosition, elasticity = 70, mobility = True, gravity = 5) diff --git a/Gambiarra/objects/elastica.py b/Gambiarra/objects/elastica.py index 5af6574..9a7a2cd 100644 --- a/Gambiarra/objects/elastica.py +++ b/Gambiarra/objects/elastica.py @@ -29,11 +29,11 @@ class Elastica(Thing): def __init__(self, initialPosition = [0,0], editable=True): if pygame.mixer.get_init(): - snd = pygame.mixer.Sound(abspath("../data/snd/cama_elastica.wav")) + snd = pygame.mixer.Sound(abspath("data/snd/cama_elastica.wav")) else: snd = None super(Elastica, self).__init__( - pygame.image.load(abspath("../data/images/cama_elastica.png")), + pygame.image.load(abspath("data/images/cama_elastica.png")), editable, snd, initialPosition, elasticity = 100, mobility = False, gravity = 10) diff --git a/Gambiarra/objects/esteira.py b/Gambiarra/objects/esteira.py index b0ffef4..5fcb5ae 100644 --- a/Gambiarra/objects/esteira.py +++ b/Gambiarra/objects/esteira.py @@ -31,15 +31,15 @@ class Esteira(Thing): def __init__(self, initialPosition = [0,0], editable=True): super(Esteira, self).__init__( - pygame.image.load(abspath("../data/images/esteira_dir.png")), + pygame.image.load(abspath("data/images/esteira_dir.png")), editable, None, initialPosition, elasticity = 100, mobility = False, gravity = 10) self.sentido = 1 self.image_dir = pygame.image.load( - abspath("../data/images/esteira_dir.png")) + abspath("data/images/esteira_dir.png")) self.image_esq = pygame.image.load( - abspath("../data/images/esteira_esq.png")) + abspath("data/images/esteira_esq.png")) def draw(self, screen, pos): # temos a imagem na variavel <img> e diff --git a/Gambiarra/objects/target.py b/Gambiarra/objects/target.py index a4021c7..eae95bd 100644 --- a/Gambiarra/objects/target.py +++ b/Gambiarra/objects/target.py @@ -28,7 +28,7 @@ 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")), + pygame.image.load(abspath("data/images/target.png")), editable, None, initialPosition, elasticity = 100, mobility = False, gravity = 10) diff --git a/Gambiarra/objects/wall.py b/Gambiarra/objects/wall.py index 4a1b32d..6b3b52f 100644 --- a/Gambiarra/objects/wall.py +++ b/Gambiarra/objects/wall.py @@ -28,7 +28,7 @@ from things import Thing class LeftWall(Thing): def __init__(self, initialPosition = [0,0], editable=False): super(LeftWall, self).__init__( - pygame.image.load(abspath("../data/images/leftwall.png")), + pygame.image.load(abspath("data/images/leftwall.png")), editable, None, initialPosition, elasticity = 100, mobility = False, gravity = 10) @@ -44,7 +44,7 @@ class LeftWall(Thing): class RightWall(Thing): def __init__(self, initialPosition = [1185,0], editable=False): super(RightWall, self).__init__( - pygame.image.load(abspath("../data/images/rightwall.png")), + pygame.image.load(abspath("data/images/rightwall.png")), editable, None, initialPosition, elasticity = 100, mobility = False, gravity = 10) @@ -59,7 +59,7 @@ class RightWall(Thing): class UpWall(Thing): def __init__(self, initialPosition = [15,0], editable=False): super(UpWall, self).__init__( - pygame.image.load(abspath("../data/images/upwall.png")), + pygame.image.load(abspath("data/images/upwall.png")), editable, None, initialPosition, elasticity = 100, mobility = False, gravity = 10) @@ -75,7 +75,7 @@ class UpWall(Thing): class DownWall(Thing): def __init__(self, initialPosition = [15,755], editable=False): super(DownWall, self).__init__( - pygame.image.load(abspath("../data/images/downwall.png")), + pygame.image.load(abspath("data/images/downwall.png")), editable, None, initialPosition, elasticity = 100, mobility = False, gravity = 10) diff --git a/gambiarra.py b/gambiarra.py new file mode 100644 index 0000000..ca1f2b8 --- /dev/null +++ b/gambiarra.py @@ -0,0 +1,27 @@ +#!/usr/bin/env python +# -*- coding: UTF-8 -*- +# +# Copyright (C) 2007 by ULPM: Alexandre Yukio Harano +# Fábio Cassarotti Parronchi Navarro +# Gabriel Geraldo França Marcondes +# Luiz Carlos Irber Júnior +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +from Gambiarra.gambiarra import Game + +if __name__ == "__main__": + game = Game() + game.run() |