Commits

Dominic Kexel committed 35fc777 Draft

menu effect

Comments (0)

Files changed (3)

       self._silos[inx] = Silo(scene=self, inx=inx)
     self._initialized = True
 
-  def destroy(self, actor):
-    if actor in self._actors:
-      self._actors.remove(actor)
-    return actor
-    
-  def create(self, actor):
-    if not actor in self._actors:
-      self._actors.append(actor)
-    return actor
-
   def _fire_rocket(self, event):
     n = event.button -1
     if n not in (0, 1, 2): return
 
     self._highlight = -1
     self._rects = {}
+    self._back_step = 20
+    self._back_timer = 5
+    self._background_org = pygame.transform.scale(pygame.image.load('back.jpg'), (SCREEN_WIDTH, SCREEN_HEIGHT)).convert()
+    self._next_back_step()
+
+
+  def _next_back_step(self):
+    if self._back_step <= 1: return
+    self._back_step -= 1
+    self._background = pygame.transform.smoothscale(self._background_org, (SCREEN_WIDTH/self._back_step, SCREEN_HEIGHT/self._back_step))
+    self._background = pygame.transform.smoothscale(self._background, (SCREEN_WIDTH, SCREEN_HEIGHT))
 
   def _handle_menu_click(self, event):
     if self._highlight == -1:
     try: self._highlight = next(i for (i, r) in self._rects.items() if r.collidepoint(pos))
     except StopIteration: pass
 
+  def update_state(self):
+    self._back_timer -= 1
+    if not self._back_timer:
+      self._back_timer = 5
+      self._next_back_step()
+    
   def draw_state(self, screen):
-    screen.fill(BLACK)
+    super(Menu, self).draw_state(screen)
     self._rects = {}
     for i, text in enumerate(self._menu):
       pos = (50, 100 + i * 40)
-      color = RED if i == self._highlight else WHITE
+      color = GREYGREEN if i == self._highlight else DINGLEY
       surf = render_cached('big', text, color)
       self._rects[i] = pygame.rect.Rect(pos[0], pos[1], surf.get_width(), surf.get_height())
       screen.blit(surf, pos)
     if event.type in self._event_handler:
       self._event_handler[event.type](event)
 
+  def destroy(self, actor):
+    if actor in self._actors:
+      self._actors.remove(actor)
+    return actor
+    
+  def create(self, actor):
+    if not actor in self._actors:
+      self._actors.append(actor)
+    return actor
+
   def _update_actors(self):
     for actor in self._actors:
       actor.update()