Commits

Radomir Dopieralski committed ef2b2a6 Draft

Start and finish screens

  • Participants
  • Parent commits b811804

Comments (0)

Files changed (4)

deevo/__main__.py

                       key=lambda sprite: getattr(sprite, "depth", 0))
 
 
-def load_sheet(filename, width=32, height=None):
-    if height is None:
-        height = width
+def load_image(filename):
     f = StringIO.StringIO(pkgutil.get_data('deevo', filename))
     image = pygame.image.load(f)
     image = image.convert()
     image.set_colorkey((0xff, 0, 0xff))
+    return image
+
+
+def load_sheet(filename, width=32, height=None):
+    if height is None:
+        height = width
+    image = load_image(filename)
     w, h = image.get_size()
     images = []
     for x in xrange(w // width):
             images.append(image.subsurface(rect))
     return images
 
+
 class Sprite(pygame.sprite.Sprite):
     sheet_index = 0
 
     def __init__(self, (x, y), kind = 12, die_to=13, hp=10):
         super(Monster, self).__init__((x, y), kind)
         self.dzs = itertools.cycle([0, -1, -4, -3, -2, -1, 0, 1, 2, 3, 4, 1])
-        self.dx, self.dy = -4, 0
+        self.dx, self.dy = -8, 0
         self.glow = Glow(self, (0, 28))
         self.die_to = die_to
         self.hp = hp
         ]))
 
 
+    def image(self, filename):
+        screen = pygame.display.get_surface()
+        image = load_image(filename)
+        screen.blit(image, (0, 0))
+        pygame.display.flip()
+        while True:
+            event = pygame.event.wait()
+            if event.type == pygame.QUIT:
+                raise SystemExit()
+            elif event.type == pygame.KEYDOWN:
+                if event.key == pygame.K_SPACE:
+                    return
+
     def main(self):
         screen = pygame.display.get_surface()
         background = screen.copy()
         nextelem = self.level.next()
         mx, my, Something = nextelem[:3]
         finish = False
-        while not finish or len(sprites) > 1:
+        while gunner.alive() and (not finish or len(sprites) > 1):
             while not finish and mx < progress + 800:
                 sprites.add(Something((mx - progress, my), *nextelem[3:]))
                 try:
             dirty += shadows.draw(screen)
             dirty += sprites.draw(screen)
             pygame.display.update(dirty)
+        if gunner.alive():
+            self.image('finish.png')
+        else:
+            self.image('over.png')
 
 
-Game().main()
+
+game = Game()
+while True:
+    game.image('intro.png')
+    game.main()

deevo/finish.png

Added
New image

deevo/intro.png

Added
New image

deevo/over.png

Added
New image