Exemplo n.º 1
0
    def add_second_player(self, player_name: str) -> bool:
        if player_name != self.player_1_status.name:
            self.player_2_status = PlayerStatus(player_name)

            # todo change game status to the first one on the go
            self.game_status = self.player_1_status.name \
                if randrange(2) else self.player_2_status.name
            return True

        return False
Exemplo n.º 2
0
class Player:
    def __init__(self, game):
        self.game = game

        self.size = (28, 60)

        self.body = PlayerBody(self)
        self.sprite = PlayerSprite(self)
        self.status = PlayerStatus(self)

        self.health = 1000
        self.damage = 0
        self.stun = 0

        self.keys = ["default"]

        #self.hurt_sound = self.game.core.get_sound("player_hurt.ogg")

    def update(self, ticks):
        self.body.update(ticks)
        self.sprite.update(ticks)
        self.status.update(ticks)

        if self.stun > 0:
            self.stun = max(self.stun - 0.1, 0)

    def collect(self, pickup):
        if pickup.drop_type == "key":
            self.keys.append(pickup.config)

    def take_damage(self, n):
        if self.sprite.flashing == 0:
            self.damage = min(self.damage + n, self.health)
            self.stun = min(self.stun + (n*10), self.health - self.damage)
            self.sprite.flashing = 60
            #self.hurt_sound.play()

    def is_dangerous(self):
        if self.body.dash_timer > 0:
            return True
        else:
            return False
Exemplo n.º 3
0
    def __init__(self, game):
        self.game = game

        self.size = (28, 60)

        self.body = PlayerBody(self)
        self.sprite = PlayerSprite(self)
        self.status = PlayerStatus(self)

        self.health = 1000
        self.damage = 0
        self.stun = 0

        self.keys = ["default"]
Exemplo n.º 4
0
 def __init__(self, player_name: str) -> None:
     self.player_1_status = PlayerStatus(player_name)
     self.game_status = "created"