示例#1
0
    def __init__(self, flyweight, owner):
        super(Sword, self).__init__()
        self.game = owner.game
        self.owner = owner
        self.game.hitter_group.add(self)  # redundant?
        self.pos = None
        self.rect = None
        self.flyweight = flyweight
        # SWING STATS
        self.right_hand = True

        # CLOCKS
        self.current_swing_clock = clock.Clock(
        )  # runs while the sword is swang
        self.next_swing_clock = clock.Clock()  # avoid swing spamming
        self.clock_ticker = clock.ClockTicker(self)

        self.move()
示例#2
0
    def __init__(self, coords, collide_with, dash_stats, back_dash_stats):
        # TODO unpack dash stats
        self.back_dash_stats = back_dash_stats
        self.dash_stats = dash_stats
        self.rect = None
        self.collide_with = collide_with
        self.face = const.V_LEFT.rotate(random.randint(-180, 180))

        self.pos = pygame.Vector2(coords)
        self.speed = const.V_ZERO

        # TODO make up better way to state if the object is moving. This field is used in SOME cases
        self.moving = False
        self.can_be_moved = True  # object's ability to make decision about its movement!!!

        # BASE CLOCKS
        # TODO move to interfaces as well
        self.dash_clock = clock.Clock(self.unblock_movement)
        self.next_dash_clock = clock.Clock()
        self.stun_clock = clock.Clock(self.unblock_movement)
        self.throw_back_clock = clock.Clock(self.stop)
示例#3
0
    def __init__(self, image, state_durations):
        """
        Init

        :param image: what image to operate on
        :param state_durations: tuple of 4 duration of each of 4 states
        """
        base.AdvancedSprite.__init__(self)
        self.image = image
        self.stage = TitleState.WAIT
        self.state_durations = state_durations
        self.clock = clock.Clock(self.next_stage)
        self.clock.wind_up(self.state_durations[self.stage.value])
        self.postponed_fetch_layer(const.IMP_PARTICLE_Y)
示例#4
0
    def __init__(self, pos, lifetime):
        """
        ! init

        :param pos: position
        :param lifetime: ticks to dissapear
        """
        base.AdvancedSprite.__init__(self)
        font = pygame.font.Font(None, 80)
        self.image = font.render("!", 3, const.C_BLACK)
        self.rect = self.image.get_rect(centerx=pos.x, centery=pos.y)
        self.postponed_fetch_layer(const.IMP_PARTICLE_Y)

        self.clock = clock.Clock(self.kill, lifetime)
        self.clock.wind_up()
示例#5
0
    def __init__(self,
                 max_health,
                 heal_sounds=None,
                 hit_sounds=None,
                 death_sounds=None,
                 invulnerability=-1,
                 low_health=0):
        self.max_health = max_health
        self.low_health = low_health
        self.health = max_health
        self.invulnerability_clock = clock.Clock(None, invulnerability)

        self.heal_sounds = heal_sounds
        self.hit_sounds = hit_sounds
        self.death_sounds = death_sounds
示例#6
0
    def __init__(self, duration, to_black, when_stops=None):
        """
        Init

        :param duration: duration of fade
        :param to_black: True if fade to black, False if fade from black
        :param when_stops: action to perform when fade is over
        """
        base.AdvancedSprite.__init__(self)
        if when_stops is None:
            when_stops = self.kill
        self.to_black = to_black
        self.duration = duration
        self.postponed_fetch_layer(const.FADE_Y)
        self.clock = clock.Clock(when_stops, duration)
        self.clock.wind_up()
示例#7
0
    def __init__(self, flyweight, coords):
        """
        Heart init

        :param flyweight: flyweight with assets
        :param coords: coordinates of new heart
        """
        base.AdvancedSprite.__init__(self)
        interface.Pickupable.__init__(self)
        self.flyweight = flyweight
        self.rect = pygame.Rect(*coords, 30, 30)  # hitbox for collisions
        self.death_clock = clock.Clock(self.kill, 90)
        # the heart will dissaper after 3 seconds
        self.death_clock.wind_up()
        # TODO improve because it is really flat and should be under everything
        self.postponed_fetch_layer(coords[1] - 50)
示例#8
0
    def __init__(self, flyweight: SpikesFlyweight, game,
                 coords: Tuple[int, int], start_phase: int):
        """
        Spikes init

        :param flyweight: flyweight for assets and constants
        :param game: game in which spikes are
        :param coords: tuple with coordinates
        :param start_phase: starting spikes phase, hidden phase is default
        """
        base.AdvancedSprite.__init__(self)
        self.rect = pygame.Rect(*coords, 50, 50)
        self.state = SpikesState(start_phase)
        self.game = game
        self.pos = pygame.Vector2(coords)
        self.flyweight = flyweight
        self.state_clock = clock.Clock(self.next_state)
        self.state_clock.wind_up(self.flyweight.state_durations[self.state])
        self.postponed_fetch_layer(coords[1] - 50)
示例#9
0
 def __init__(self, max_stamina, wait_speed, rest_speed):
     self.rest_speed = rest_speed
     self.max_stamina = max_stamina
     self.stamina = max_stamina
     self.rest_clock = clock.Clock(self.stamina_rest, rest_speed)
     self.wait_clock = clock.Clock(self.start_resting, wait_speed)