Example #1
0
    def __init__(self):
        Sprite.__init__(self)

        self._resources_path = os.path.abspath(
            os.path.join(str(Path(__file__).parent.parent.parent)))
        self._resources_path = os.path.join(self._resources_path, "resources",
                                            "sprites")
        self.image_wall_brighter = Image.open(
            str(os.path.join(self._resources_path, 'Wall_Brighter.png')))
        self.image_wall_brighter = transform_into_surface(
            self.image_wall_brighter)
        self.image_wall_darker = Image.open(
            str(os.path.join(self._resources_path, 'Wall_Darker.png')))
        self.image_wall_darker = transform_into_surface(self.image_wall_darker)

        self.rect = self.image_wall_darker.get_rect()

        self.width = 300
        self.height = 300
        self.set_dimensions(self.width, self.height)

        self.x_pos = 0
        self.y_pos = 0
        self.rect.x = 0
        self.rect.y = 0
Example #2
0
    def __init__(self, start_pos_x: int, start_pos_y: int):
        Sprite.__init__(self)

        self._frame_counter = 0
        self._resources_path = os.path.abspath(
            os.path.join(str(Path(__file__).parent.parent.parent)))
        self._resources_path = os.path.join(self._resources_path, "resources",
                                            "sprites")
        self._image_energy_time_gif = Image.open(
            str(os.path.join(self._resources_path, 'Energy-Time-1.gif')))
        self._image_energy_time_gif = split_animated_gif(
            self._image_energy_time_gif)
        self.image_energy_time = self._image_energy_time_gif[0]
        self.mask_icon = transform_into_surface(
            Image.open(
                str(os.path.join(self._resources_path, 'Mask-collected.png'))))
        self.gloves_icon = transform_into_surface(
            Image.open(
                str(os.path.join(self._resources_path,
                                 'Gloves-collected.png'))))

        self.width = 30
        self.height = 30
        self.set_dimensions(self.width, self.height)

        self.x_pos = start_pos_x
        self.y_pos = start_pos_y
Example #3
0
    def __init__(self):
        Sprite.__init__(self)
        self._resources_path = os.path.abspath(os.path.join(str(Path(__file__).parent.parent.parent)))
        self._resources_path = os.path.join(self._resources_path, "resources", "sprites")

        self.image_grass = Image.open(str(os.path.join(self._resources_path, 'Platform_Grass.png')))
        self.image_grass = transform_into_surface(self.image_grass)

        self.image_soil = Image.open(str(os.path.join(self._resources_path, 'Platform_Soil.png')))
        self.image_soil = transform_into_surface(self.image_soil)

        self.image_concrete = Image.open(str(os.path.join(self._resources_path, 'Platform_Concrete.png')))
        self.image_concrete = transform_into_surface(self.image_concrete)

        self.rect = self.image_grass.get_rect()

        self.width = 50
        self.height = 100
        self.set_dimensions(self.width, self.height)

        self.rect.x = 0
        self.rect.y = 0
        self.width = 50
        self.height = 100

        self.x_pos = 0
        self.y_pos = 0

        self.is_dead = False
Example #4
0
    def __init__(self):
        Sprite.__init__(self)

        self._resources_path = os.path.abspath(
            os.path.join(str(Path(__file__).parent.parent.parent)))
        self._resources_path = os.path.join(self._resources_path, "resources",
                                            "sprites")
        self.image_sink = Image.open(
            str(os.path.join(self._resources_path, 'Sink.png')))
        self.image_sink = transform_into_surface(self.image_sink)

        self.image_sink2 = Image.open(
            str(os.path.join(self._resources_path, 'Sink_mirror.png')))
        self.image_sink2 = transform_into_surface(self.image_sink2)

        self.rect = self.image_sink.get_rect()

        self.width = 30
        self.height = 30
        self.set_dimensions(self.width, self.height)

        self.rect.x = 0
        self.rect.y = 0

        self.x_pos = 0
        self.y_pos = 0
Example #5
0
    def __init__(self):
        Sprite.__init__(self)

        self._resources_path = os.path.abspath(
            os.path.join(str(Path(__file__).parent.parent.parent)))
        self._resources_path = os.path.join(self._resources_path, "resources",
                                            "sprites")

        self.door_entrance = Image.open(
            str(os.path.join(self._resources_path, 'Door-Entrance.png')))
        self.door_entrance = transform_into_surface(self.door_entrance)

        self.door_exit = Image.open(
            str(os.path.join(self._resources_path, 'Door-Exit.png')))
        self.door_exit = transform_into_surface(self.door_exit)

        self.width = self.door_entrance.get_width()
        self.height = self.door_entrance.get_height()
        self.set_dimensions(self.width, self.height)

        self.x_pos = 0
        self.y_pos = 0
Example #6
0
    def __init__(self):
        Sprite.__init__(self)

        self._resources_path = os.path.abspath(os.path.join(str(Path(__file__).parent.parent.parent)))
        self._resources_path = os.path.join(self._resources_path, "resources", "sprites")
        self.image_box = Image.open(str(os.path.join(self._resources_path, 'Box.png')))
        self.image_box = transform_into_surface(self.image_box)
        self.width = 0
        self.height = 0
        self.x_pos = 0
        self.y_pos = 0
        self.rect = self.image_box.get_rect()
        self.is_dead = False
