Пример #1
0
def splash(screen, filename, min_timeout=0.0):
    print "splash %s" % filename
    help_sprite = data.get_sprite(filename)
    help_rect = help_sprite.get_rect()
    screen.blit(help_sprite, help_rect)
    pygame.display.flip()
    start = time.time()
    for event in iter_all_events():
        if time.time() - start >= min_timeout:
            break
Пример #2
0
 def onhit(self, dest):
     if dest.__class__ != Car: return
     # stop sound, continue current path for 3 iterations and then move on
     g.sounds['shit_splat'].play()
     new_sprite = data.get_sprite('shit_on_car.png')
     self.onhit = self.null_onhit
     def set_orig():
         self.set_sprite(new_sprite)
         self._orig_sprite = new_sprite
     print "BRRRR"
     rest_of_path = self._active_path[self._active_i:random.choice(range(self._active_i, len(self._active_path)))]
     self._action = self.do_end(self.do_path_with_size(rest_of_path), end=set_orig)
Пример #3
0
 def __init__(self, location, filename):
     self._start_location = location
     self._sprite = self._orig_sprite = data.get_sprite(filename)
     if self._sprite is None:
         import pdb; pdb.set_trace()
     self._rect = self._sprite.get_rect()
     self._orig_rect = self._rect
     self.set_pos(*self._start_location)
     self._state = None
     self._action = self.do_nothing()
     self._active_path = None # do_path uses this, and do_path_size
     self._active_i = 0
     self._visible = True
Пример #4
0
 def __init__(self, controller, location, key, dive_path, return_path):
     SpriteWorld.__init__(self, world=controller._world, location=location, filename='pigeon_sit.png')
     if self._rect.center[0] < g.width / 2:
         self.replace_sprite(pygame.transform.flip(self._sprite, True, False))
     self._controller = controller
     self._key = key
     self._dive_path = dive_path # predetermined path (later - generated?)
     self._return_path = return_path
     self._target = g.unit_pos_to_screen_pos(*g.config.car_start_position)
     flap_steps = 3
     d = flap_delay_steps = 2
     self._flap_sprites = [data.get_sprite(sprite) for sprite in ['pigeon_flap_up.png', 'pigeon_flap_down.png']]
     self._flap_sprite_iter = itertools.cycle(self._flap_sprites)
     a, b = self._flap_sprites
     self._diversion_flap_sprites = sum([[(a, d), (b, d)] for i in xrange(flap_steps)], []) + [(self._sprite, 0)]