Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/DerechosSprites.py
diff options
context:
space:
mode:
Diffstat (limited to 'DerechosSprites.py')
-rw-r--r--DerechosSprites.py52
1 files changed, 38 insertions, 14 deletions
diff --git a/DerechosSprites.py b/DerechosSprites.py
index 92e0341..1d383ec 100644
--- a/DerechosSprites.py
+++ b/DerechosSprites.py
@@ -78,6 +78,9 @@ class MainSprite(AnimatedSprite):
elif self.move == TALKING:
pass
+ def collision_rect(self):
+ return (self.x+15, self.y+38, 38, 38)
+
class BoySprite(AnimatedSprite):
"""
@@ -192,18 +195,14 @@ class BoySprite(AnimatedSprite):
elif self.move == RIGHT:
self._frame = 24
- def draw_talking_range(self, screen):
- pygame.draw.arc(screen, (200, 0, 0), (self.x+9, self.y, 48, 48),
- -math.pi/4, math.pi/4, 2)
- pygame.draw.arc(screen, (200, 0, 0), (self.x+9, self.y, 48, 48),
- math.pi/4*3, math.pi/4*5, 2)
-
def draw_talking(self, screen):
pygame.draw.arc(screen, (0, 0, 200), (self.x+9, self.y, 48, 48),
-math.pi/4, math.pi/4, 2)
pygame.draw.arc(screen, (0, 0, 200), (self.x+9, self.y, 48, 48),
math.pi/4*3, math.pi/4*5, 2)
+ def collision_rect(self):
+ return (self.x+15, self.y+38, 38, 38)
def draw_grid(grid,screen):
@@ -226,16 +225,13 @@ if __name__ == "__main__":
w = int(master_width/4)
h = int(master_height/4)
for i in xrange(4):
- images.append(master_image.subsurface((i*w,0,w,h)))
+ images.append(master_image.subsurface((i*w, 0, w, h)))
for i in xrange(4):
- images.append(master_image.subsurface((i*w,h,w,h)))
+ images.append(master_image.subsurface((i*w, h, w, h)))
for i in xrange(4):
- images.append(master_image.subsurface((i*w,2*h,w,h)))
+ images.append(master_image.subsurface((i*w, 2*h, w, h)))
for i in xrange(4):
- images.append(master_image.subsurface((i*w,3*h,w,h)))
-
- bg_image = pygame.image.load(os.path.join('images',
- 'derechos-plaza-fondo.jpg')).convert_alpha()
+ images.append(master_image.subsurface((i*w, 3*h, w, h)))
fms = [0, 1, 0, 2, 0, 1, 0, 3, # up
4, 5, 4, 6, 4, 5, 4, 7, # down
@@ -257,6 +253,27 @@ if __name__ == "__main__":
sp = MainSprite(images, fms, nf, dxs, dys, 30, 370, 10)
sp2 = BoySprite(images, fms, nf, dxs, dys, 150, 470, 10)
+ images = []
+ master_image = pygame.image.load(os.path.join('images',
+ 'spacebar.png')).convert_alpha()
+ master_width, master_height = master_image.get_size()
+ w = int(master_width)
+ h = int(master_height/2)
+ images.append(master_image.subsurface((0, 0, w, h)))
+ images.append(master_image.subsurface((0, h, w, h)))
+ fms = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 1, 1, 1, 1]
+ nf = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
+ 16, 17, 18, 19, 20, 21, 22, 23, 0]
+ dxs = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0]
+ dys = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0]
+ sb = AnimatedSprite(images, fms, nf, dxs, dys, 0, 0, 10)
+
+ bg_image = pygame.image.load(os.path.join('images',
+ 'derechos-plaza-fondo.jpg')).convert_alpha()
+
grid = [[0,0,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1],
[0,0,1,1,1,1,1,1,0,0,0,0,0,0,0,0,1,1,1,1,0,0,0,0],
[0,0,1,1,1,1,1,1,0,0,1,1,1,1,0,0,1,1,1,1,0,0,0,0],
@@ -310,6 +327,8 @@ if __name__ == "__main__":
sp.update_move(STOP)
sp2.update_move(STOP)
print("Not talking...")
+ elif event.key == pygame.K_ESCAPE:
+ playing = False
elif event.type == pygame.KEYUP:
keys_pressed = pygame.key.get_pressed()
if event.key == pygame.K_UP and not talking:
@@ -379,6 +398,8 @@ if __name__ == "__main__":
if ulx-ulx2 >= -1 and ulx-ulx2 <=1 \
and uly-uly2 >= -1 and uly-uly2<=1:
talking_range = True
+ sb.x = sp2.x + 12
+ sb.y = sp2.y - 10
else:
talking_range = False
@@ -390,9 +411,12 @@ if __name__ == "__main__":
sp.render(screen)
if talking_range and not talking:
- sp2.draw_talking_range(screen)
+ sb.update(time_passed,grid)
+ sb.render(screen)
elif talking:
sp2.draw_talking(screen)
+
+# sp.draw_rect(screen)
pygame.display.flip()