Example #7
0
    def __init__(self):
        Sprite.__init__(self)

        self._resources_path = os.path.abspath(
            os.path.join(str(Path(__file__).parent.parent.parent)))
        self._resources_path = os.path.join(self._resources_path, "resources",
                                            "sprites")

        self.image_cave = Image.open(
            str(os.path.join(self._resources_path, 'Background-Cave.png')))
        self.image_cave = transform_into_surface(self.image_cave)

        self.width = 960
        self.height = 640
        self.set_dimensions(self.width, self.height)

        self.x_pos = 0
        self.y_pos = 0
Example #8
0
    def __init__(self, direction: str, start_pos_x: int, start_pos_y: int):
        Sprite.__init__(self)

        self._resources_path = os.path.abspath(
            os.path.join(str(Path(__file__).parent.parent.parent)))
        self._resources_path = os.path.join(self._resources_path, "resources",
                                            "sprites")
        self.image_bullet = Image.open(
            str(os.path.join(self._resources_path, 'Bullet.png')))
        self.image_bullet = transform_into_surface(self.image_bullet)

        self.width = 30
        self.height = 30
        self.set_dimensions(self.width, self.height)

        self.x_pos = start_pos_x
        self.y_pos = start_pos_y

        self._direction = direction  # "Right.", "Left.", "Up.", "Down".
Example #9
0
    def __init__(self):
        Sprite.__init__(self)

        self._resources_path = os.path.abspath(
            os.path.join(str(Path(__file__).parent.parent.parent)))
        self._resources_path = os.path.join(self._resources_path, "resources",
                                            "sprites")
        self.image_infected_person = Image.open(
            str(os.path.join(self._resources_path, 'Infected_Person.png')))
        self.image_infected_person = transform_into_surface(
            self.image_infected_person)

        self.width = 100
        self.height = 150
        self.set_dimensions(self.width, self.height)

        self.x_pos = 0
        self.y_pos = 0

        self.is_dead = False
