Exemplo n.º 1
0
    def portal(self):
        if mouse_pressed() == "left" and not len(
                Teleporter.teleporter_list) > 0 and self._delay == 0:
            if pygame.mouse.get_pos(
            )[0] - self._g_point[0] >= 0 and pygame.mouse.get_pos(
            )[1] - self._g_point[1] <= 0:
                Teleporter(_x0=(pygame.mouse.get_pos()[0]),
                           _y0=(pygame.mouse.get_pos()[1]) - 125,
                           _x1=self._g_point[0] - 25,
                           _y1=self._g_point[1] - 75)
            elif pygame.mouse.get_pos(
            )[0] - self._g_point[0] <= 0 and pygame.mouse.get_pos(
            )[1] - self._g_point[1] <= 0:
                Teleporter(_x0=(pygame.mouse.get_pos()[0]) - 50,
                           _y0=(pygame.mouse.get_pos()[1]) - 125,
                           _x1=self._g_point[0] - 25,
                           _y1=self._g_point[1] - 75)
            elif pygame.mouse.get_pos(
            )[0] - self._g_point[0] >= 0 and pygame.mouse.get_pos(
            )[1] - self._g_point[1] >= 0:
                Teleporter(_x0=(pygame.mouse.get_pos()[0]),
                           _y0=(pygame.mouse.get_pos()[1]),
                           _x1=self._g_point[0] - 25,
                           _y1=self._g_point[1] - 75)
            else:
                Teleporter(_x0=(pygame.mouse.get_pos()[0]) - 50,
                           _y0=(pygame.mouse.get_pos()[1]),
                           _x1=self._g_point[0] - 25,
                           _y1=self._g_point[1] - 75)
            self._delay = 100

        if not self._delay == 0:
            self._delay -= 1
Exemplo n.º 2
0
    def sword(self, win):
        if keyboard_pressed() == "right":
            self._facing_right = True
            self._facing_left = False
        elif keyboard_pressed() == "left":
            self._facing_right = False
            self._facing_left = True
        else:
            self._facing_right = False
            self._facing_left = False

        if self._facing_left:
            pygame.draw.rect(
                win, (255, 180, 12),
                (self._g_point[0] - 20, self._g_point[1] + 25, -50, 15), 0)
            self._hitbox_sword = pygame.Rect(self._g_point[0],
                                             self._g_point[1], -50, 15)
        elif self._facing_right or not self._facing_left and not self._facing_right:
            pygame.draw.rect(
                win, (255, 180, 12),
                (self._g_point[0] + 20, self._g_point[1] + 25, 50, 15), 0)
            self._hitbox_sword = pygame.Rect(self._g_point[0],
                                             self._g_point[1], 50, 15)

        if not self._hitbox_sword.collidelist(
                Enemy.enemy_hitlist
        ) == -1 and self._delay == 0 and mouse_pressed() == "right":
            num = self._hitbox.collidelist(Enemy.enemy_hitlist)
            Enemy.enemy_list[num].health -= self._damage
            self._delay = 50

        if not self._delay == 0:
            self._delay -= 1
Exemplo n.º 3
0
    def shooting(self):
        if self._shoot_loop >= 0:
            self._shoot_loop += 1
        if self._shoot_loop > self._shooting_rates:
            self._shoot_loop = self._shooting_rates

        if mouse_pressed() == "right" and len(
                RoundedProj.proj_list
        ) <= 25 and self._shoot_loop == self._shooting_rates:
            RoundedProj(
                _x=self._g_point[0],
                _y=self._g_point[1],
                _v=3,
                _radius=10,
                _orientationX=(pygame.mouse.get_pos()[0] - self._g_point[0]) /
                30,
                _orientationY=-(pygame.mouse.get_pos()[1] - self._g_point[1]) /
                30,
                _damage=50)
            self._shoot_loop = 0
