Exemplo n.º 1
0
    def __init__(self, form_position):
        super().__init__()
        ### Local variables ####################################################
        the_color = choice(color.LIST)
        the_id = id(the_color)
        ########################################################################

        ### Object Attributes ##################################################
        self.amount_lowered = 0
        self._anim = 0.0
        self.color = the_color
        self.column = None
        self._form_position = form_position
        self.current_frame_list = ENEMY_FRAMES_COLOR_BLIND if settings.SETTINGS[
            'color_blind'] else ENEMY_FRAMES
        self.image = self.current_frame_list[the_id][0]
        self.position = list(START_POS)
        self.rect = Rect(START_POS, self.image.get_size())
        self.state = Enemy.STATES.IDLE
        self.emitter = ParticleEmitter(color.color_particles[the_id],
                                       self.rect, 1)
        ########################################################################

        ### Preparation ########################################################
        del self.acceleration, self.velocity
Exemplo n.º 2
0
    def __init__(self):
        '''
        @ivar anim: A counter for ship animation
        @ivar image: The graphic
        @ivar invincible: How many frames of invincibility the player has if any
        @ivar my_bullet: The single bullet this ship may fire
        '''
        super().__init__()

        self.anim = 0.0
        self.appear_emitter = ParticleEmitter(APPEAR_POOL, START_POS.copy(), 2)
        self.emitter = ParticleEmitter(DEATH_POOL, START_POS.copy(), 2)
        self.flames = FlameTrail()
        self.image = FRAMES[0]
        self.invincible = 0
        self.light_column = LightColumn()
        self.my_bullet = ShipBullet()
        self.position = list(START_POS.topleft)
        self.rect = START_POS.copy()
        self.respawn_time = 3 * 60  # In frames
        self.change_state(Ship.STATES.RESPAWN)
Exemplo n.º 3
0
 def appear(self):
     self.position = self.__get_snap()
     self.rect.topleft = self.position
     self.image = self.current_frame_list[id(self.color)][0]
     self.gridcell = [
         self.rect.centerx // self.rect.width,
         self.rect.centery // self.rect.height,
     ]  #(x, y)
     self.emitter = ParticleEmitter(color.color_particles[id(self.color)],
                                    self.rect, 5, Block.particle_group)
     self.change_state(Block.STATES.START_FALLING)
     self.add(Block.GROUP)
Exemplo n.º 4
0
    def __init__(self):
        super().__init__()
        self._anim = 0.0
        self.column = None
        self.current_frame_list = UFO_FRAMES
        self.image = config.get_sprite(FRAMES[0])
        self.odds = expovariate(AVG_WAIT)
        self.position = list(START_POS)
        self.rect = Rect(START_POS, self.image.get_size())
        self.state = UFO.STATES.IDLE
        self.emitter = ParticleEmitter(color.random_color_particles, self.rect)

        del self.acceleration
Exemplo n.º 5
0

### Functions ##################################################################
def _star_appear(self):
    '''
    Stars appear on the left edge of the screen and travel right at one of five
    possible speeds.
    '''
    self.velocity[0] = randint(1, 5)


def _star_move(self):
    '''
    And this is the part where they actually move.
    '''
    self.position[0] += self.velocity[0]
    self.rect.left = self.position[0]


################################################################################

STARS_GROUP = pygame.sprite.RenderUpdates()
_STAR_IMAGE = config.get_sprite(Rect(4, 170, 2, 2))

EARTH = HudObject(config.EARTH, (0, 0))
GRID = HudObject(config.GRID_BG, (0, 0))
STARS = ParticleEmitter(ParticlePool(_STAR_IMAGE, _star_move, _star_appear),
                        Rect(0, 0, 0, config.SCREEN_HEIGHT), 8, STARS_GROUP)

EARTH.rect.midbottom = config.SCREEN_RECT.midbottom