def __init__(self): super().__init__() self.character_face_direction = RIGHT_FACING # Track out state self.jumping = False self.walking = False self.running = False self.swimming = False self.standup = True self.hanging = False self.climbing = False self.is_on_ladder = False self.cur_texture = 0 self.scale = CHARACTER_SCALING self.FRAMES_OJOS_ABIERTO = 100 self.FRAMES_PARPADEO = 20 self.index_textura_parado = 0 self.index_textura_walking = 0 self.timer_parpadeo = 0 image_source_parado = "Megaman/toad_parado_0{}.png" image_source_corriendo = "Megaman/toad_corriendo_0{}.png" self.texturas_parado = [] for i in range(1, 3): idle_texture_pair = arcade.load_texture_pair(image_source_parado.format(i)) self.texturas_parado.append(idle_texture_pair) print(len(self.texturas_parado)) self.texturas_corriendo = [] for i in range(1, 6): running_texture_pair = arcade.load_texture_pair(image_source_corriendo.format(i)) self.texturas_corriendo.append(running_texture_pair)
def __init__(self, ladder_list: arcade.SpriteList, hit_box_algorithm): """ Init """ # Let parent initialize super().__init__() # Set our scale self.scale = SPRITE_SCALING_PLAYER # Images from Kenney.nl's Character pack # main_path = ":resources:images/animated_characters/female_adventurer/femaleAdventurer" main_path = ":resources:images/animated_characters/female_person/femalePerson" # main_path = ":resources:images/animated_characters/male_person/malePerson" # main_path = ":resources:images/animated_characters/male_adventurer/maleAdventurer" # main_path = ":resources:images/animated_characters/zombie/zombie" # main_path = ":resources:images/animated_characters/robot/robot" # Load textures for idle standing self.idle_texture_pair = arcade.load_texture_pair( f"{main_path}_idle.png", hit_box_algorithm=hit_box_algorithm) self.jump_texture_pair = arcade.load_texture_pair( f"{main_path}_jump.png") self.fall_texture_pair = arcade.load_texture_pair( f"{main_path}_fall.png") # Load textures for walking self.walk_textures = [] for i in range(8): texture = arcade.load_texture_pair(f"{main_path}_walk{i}.png") self.walk_textures.append(texture) # Load textures for climbing self.climbing_textures = [] texture = arcade.load_texture(f"{main_path}_climb0.png") self.climbing_textures.append(texture) texture = arcade.load_texture(f"{main_path}_climb1.png") self.climbing_textures.append(texture) # Set the initial texture self.texture = self.idle_texture_pair[0] # Hit box will be set based on the first image used. self.hit_box = self.texture.hit_box_points # Default to face-right self.character_face_direction = RIGHT_FACING # Index of our current texture self.cur_texture = 0 # How far have we traveled horizontally since changing the texture self.x_odometer = 0 self.y_odometer = 0 self.ladder_list = ladder_list self.is_on_ladder = False
def __init__(self, boundary_left, boundary_right, speed): super().__init__() self.boundary_left = boundary_left self.boundary_right = boundary_right self.change_x = speed # Default to face-left self.character_face_direction = LEFT_FACING # Used for flipping between image sequences self.cur_texture = 0 self.scale = TILE_SCALING # Set true when the goomba dies self.death = False # Set true when the death animation is finished self.death_animation_finished = False # Index for image loading and counting index = 1 # Load textures for walking self.walk_textures = [] while index <= 16: texture = arcade.load_texture_pair( f"Immagini/Enemy/tartaruga{index}.png") self.walk_textures.append(texture) self.walk_textures.append(texture) self.walk_textures.append(texture) self.walk_textures.append(texture) self.walk_textures.append(texture) index += 1 index = 1 # Load textures death animation self.death_textures = [] while index <= 5: texture = arcade.load_texture_pair( f"Immagini/Enemy/tartarugaKO{index}.png") self.death_textures.append(texture) self.death_textures.append(texture) self.death_textures.append(texture) self.death_textures.append(texture) self.death_textures.append(texture) index += 1 # Set the initial texture self.texture = self.walk_textures[0][self.character_face_direction] # Hit box will be set based on the first image used self.set_hit_box(self.texture.hit_box_points)
def __init__(self, game): """ Init """ # Let parent initialize super().__init__() # Set our scale self.scale = SPRITE_SCALING_PLAYER self.game = game self.dead = False # Images from Kenney.nl's Character pack # main_path = ":resources:images/animated_characters/female_adventurer/femaleAdventurer" # main_path = ":resources:images/animated_characters/female_person/femalePerson" # main_path = ":resources:images/animated_characters/male_person/malePerson" # main_path = ":resources:images/animated_characters/male_adventurer/maleAdventurer" # main_path = ":resources:images/animated_characters/zombie/zombie" # main_path = ":resources:images/animated_characters/robot/robot" main_path = "resources/images/characters/character_femaleAdventurer" # Load textures for idle standing self.idle_texture_pair = arcade.load_texture_pair( f"{main_path}_idle.png") self.jump_texture_pair = arcade.load_texture_pair( f"{main_path}_jump.png") self.fall_texture_pair = arcade.load_texture_pair( f"{main_path}_fall.png") self.splat_texture_pair = arcade.load_texture_pair( f"{main_path}_splat.png") # Load textures for walking self.walk_textures = [] for i in range(8): texture = arcade.load_texture_pair(f"{main_path}_walk{i}.png") self.walk_textures.append(texture) # Set the initial texture self.texture = self.idle_texture_pair[0] # Hit box will be set based on the first image used. self.hit_box = self.texture.hit_box_points # Default to face-right self.character_face_direction = RIGHT_FACING # Index of our current texture self.cur_texture = 0 # How far have we traveled: self.x_odometer = 0 # since changing texture self.y_odometer = 0 # since jumping
def __init__(self, name): super().__init__() partial_path = "assets/" if name == "main_char": partial_path += "main_char_walking" self.char = True elif name == "main_char_mask": partial_path += "main_char_mask_walking" self.char = True elif name == "main_char_gas": partial_path += "main_char_gas_walking" self.char = True elif name == "hazmat": partial_path += "hazmat_walking" self.char = True elif name == "fatman": partial_path += "fatman_walking" self.char = False elif name == "karen": partial_path += "karen_walking" self.char = False elif name == "employee": partial_path += "employee_walking" self.char = False else: raise Exception("Name provided for entity didn't match: " + name) if self.char: self.scale = constants.SCALING_ENTITY else: self.scale = constants.SCALING_TILES self.num = 0 self.stand_right = arcade.load_texture_pair( f"{partial_path}/1.png") self.jump_right = arcade.load_texture_pair( f"{partial_path}/5.png") self.walk_right = [] fns = os.listdir(f"{partial_path}/") fns.sort(key=lambda fn: int(fn[:len(fn) - 4])) for fn in fns: self.walk_right.append(arcade.load_texture_pair( f"{partial_path}/{fn}")) # Initial self.facing_left = 0 self.texture = self.stand_right[self.facing_left] self.hit_box = self.texture.hit_box_points # Sets it based on first one self.distance_travelled_with_texture = 0 self.walk_curr_index = 0
def __init__(self): super().__init__() self.dead_zone = 0.1 # constants used to track if the player if facing left or right self.right_facing = 0 self.left_facing = 1 self.distance_to_change_texture = 20 self.scale = 0.5 # Images from Kenney.nl's Character pack # main_path = ":resources:images/animated_characters/female_adventurer/femaleAdventurer" # main_path = ":resources:images/animated_characters/female_person/femalePerson" # main_path = ":resources:images/animated_characters/male_person/malePerson" # main_path = ":resources:images/animated_characters/male_adventurer/maleAdventurer" # main_path = ":resources:images/animated_characters/zombie/zombie" main_path = ":resources:images/animated_characters/robot/robot" # Load textures for idle standing self.idle_texture_pair = ac.load_texture_pair(f"{main_path}_idle.png") self.jump_texture_pair = ac.load_texture_pair(f"{main_path}_jump.png") self.fall_texture_pair = ac.load_texture_pair(f"{main_path}_fall.png") # Load textures for walking self.walk_textures = [] for i in range(8): texture = ac.load_texture_pair(f"{main_path}_walk{i}.png") self.walk_textures.append(texture) # Set the initial texture self.texture = self.idle_texture_pair[0] # Hit box will be set based on the first image used. self.hit_box = self.texture.hit_box_points self.character_face_direction = self.right_facing self.cur_texture = 0 # how far have we traveled horizontally since changing the texture self.x_odometer = 0
def load_textures(self): # Load textures for idle standing for i in range(1, 5): self.idle_list.append( arcade.load_texture_pair(f"{self.main_path}_{i}.png")) self.texture = self.idle_list[0][0] # Hit box will be set based on the first image used. If you want to specify # a different hit box, you can do it like the code below. # self.set_hit_box([[-22, -64], [22, -64], [22, 28], [-22, 28]]) self.set_hit_box(self.texture.hit_box_points)
def __init__(self): super().__init__() self.center_x = int(constants.SCREEN_WIDTH - 350) self.center_y = int(constants.SCREEN_HEIGHT - 375) self.change_x = 0 self.change_y = 0 self.alive = True self.scale = constants.CHARACTER_SCALING self.main_path = "cse210-FinalProject/bedhead/assets/Individual_Sprites/adventurer" self.idle_texture_pair = arcade.load_texture_pair( f"{self.main_path}-idle-00.png") self.jump_texture_pair = arcade.load_texture_pair( f"{self.main_path}-jump-02.png") self.fall_texture_pair = arcade.load_texture_pair( f"{self.main_path}-fall-01.png") # Set the initial texture self.texture = self.idle_texture_pair[0] # Hit box will be set based on the first image used. self.hit_box = self.texture.hit_box_points # Default to face-right self.character_face_direction = constants.RIGHT_FACING # Index of our current texture self.cur_texture = 0 # How far have we traveled horizontally since changing the texture self.x_odometer = 0 self.idle_textures = [] for i in range(3): texture = arcade.load_texture_pair( f"{self.main_path}-idle-0{i}.png") self.idle_textures.append(texture) self.walk_textures = [] for i in range(6): texture = arcade.load_texture_pair( f"{self.main_path}-run-0{i}.png") self.walk_textures.append(texture)
def __init__(self, x, y, scale, inv: Inventory): super().__init__(scale=scale) # path to texture folder texture_path = "resources/sprites/Dungeon_Character_2/sprite_01.png" self.textures = arcade.load_texture_pair(texture_path) self.texture = self.textures[1] self.center_x, self.center_y = x, y self.direction = 1 self.holding_candle = False self.candle = None self.inv = inv
def __init__(self, x, y): super().__init__("resources/sprites/dagger_slash/0.png", scale=.5) self.center_x, self.center_y = x, y self.path = "resources/sprites/dagger_slash/" self.animation_length = 4 self.animation_speed = 5 self.textures = [ arcade.load_texture_pair(f"{self.path}{x}.png") for x in range(self.animation_length) ] self.cur_texture_index = 0 self.frame = 0 self.complete = False self.direction = 0
def __init__(self): # Call the parent class super().__init__() # Define player scale self.scale = SPRITE_SCALE # Define main path of player model main_path = "Player/player" # Load idle, fall and jump animation self.idle_texture_pair = arcade.load_texture_pair( f"{main_path}_idle.png") self.jump_texture_pair = arcade.load_texture_pair( f"{main_path}_jump.png") self.fall_texture_pair = arcade.load_texture_pair( f"{main_path}_fall.png") # Load textures for walking self.walk_textures = [] for x in range(8): texture = arcade.load_texture_pair(f"{main_path}_walk{x}.png") self.walk_textures.append(texture) # Set the initial texture self.texture = self.idle_texture_pair[0] # Hit box will be set based on the first image used. self.hit_box = self.texture.hit_box_points # Default to face-right self.character_face_direction = RIGHT_FACING # Index of our current texture self.current_texture = 0 # How far have we traveled horizontally since changing the texture self.x_odometer = 0
def __init__(self): # Set up parent class super().__init__() # Default to face-right self.character_face_direction = RIGHT_FACING # Used for flipping between image sequences self.cur_texture = 0 self.scale = CHARACTER_SCALING # Adjust the collision box. Default includes too much empty space # side-to-side. Box is centered at sprite center, (0, 0) # --- Load Textures --- # Images from Kenney.nl's Asset Pack 3 main_path = ":resources:images/animated_characters/male_adventurer/maleAdventurer" # main_path = ":resources:images/animated_characters/female_person/femalePerson" # main_path = ":resources:images/animated_characters/male_person/malePerson" # main_path = ":resources:images/animated_characters/female_adventurer/femaleAdventurer" # main_path = ":resources:images/animated_characters/zombie/zombie" # main_path = ":resources:images/animated_characters/robot/robot" # Load textures for idle standing self.idle_texture_pair = arcade.load_texture_pair( f"{main_path}_idle.png", hit_box_algorithm='Detailed') self.texture = self.idle_texture_pair[0] self.hit_box = self.texture.hit_box_points # Load textures for walking self.walk_textures = [] for i in range(8): texture = arcade.load_texture_pair(f"{main_path}_walk{i}.png") self.walk_textures.append(texture) self.climbing_textures = [ arcade.load_texture_pair(f'{main_path}_climb0.png'), arcade.load_texture_pair(f'{main_path}_climb1.png') ] self.jumping_texture_pair = arcade.load_texture_pair( f'{main_path}_jump.png') self.falling_texture_pair = arcade.load_texture_pair( f'{main_path}_fall.png')
def __init__(self, position, game_resources, scene_renderer): # Set up parent class super().__init__(position) self.game_resources = game_resources self.main_path = "Graphics/Character_animation/Acolyte/player_animation_down_idle" self.load_textures() self.up_pressed = False self.down_pressed = False self.left_pressed = False self.right_pressed = False self.x_force = 0 self.y_force = 0 self.speed = 40 self.candles = 0 self.walk_textures = [] walk_path = 'Graphics/Character_animation/Acolyte/player_animation_down_walk' for i in range(1, 5): self.walk_textures.append(arcade.load_texture_pair( f"{walk_path}_{i}.png" )) self.player_light = scene_renderer.light_renderer.create_point_light( (400, 400), # Position ( 1.75, 1.75, 1.75, ), # Color, 0 = black, 1 = white, 0.5 = grey, order is RGB This can go over 1.0 because of HDR 160.0, ) # Radius # player heath system self.player_health = Health( self.player_light, scene_renderer.post_processing )
def on_update(self, dt): if self.immune_for > 0: self.immune_for -= dt else: self.immune_for = 0 # DEALING WITH MOVEMENT self.enemy_list.update() if self.window.score >= self.window.goal: self.cashier.texture = arcade.load_texture_pair( "assets/cashier/open.png")[0] self.cashier.update() if arcade.check_for_collision(self.player, self.cashier) and self.window.score >= self.window.goal: game_win = WinView.WinView() self.window.show_view(game_win) for enemy in self.enemy_list: # If the enemy hit the left boundary, reverse if enemy.boundary_left is not None and enemy.left < enemy.boundary_left: enemy.facing_left = 0 enemy.walk_curr_index = 0 enemy.change_x *= -1 enemy.move_enemy() # If the enemy hit the right boundary, reverse elif enemy.boundary_right is not None and enemy.right > enemy.boundary_right: enemy.facing_left = 1 enemy.walk_curr_index = 0 enemy.change_x *= -1 enemy.move_enemy() else: enemy.num += 1 if enemy.num % 10 == 0: enemy.walk_curr_index += 1 enemy.move_enemy() # TP TP_hit_list = arcade.check_for_collision_with_list( self.player, self.window.item_list) for TP in TP_hit_list: TP.remove_from_sprite_lists() self.window.score += 1 grounded = self.physics_engine.is_on_ground(self.player) if self.left_pressed and not self.right_pressed: if grounded: # Might have vertical movement, but force APPLIED is zero f = (-constants.PLAYER_MOVE_FORCE_GROUND, 0) else: f = (-constants.PLAYER_MOVE_FORCE_AIR, 0) self.physics_engine.set_friction(self.player, 0) self.physics_engine.apply_force(self.player, f) elif self.right_pressed and not self.left_pressed: if grounded: # Might have vertical movement, but force APPLIED is zero f = (constants.PLAYER_MOVE_FORCE_GROUND, 0) else: f = (constants.PLAYER_MOVE_FORCE_AIR, 0) self.physics_engine.set_friction(self.player, 0) self.physics_engine.apply_force(self.player, f) else: # Stuck while holding both down self.physics_engine.set_friction(self.player, 1) self.physics_engine.step() # DEALING WITH VIEWPORT changed_viewport = False left_boundary = self.view_left + constants.VIEWPORT_MARGIN if self.player.center_x < left_boundary and self.view_left - (left_boundary - self.player.center_x) > 0: self.view_left -= left_boundary - self.player.center_x changed_viewport = True right_boundary = self.view_left + self.window.w - constants.VIEWPORT_MARGIN if self.player.center_x > right_boundary and self.view_left + (self.player.center_x - right_boundary) + self.window.w < constants.LEVEL_WIDTH: self.view_left += self.player.center_x - right_boundary changed_viewport = True if changed_viewport: self.view_left = int(self.view_left) # Scroll arcade.set_viewport( self.view_left, self.window.w + self.view_left, 0, self.window.h) if len(arcade.check_for_collision_with_list(self.player, self.enemy_list)) > 0: if self.immune_for <= 0: self.immune_for = 3 if self.window.fx_on: # sounds.sneeze.play() sounds.grunt.play() self.window.hits_left -= 1 if self.window.hits_left <= 0: view = LoseView.LoseView() self.window.show_view(view) else: game_view = GameView() game_view.setup() self.window.show_view(game_view) if self.player.center_y < 0: game_view = GameView() game_view.setup() self.window.show_view(game_view)
def __init__(self): # set up parent class super().__init__() self._hit_box_algorithm = "Detailed" self.character_face_direction = RIGHT_FACING self.cur_texture = 0 self.spawnpoint = [0, 0] self.health = 0 self.default_color = [255, 255, 255, 255] self.color = [0, 0, 0, 0] # color is RGBA, 4th int being opacity between 0-255 self.took_damage = False self.time_last_hit = 0 self.time_last_launched = 0 self.crouching = False # is the player crouching? self.default_points = [[-40, -60], [40, -60], [40, 50], [-40, 50]] self.adjusted_hitbox = False # this is a "latch", used for handling crouching. self.current_y_velocity = 0 self.ball_dashing = False # do ball dashing when true self.ball_dash_released = True # toggle True if player has let go of key combo for dashing self.ball_dash_reset = False self.collision_radius = 0 self.angle = 0 self.in_water = False self.jumping = False # is the player jumping? self.jumped_max_height = False self.scale = SPRITE_SCALING # How far have we traveled horizontally since changing the texture self.x_odometer = 0 # How far have we traveled vertically since changing the texture self.y_odometer = 0 main_path = "sprites/player_sprites/player" # add idle texture self.idle_texture_pair = ar.load_texture_pair(f"{main_path}_idle.png") # add crouching texture self.crouching_texture_pair = ar.load_texture_pair( f"{main_path}_ball.png") # add jumping texture self.jumping_texture_pair = ar.load_texture_pair( f"{main_path}_jumping.png") # add swimming texture self.swimming_textures = [] for i in range(1, 5): texture = ar.load_texture_pair(f"{main_path}_swimming{i}.png") self.swimming_textures.append(texture) # add dashing sprites to list self.dashing_textures = [] for i in range(1, 12): texture = ar.load_texture_pair(f"{main_path}_dashing{i}.png") self.dashing_textures.append(texture) # add walking sprites to list self.walking_textures = [] for i in range(1, 15): texture = ar.load_texture_pair(f"{main_path}walking{i}.png") self.walking_textures.append(texture) self.texture = self.idle_texture_pair[0] self.set_hit_box(self.texture.hit_box_points) # load sounds self.footstep_sound = ar.load_sound("sounds/footstep.wav") self.jump_sound = ar.load_sound("sounds/jump1.wav")
import arcade import glob from util import get_tile_set # MONSTER water_vole_0 = arcade.load_texture_pair(r"image/character/monster/water_vole0.png") water_vole_1 = arcade.load_texture_pair(r"image/character/monster/water_vole1.png") water_vole =[*water_vole_0, *water_vole_1] cabbage_snail_0 = arcade.load_texture_pair(r"image/character/monster/cabbage_snail0.png") cabbage_snail_1 = arcade.load_texture_pair(r"image/character/monster/cabbage_snail1.png") cabbage_snail =[*cabbage_snail_0, *cabbage_snail_1] dog_1 = arcade.load_texture_pair(r"image\character\monster\dog1.png") dog_2 = arcade.load_texture_pair(r"image\character\monster\dog2.png") dog = [*dog_1, *dog_2] goblin_shaman_0 = arcade.load_texture_pair(r"image\character\monster\goblin_shaman_0.png") goblin_shaman_1 = arcade.load_texture_pair(r"image\character\monster\goblin_shaman_1.png") goblin_shaman = [*goblin_shaman_0, *goblin_shaman_1] ssr1 = arcade.load_texture_pair(r"image\character\monster\ssr1.png") ssr2 = arcade.load_texture_pair(r"image\character\monster\ssr2.png") ssr = [*ssr1, *ssr2] # FLOWER # silver_grass = arcade.load_texture_pair(r"image\items\flower\silver_grass.png") bambooflower = arcade.load_texture(r"image\items\flower\bambooflower.png")