Exemplo n.º 4
0
    def draw(self, win):
        """Method for displaying the character"""
        #   Draw the hitbox
        # pygame.draw.rect(win, (255, 0, 0), (self._x, self._y, self._w, self._h), 0)

        if self._gender == "fireman/":

            if self._img_max_attack == 0:

                if mouse_pressed() == "right":
                    self._img_max_attack = len(attackFireman)

                if keyboard_pressed() == "right":
                    self._img_max = len(walkLeftFireman)

                    if self._count < self._img_max:
                        self._player = pygame.image.load("Assets/" + self._gender + "WalkRight/" + walkRightFireman[self._count])
                        self._count += 1
                    else:
                        self._count = 0

                if keyboard_pressed() == "left":
                    self._img_max = len(walkLeftFireman)

                    if self._count < self._img_max:
                        self._player = pygame.image.load(
                            "Assets/" + self._gender + "WalkLeft/" + walkLeftFireman[self._count])
                        self._count += 1
                    else:
                        self._count = 0

                if keyboard_pressed() == 0:
                    if self._velocity < 0:

                        self._img_max = len(fallFireman)
                        if self._count < self._img_max:
                            self._player = pygame.image.load(
                                "Assets/" + self._gender + "Jump/" + fallFireman[self._count])
                            self._count += 1
                        elif self._count == self._img_max:
                            self._player = pygame.image.load(
                                "Assets/" + self._gender + "Jump/" + fallFireman[self._img_max - 1])
                        else:
                            self._count = 0

                    elif self._velocity > 0:

                        self._img_max = len(jumpFireman)
                        if self._count < self._img_max:
                            self._player = pygame.image.load(
                                "Assets/" + self._gender + "Jump/" + jumpFireman[self._count])
                            self._count += 1
                        elif self._count == self._img_max:
                            self._player = pygame.image.load(
                                "Assets/" + self._gender + "Jump/" + jumpFireman[self._img_max - 1])
                        else:
                            self._count = 0

                    else:
                        self._img_max = len(afkFireman)
                        if self._count < self._img_max:
                            self._player = pygame.image.load(
                                "Assets/" + self._gender + "Afk/" + afkFireman[self._count])
                            self._count += 1
                        else:
                            self._count = 0
            else:
                # this is the left button but my mate failed between left and right, screw him
                self._count += 1
                if self._count < self._img_max_attack:
                    self._player = pygame.image.load(
                        "Assets/" + self._gender + "Attack/" + attackFireman[self._count])
                    self._count += 1
                else:
                    self._count = 0
                    self._img_max_attack = 0
        if self._gender == "knight/":

            if self._img_max_attack == 0:

                if mouse_pressed() == "right":
                    self._img_max_attack = len(attackKnight)

                if keyboard_pressed() == "right":
                    self._img_max = len(walkRightKnight)

                    if self._count < self._img_max:
                        self._player = pygame.image.load(
                            "Assets/" + self._gender + "WalkRight/" + walkRightKnight[self._count])
                        self._count += 1
                    else:
                        self._count = 0

                if keyboard_pressed() == "left":
                    self._img_max = len(walkLeftKnight)

                    if self._count < self._img_max:
                        self._player = pygame.image.load(
                            "Assets/" + self._gender + "WalkLeft/" + walkLeftKnight[self._count])
                        self._count += 1
                    else:
                        self._count = 0

                if keyboard_pressed() == 0:
                    """""
                    if self._velocity < 0:

                        self._img_max = len(fallKnight)
                        if self._count < self._img_max:
                            self._player = pygame.image.load(
                                "Assets/" + self._gender + "Jump/" + fallKnight[self._count])
                            self._count += 1
                        elif self._count == self._img_max:
                            self._player = pygame.image.load(
                                "Assets/" + self._gender + "Jump/" + fallKnight[self._img_max - 1])
                        else:
                            self._count = 0

                    elif self._velocity > 0:

                        self._img_max = len(jumpKnight)
                        if self._count < self._img_max:
                            self._player = pygame.image.load(
                                "Assets/" + self._gender + "Jump/" + jumpKnight[self._count])
                            self._count += 1
                        elif self._count == self._img_max:
                            self._player = pygame.image.load(
                                "Assets/" + self._gender + "Jump/" + jumpKnight[self._img_max - 1])
                        else:
                            self._count = 0
                    """""
                    if True:
                        self._img_max = len(afkKnight)
                        if self._count < self._img_max:
                            self._player = pygame.image.load(
                                "Assets/" + self._gender + "Afk/" + afkKnight[self._count])
                            self._count += 1
                        else:
                            self._count = 0
            else:
                # this is the left button but my mate failed between left and right, screw him
                self._count += 1
                if self._count < self._img_max_attack:
                    self._player = pygame.image.load(
                        "Assets/" + self._gender + "Attack/" + attackKnight[self._count])
                    self._count += 1
                else:
                    self._count = 0
                    self._img_max_attack = 0

        self._player_to_draw = pygame.transform.scale(self._player, (200, 200))

        if self._gender == "fireman/":
            self._x_neg = 75
            self._y_neg = 52
            self._delta_x = self._x - self._x_neg
            self._delta_y = self._y - self._y_neg

        elif self._gender == "knight/":
            self._x_neg = 75
            self._y_neg = 52
            self._delta_x = self._x - self._x_neg
            self._delta_y = self._y - self._y_neg

        win.blit(self._player_to_draw, (self._delta_x, self._delta_y))