Example #10
0
    def __init__(self):
        Sprite.__init__(self)

        self._resources_path = os.path.abspath(
            os.path.join(str(Path(__file__).parent.parent.parent)))
        self._sounds_path = os.path.join(self._resources_path, "resources",
                                         "sounds")
        self._resources_path = os.path.join(self._resources_path, "resources",
                                            "sprites")

        # Get the player animation for standing still.
        self._gif_still = Image.open(
            str(os.path.join(self._resources_path, 'Hero_Standing_Still.gif')))
        self._images_still = split_animated_gif(self._gif_still)
        self._image_still = self._images_still[0]

        # Get the player animation for standing still while masked.
        self._gif_still_MASK = Image.open(
            str(
                os.path.join(self._resources_path,
                             'Hero_Standing_Still_Mask.gif')))
        self._images_still_MASK = split_animated_gif(self._gif_still_MASK)
        self._image_still_MASK = self._images_still_MASK[0]

        # Get the player animation for moving left.
        self._gif_move_L = Image.open(
            str(os.path.join(self._resources_path, 'Hero_Move_Left.gif')))
        self._images_move_L = split_animated_gif(self._gif_move_L)
        self._image_move_L = self._images_move_L[0]

        # Get the player animation for moving left while masked.
        self._gif_move_L_MASK = Image.open(
            str(os.path.join(self._resources_path, 'Hero_Move_Left_Mask.gif')))
        self._images_move_L_MASK = split_animated_gif(self._gif_move_L_MASK)
        self._image_move_L_MASK = self._images_move_L_MASK[0]

        # Get the player animation for moving right.
        self._gif_move_R = Image.open(
            str(os.path.join(self._resources_path, 'Hero_Move_Right.gif')))
        self._images_move_R = split_animated_gif(self._gif_move_R)
        self._image_move_R = self._images_move_R[0]

        # Get the player animation for moving right while masked.
        self._gif_move_R_MASK = Image.open(
            str(os.path.join(self._resources_path,
                             'Hero_Move_Right_Mask.gif')))
        self._images_move_R_MASK = split_animated_gif(self._gif_move_R_MASK)
        self._image_move_R_MASK = self._images_move_R_MASK[0]

        # Get the player animation for jumping.
        self._image_jump_R_gif = Image.open(
            str(os.path.join(self._resources_path, 'Hero_Jump_Right.gif')))
        self._image_jump_R_gif = split_animated_gif(self._image_jump_R_gif)
        self._image_jump_R = self._image_jump_R_gif[0]

        self._image_jump_L_gif = Image.open(
            str(os.path.join(self._resources_path, 'Hero_Jump_Left.gif')))
        self._image_jump_L_gif = split_animated_gif(self._image_jump_L_gif)
        self._image_jump_L = self._image_jump_L_gif[0]

        # Get the player animation for jumping while masked.
        self._image_jump_R_gif_MASK = Image.open(
            str(os.path.join(self._resources_path,
                             'Hero_Jump_Right_Mask.gif')))
        self._image_jump_R_gif_MASK = split_animated_gif(
            self._image_jump_R_gif_MASK)
        self._image_jump_R_MASK = self._image_jump_R_gif_MASK[0]

        self._image_jump_L_gif_MASK = Image.open(
            str(os.path.join(self._resources_path, 'Hero_Jump_Left_Mask.gif')))
        self._image_jump_L_gif_MASK = split_animated_gif(
            self._image_jump_L_gif_MASK)
        self._image_jump_L_MASK = self._image_jump_L_gif_MASK[0]

        # Get the player animation for shooting.
        self._image_shoot_left = Image.open(
            str(os.path.join(self._resources_path,
                             'Hero_Shoot_Left.png'))).convert("RGBA")
        self._image_shoot_left = transform_into_surface(self._image_shoot_left)

        self._image_shoot_right = Image.open(
            str(os.path.join(self._resources_path,
                             'Hero_Shoot_Right.png'))).convert("RGBA")
        self._image_shoot_right = transform_into_surface(
            self._image_shoot_right)

        # Get the player animation for shooting while masked.
        self._image_shoot_left_MASK = Image.open(
            str(os.path.join(self._resources_path,
                             'Hero_Shoot_Left_Mask.png'))).convert("RGBA")
        self._image_shoot_left_MASK = transform_into_surface(
            self._image_shoot_left_MASK)

        self._image_shoot_right_MASK = Image.open(
            str(os.path.join(self._resources_path,
                             'Hero_Shoot_Right_Mask.png'))).convert("RGBA")
        self._image_shoot_right_MASK = transform_into_surface(
            self._image_shoot_right_MASK)

        # Get the player animation for box moving (without gloves).
        self._image_move_box_R_gif = Image.open(
            str(os.path.join(self._resources_path, 'Hero-Guranje-Desno.gif')))
        self._image_move_box_R_gif = split_animated_gif(
            self._image_move_box_R_gif)
        self._image_move_box_R = self._image_move_box_R_gif[0]

        self._image_move_box_L_gif = Image.open(
            str(os.path.join(self._resources_path, 'Hero-Guranje-Lijevo.gif')))
        self._image_move_box_L_gif = split_animated_gif(
            self._image_move_box_L_gif)
        self._image_move_box_L = self._image_move_box_L_gif[0]

        # Get the player animation for box moving (with gloves).
        self._image_move_box_R_gif_GLOVES = Image.open(
            str(
                os.path.join(self._resources_path,
                             'Hero-Guranje-Desno-Rukavice.gif')))
        self._image_move_box_R_gif_GLOVES = split_animated_gif(
            self._image_move_box_R_gif_GLOVES)
        self._image_move_box_R_GLOVES = self._image_move_box_R_gif_GLOVES[0]

        self._image_move_box_L_gif_GLOVES = Image.open(
            str(
                os.path.join(self._resources_path,
                             'Hero-Guranje-Lijevo-Rukavice.gif')))
        self._image_move_box_L_gif_GLOVES = split_animated_gif(
            self._image_move_box_L_gif_GLOVES)
        self._image_move_box_L_GLOVES = self._image_move_box_L_gif_GLOVES[0]

        self.bullet_count = 0
        self.bullet_list = []

        # Get the dying animation.
        self._gif_die = Image.open(
            str(os.path.join(self._resources_path, 'Hero_Game_Over.gif')))
        self._gif_die = split_animated_gif(self._gif_die)
        self.image_die = self._gif_die[0]

        # Main image (changes to whatever the main character is currently doing).
        self.current_animation = self._image_still

        # Gif frame counters.
        self._still_frame_counter = 0
        self._move_L_frame_counter = 0
        self._move_R_frame_counter = 0
        self._die_animation_counter = 0
        self._jump_counter = 0
        self._move_box_counter = 0
        self._move_box_counter_GLOVES = 0

        self.x_movement_direction = "Left."  # Or "Right."
        self.y_movement_direction = "Up."  # Or "Down."
        self.current_movement_direction = "Left."  # "Left.", "Right", "Up.", "Down".

        self.isJump = False
        self.is_dead = False
        self.is_masked = False
        self.has_gloves = False
        self.is_moving_box = False

        self.death_countdown = False
        self.death_counter = 0
        self.death_timer_start = -1

        self.rect = self._image_still.get_rect()

        # Player dimensions.
        self.width = 50
        self.height = 100
        self.set_dimensions(
            self.width, self.height)  # Set the dimensions of all the images.

        # Collect all the animations.
        self._default_animations = []
        self._default_animations.append(self._images_still)
        self._default_animations.append(self._images_move_L)
        self._default_animations.append(self._images_move_R)
        self._default_animations.append(self._image_jump_R_gif)
        self._default_animations.append(self._image_jump_L_gif)
        self._default_animations.append(self._image_jump_R)
        self._default_animations.append(self._image_jump_L)
        self._default_animations.append(self._image_shoot_left)
        self._default_animations.append(self._image_shoot_right)

        # Current player position.
        self.x_pos = 0
        self.y_pos = 0

        #Glove counter
        self.glove_counter_start = -1