Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuiz Irber <luiz.irber@gmail.com>2007-11-11 02:03:22 (GMT)
committer Luiz Irber <luiz.irber@gmail.com>2007-11-11 02:03:22 (GMT)
commitf8324d6c1bfdafa884d926ca4da317ab8f8e96f5 (patch)
tree6273f28f4642219627453584a6f1f6b990e93341
parent96daec740440285d4232189375a06fd592fa25bb (diff)
V5, aa meia-noite buscarei sua ALMA! (versao sem crase, e nem til)
-rw-r--r--Gambiarra/gambiarra.py98
-rw-r--r--Gambiarra/levels/levels.py33
-rw-r--r--Gambiarra/objects/balls.py4
-rw-r--r--Gambiarra/objects/esteira.py14
-rw-r--r--Gambiarra/objects/wall.py2
-rw-r--r--MANIFEST2
-rw-r--r--activity/activity-gambiarra.svg30
-rwxr-xr-xdata/bola.pngbin2269 -> 2678 bytes
-rwxr-xr-xdata/bolaBoliche.pngbin1999 -> 1594 bytes
-rwxr-xr-xdata/leftwall.pngbin216 -> 261 bytes
-rwxr-xr-xdata/penguin.pngbin2001 -> 424 bytes
-rw-r--r--data/penguin16.pngbin3117 -> 0 bytes
-rwxr-xr-xdata/rightwall.pngbin216 -> 243 bytes
13 files changed, 138 insertions, 45 deletions
diff --git a/Gambiarra/gambiarra.py b/Gambiarra/gambiarra.py
index 83843fd..a6a0d25 100644
--- a/Gambiarra/gambiarra.py
+++ b/Gambiarra/gambiarra.py
@@ -7,6 +7,40 @@ import os
from levels import levels as Levels
from objects.wall import *
+def check_collision(sprite_list, wall_list):
+ new_objects = pygame.sprite.RenderPlain()
+ for obj in sprite_list:
+ obj.remove(sprite_list)
+ obj.add(new_objects)
+
+ for s in sprite_list:
+ #TODO: verifica colisao de objetos dinamicos
+ pass
+
+ for w in wall_list:
+ if obj.rect.colliderect(w.rect):
+ if isinstance(w, DownWall):
+ obj.speed[1] = -0.7*obj.speed[1]
+ if obj.rect.bottom > w.rect.top:
+ obj.rect.bottom = w.rect.top - 1
+
+ if isinstance(w, UpWall):
+ obj.speed[1] = -0.7*obj.speed[1]
+ if obj.rect.top < w.rect.bottom:
+ obj.rect.top = w.rect.bottom + 1
+
+ if isinstance(w, LeftWall):
+ obj.speed[0] = -0.9*obj.speed[0]
+ if obj.rect.left < w.rect.right:
+ obj.rect.left = w.rect.right + 1
+
+ if isinstance(w, RightWall):
+ obj.speed[0] = -0.9*obj.speed[0]
+ if obj.rect.right > w.rect.left:
+ obj.rect.right = w.rect.left - 1
+
+ return new_objects
+
class Game(object):
fps = 30
screen = None
@@ -36,49 +70,63 @@ class Game(object):
def update_screen(self, fps):
#update dos elementos da tela
- self.check_collision()
+ objs = check_collision(self.allLevels[self.level].simulator.objects,
+ self.allLevels[self.level].simulator._walls)
+ self.allLevels[self.level].simulator.objects = objs
for obj in self.allLevels[self.level].simulator.objects:
#obj eh um objeto na tela
if obj.mobility:
newpos = obj.rect.move((obj.speed[0],obj.speed[1]))
obj.rect = newpos
- obj.speed[0] *= 0.9
+ if obj.speed[0]:
+ obj.speed[0] *= 0.9
+ else:
+ obj.speed[0] = 20
obj.speed[1] += obj.gravity
- def check_collision(self):
- for obj in self.allLevels[self.level].simulator.objects:
- obj.remove(self.allLevels[self.level].simulator.objects)
- collision = pygame.sprite.spritecollide(obj,
- self.allLevels[self.level].simulator.objects, 0)
- obj.add(self.allLevels[self.level].simulator.objects)
- if collision != []:
- if isinstance(collision[0],DownWall):
- obj.speed[1] =- obj.speed[1]
-
- def actors_clear(self):
- #retira ator da tela
- pass
-
- def actors_draw(self):
- #desenha ator na tela
- pass
-
def start_window(self):
#desenha a tela inicial (abstrato -chama os outros metodos predefinidos)
pass
def next_level(self):
pass
+
+ def mouse_event(self, mousePos, mouseButtonsPressed ):
+ if mouseButtonsPressed[0]:
+ #verificar colisao com thing
+ #colidiu = verificar Colisao!!!
+ collided = False
+ #Pegar o objeto
+ obj = None
+ mouseMove = python.mouse.get_rel()
+ if collided:
+ while mouseButtonsPressed[0]:
+ pass
+
+ mouseMove = python.mouse.get_rel()
+ #comentado porque por enquanto obj eh None
+ #obj.rect = obj.rect.move(mouseMove)
def main_loop(self):
#loop principal
+ #-definir e desenhar o nivel
+ #-esperar por eventos do mouse:
+ # -clique sobre um thing, arrasta
+ # -clique sobre um botao
- while self.run:
- self.clock.tick(self.fps)
- self.update_screen(self.fps)
- self.allLevels[self.level].draw()
+ #quando clicar em play transformar o botao em stop
+ playPressed = True
+ if playPressed:
+ while self.run:
+ self.clock.tick(self.fps)
+ self.update_screen(self.fps)
+ self.allLevels[self.level].draw()
- pygame.display.flip()
+ pygame.display.flip()
+ for event in pygame.event.get():
+ if event.type == MOUSEBUTTONDOWN:
+ self.mouse_event( pygame.mouse.get_pos(),
+ pygame.mouse.get_pressed() )
def main():
game = Game()
diff --git a/Gambiarra/levels/levels.py b/Gambiarra/levels/levels.py
index 47a67c7..0c62e4a 100644
--- a/Gambiarra/levels/levels.py
+++ b/Gambiarra/levels/levels.py
@@ -5,6 +5,7 @@ import pygame
from objects.balls import *
from objects.animals import *
from objects.wall import *
+from objects.esteira import *
class SimulationView(object):
""" This widget holds the objects being simulated. """
@@ -14,13 +15,14 @@ class SimulationView(object):
def __init__(self, objects):
self.running = False
- self.background = pygame.Surface((1200, 700))
+ self.background = pygame.Surface((1200, 770))
self.background.fill([0,0,150])
self.objects = pygame.sprite.RenderPlain(objects)
- LeftWall().add(self.objects)
- RightWall().add(self.objects)
- UpWall().add(self.objects)
- DownWall().add(self.objects)
+ self._walls = []
+ self._walls.append(LeftWall())
+ self._walls.append(RightWall())
+ self._walls.append(UpWall())
+ self._walls.append(DownWall())
def draw(self, pos = None):
screen = pygame.display.get_surface()
@@ -29,6 +31,9 @@ class SimulationView(object):
else:
screen.blit(self.background, (0, 0))
+ for wall in self._walls:
+ wall.draw(screen, wall.rect)
+
for item in self.objects:
item.draw(screen, item.rect.topleft)
@@ -36,18 +41,18 @@ class ObjectBar(object):
""" This widget contains the objects available for the problem. """
def __init__(self, objects):
- self.background = pygame.Surface((1000, 200))
+ self.background = pygame.Surface((1000, 130))
self.background.fill([0,255,0]) #TODO: achar uma cor melhor =D
self.objects = pygame.sprite.RenderPlain(objects)
def draw(self, pos = None):
screen = pygame.display.get_surface()
if pos:
- screen.blit(self.background, (pos[0], 700 + pos[1]), pos)
+ screen.blit(self.background, (pos[0], 770 + pos[1]), pos)
else:
- screen.blit(self.background, (0, 700))
+ screen.blit(self.background, (0, 770))
- objpos = [0,715]
+ objpos = [0, 785]
for item in self.objects:
item.draw(screen, objpos)
objpos[0] += item.image.get_width() + 15
@@ -59,16 +64,16 @@ class CommandBar(object):
""" This widget contains the commands: play, help, and quit. KISS! =D """
def __init__(self):
- self.background = pygame.Surface((200, 200))
+ self.background = pygame.Surface((200, 130))
self.width, self.height = self.background.get_size()
self.background.fill([0,0,255]) #TODO: achar uma cor melhor =D
def draw(self, pos=None):
screen = pygame.display.get_surface()
if pos:
- screen.blit(self.background, (1000 + pos[0], 700 + pos[1]), pos)
+ screen.blit(self.background, (1000 + pos[0], 770 + pos[1]), pos)
else:
- screen.blit(self.background, (1000, 700))
+ screen.blit(self.background, (1000, 770))
def update(self):
pass
@@ -92,10 +97,10 @@ class Level(object):
def init_levels():
#FIXME: fazer de um jeito menos lusitano
#Sample levels
- level1ObjInPlace = [ BowlingBall((200,300)), BeachBall((400,800))]
+ level1ObjInPlace = [ BowlingBall((200,300)), BeachBall((100,100))]
level1ObjToAdd = [ Penguin(), BeachBall() ]
- level2ObjInPlace = [ Penguin((300,600))]
+ level2ObjInPlace = [ Penguin((300,600)), Esteira((20,650))]
level2ObjToAdd = [ BeachBall(), Penguin(), BowlingBall() ]
level3ObjInPlace = [ BowlingBall((200,700)), Penguin((500, 800))]
diff --git a/Gambiarra/objects/balls.py b/Gambiarra/objects/balls.py
index 7c08805..5960c73 100644
--- a/Gambiarra/objects/balls.py
+++ b/Gambiarra/objects/balls.py
@@ -12,7 +12,7 @@ class BowlingBall(Thing):
super(BowlingBall, self).__init__(
pygame.image.load(abspath("../data/bolaBoliche.png")),
editable, initialPosition, elasticity = 100, mobility = True,
- gravity = 1)
+ gravity = 10)
# TODO: substituir pela imagem correta
#self.img = pygame.Surface((170, 170))
#pygame.draw.circle(self.img, [0,10,0], (85, 85), 80)
@@ -22,7 +22,7 @@ class BeachBall(Thing):
super(BeachBall, self).__init__(
pygame.image.load(abspath("../data/bola.png")),
editable, initialPosition, elasticity = 100, mobility = True,
- gravity = 1)
+ gravity = 10)
# TODO: substituir pela imagem correta
#self.img = pygame.Surface((170, 170))
#pygame.draw.circle(self.img, [0,10,0], (85, 85), 80)
diff --git a/Gambiarra/objects/esteira.py b/Gambiarra/objects/esteira.py
new file mode 100644
index 0000000..ea4fb01
--- /dev/null
+++ b/Gambiarra/objects/esteira.py
@@ -0,0 +1,14 @@
+# /gambiarra/esteira.py
+
+from os.path import abspath
+
+import pygame
+
+from objects.things import Thing
+
+class Esteira(Thing):
+ def __init__(self, initialPosition = [0,0], editable=False):
+ super(Esteira, self).__init__(
+ pygame.image.load(abspath("../data/esteira.png")),
+ editable, initialPosition, elasticity = 100, mobility = False,
+ gravity = 10) \ No newline at end of file
diff --git a/Gambiarra/objects/wall.py b/Gambiarra/objects/wall.py
index ab7954d..b30fc46 100644
--- a/Gambiarra/objects/wall.py
+++ b/Gambiarra/objects/wall.py
@@ -38,7 +38,7 @@ class UpWall(Thing):
#pygame.draw.circle(self.img, [0,10,0], (85, 85), 80)
class DownWall(Thing):
- def __init__(self, initialPosition = [15,685], editable=False):
+ def __init__(self, initialPosition = [15,755], editable=False):
super(DownWall, self).__init__(
pygame.image.load(abspath("../data/downwall.png")),
editable, initialPosition, elasticity = 100, mobility = False,
diff --git a/MANIFEST b/MANIFEST
index 9e22117..3fb1171 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -3,7 +3,6 @@ activity/activity.info
data/bolaBoliche.png
data/bola.png
data/helpButton.png
-data/penguin16.png
data/penguin.png
data/pen.png
data/playButton.png
@@ -22,6 +21,7 @@ Gambiarra/objects/animals.py
Gambiarra/objects/balls.py
Gambiarra/objects/wall.py
Gambiarra/objects/things.py
+Gambiarra/objects/esteira.py
olpcgames/activity.py
olpcgames/camera.py
olpcgames/canvas.py
diff --git a/activity/activity-gambiarra.svg b/activity/activity-gambiarra.svg
index b76fb6c..e8528dd 100644
--- a/activity/activity-gambiarra.svg
+++ b/activity/activity-gambiarra.svg
@@ -5,6 +5,32 @@
<!ENTITY stroke_color "#000000">
]>
<svg xmlns="http://www.w3.org/2000/svg" width="50" height="50">
- <rect x="1" y="1" width="48" height="48"
- style="fill:&fill_color;;stroke:&stroke_color;;stroke-width:2"/>
+ <metadata>
+ <rdf:RDF xmlns:cc="http://web.resource.org/cc/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
+ <cc:Work rdf:about="">
+ <dc:creator>
+ <cc:Agent>
+ <dc:title>Sérgio Luiz Araújo Silva</dc:title>
+ </cc:Agent>
+ </dc:creator>
+ <dc:rights>
+ <cc:Agent>
+ <dc:title>Sérgio Luiz Araújo Silva</dc:title>
+ </cc:Agent>
+ </dc:rights>
+ <dc:date></dc:date>
+ </cc:Work>
+ <cc:License rdf:about="http://web.resource.org/cc/PublicDomain">
+ <cc:permits rdf:resource="http://web.resource.org/cc/Reproduction"/>
+ <cc:permits rdf:resource="http://web.resource.org/cc/Distribution"/>
+ <cc:permits rdf:resource="http://web.resource.org/cc/DerivativeWorks"/>
+ </cc:License>
+ </rdf:RDF>
+ </metadata>
+ <path
+ d="M 11.504022,30.960125 L 14.2004,25.741484 C 14.805965,25.780057 15.407927,25.757695 15.996739,25.667646 L 19.180648,30.603347 L 22.068569,29.256688 L 20.288189,23.669889 C 20.737863,23.275702 21.142403,22.826415 21.50368,22.335907 L 27.243508,23.574948 L 28.332633,20.582597 L 23.125493,17.892705 C 23.165173,17.28242 23.142981,16.675959 23.052027,16.082653 L 27.975862,12.905959 L 26.629192,10.018034 L 21.054833,11.796021 C 20.65841,11.343671 20.208747,10.934309 19.714911,10.57143 L 20.949506,4.8438454 L 17.955104,3.7539766 L 15.269489,8.9557444 C 14.657759,8.9166004 14.050458,8.9404694 13.455905,9.0325454 L 10.280518,4.1114913 L 7.3925907,5.4581594 L 9.1690857,11.036598 C 8.7192861,11.432281 8.3130403,11.882425 7.9521107,12.374668 L 2.2163615,11.137109 L 1.1264874,14.131507 L 6.337712,16.822885 C 6.299694,17.429801 6.3257814,18.033513 6.4169314,18.623484 L 1.4840122,21.806099 L 2.8306732,24.694024 L 8.4222816,22.913085 C 8.8156416,23.360235 9.2628223,23.762882 9.7516333,24.122259 L 8.5116571,29.870994 L 11.504022,30.960125 z M 10.594703,15.852078 C 11.425448,13.569645 13.952085,12.391449 16.234531,13.222189 C 18.516968,14.052932 19.695163,16.579572 18.864419,18.862017 C 18.033682,21.14446 15.507037,22.322653 13.2246,21.491907 C 10.942157,20.661168 9.7639601,18.134524 10.594703,15.852078 z "
+ style="fill:&fill_color;;fill-opacity:1.0000000;fill-rule:evenodd;stroke:&stroke_color;;stroke-width:2.1250000;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4.0000000;stroke-opacity:1.0000000;"/>
+ <path
+ d="M 31.549365,42.683675 L 34.245751,37.465033 C 34.851318,37.503611 35.453267,37.481251 36.042081,37.391198 L 39.225996,42.326896 L 42.113915,40.980233 L 40.333535,35.393445 C 40.783204,34.999253 41.187744,34.54996 41.549024,34.059457 L 47.28885,35.298501 L 48.37798,32.306144 L 43.170835,29.616258 C 43.210522,29.00597 43.188332,28.399506 43.097372,27.806196 L 48.021203,24.629517 L 46.674545,21.741585 L 41.10018,23.519569 C 40.703756,23.067227 40.254106,22.657857 39.760261,22.294985 L 40.994853,16.5674 L 38.000455,15.477527 L 35.314836,20.679293 C 34.703103,20.640139 34.095801,20.664023 33.501254,20.756094 L 30.325866,15.835049 L 27.437939,17.181707 L 29.214434,22.760147 C 28.764639,23.155825 28.358381,23.605985 27.997455,24.098224 L 22.261704,22.860657 L 21.171835,25.85506 L 26.383053,28.546433 C 26.345041,29.15335 26.371127,29.757063 26.462276,30.347027 L 21.529356,33.529646 L 22.876017,36.417576 L 28.467631,34.636635 C 28.860985,35.083784 29.30817,35.486438 29.796979,35.845816 L 28.557011,41.594545 L 31.549365,42.683675 z M 30.640051,27.575631 C 31.470788,25.293193 33.997434,24.114999 36.279878,24.945738 C 38.562313,25.776487 39.740507,28.303122 38.909768,30.585564 C 38.079027,32.868003 35.55238,34.046198 33.269942,33.215461 C 30.987496,32.384725 29.809314,29.858074 30.640051,27.575631 z "
+ style="fill:&fill_color;;fill-opacity:1.0000000;fill-rule:evenodd;stroke:&stroke_color;;stroke-width:2.1250000;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4.0000000;stroke-opacity:1.0000000;"/>
</svg> \ No newline at end of file
diff --git a/data/bola.png b/data/bola.png
index acc48b0..9412552 100755
--- a/data/bola.png
+++ b/data/bola.png
Binary files differ
diff --git a/data/bolaBoliche.png b/data/bolaBoliche.png
index 4b87478..3cb862b 100755
--- a/data/bolaBoliche.png
+++ b/data/bolaBoliche.png
Binary files differ
diff --git a/data/leftwall.png b/data/leftwall.png
index 061f7d0..78a220f 100755
--- a/data/leftwall.png
+++ b/data/leftwall.png
Binary files differ
diff --git a/data/penguin.png b/data/penguin.png
index 7d2f2b4..0b585f8 100755
--- a/data/penguin.png
+++ b/data/penguin.png
Binary files differ
diff --git a/data/penguin16.png b/data/penguin16.png
deleted file mode 100644
index 9525bd3..0000000
--- a/data/penguin16.png
+++ /dev/null
Binary files differ
diff --git a/data/rightwall.png b/data/rightwall.png
index 061f7d0..c9655c1 100755
--- a/data/rightwall.png
+++ b/data/rightwall.png
Binary files differ