def __init__(self, location): anim = open(config.frog.head_file) images = [ pygame.image.load(config.assets_folder + frame.rstrip()) for frame in anim ] web_image = pygame.image.load(config.frog.webbed_image) self.head = Frog.Head(images, web_image, config.frog.head_center) self.image = pygame.image.load(config.frog.body_image) self.web_image = pygame.image.load(config.frog.webbed_body_image) self.rect = self.image.get_rect(midbottom=location) self.head.rect.center = self.rect.topleft + Vec2d( self.head.rect.size) / 2 self.hp = 10 self.frames = 0 self.aim_time = frame_seconds(config.frog.time_aiming) self.charge_time = frame_seconds(config.frog.time_charging) self.shoot_time = frame_seconds(config.frog.time_shooting) self.shoot_clock = self.aim_time self.direction = directions.left self.shooting_state = shoot_states.aiming self.target_location = Vec2d(0, 0) self.range = config.frog.fire_range self.tongue = None self.webbed = 0 all_frogs.append(self)
def __init__(self, location): anim = open(config.frog.head_file) images = [pygame.image.load(config.assets_folder + frame.rstrip()) for frame in anim] web_image = pygame.image.load(config.frog.webbed_image) self.head = Frog.Head(images, web_image, config.frog.head_center) self.image = pygame.image.load(config.frog.body_image) self.web_image = pygame.image.load(config.frog.webbed_body_image) self.rect = self.image.get_rect(midbottom = location) self.head.rect.center = self.rect.topleft + Vec2d(self.head.rect.size)/2 self.hp = 10 self.frames = 0 self.aim_time = frame_seconds(config.frog.time_aiming) self.charge_time = frame_seconds(config.frog.time_charging) self.shoot_time = frame_seconds(config.frog.time_shooting) self.shoot_clock = self.aim_time self.direction = directions.left self.shooting_state = shoot_states.aiming self.target_location = Vec2d(0, 0) self.range = config.frog.fire_range self.tongue = None self.webbed = 0 all_frogs.append(self)
def kill(self): self.dead_time = frame_seconds(config.spider.dead_time) if not config.spider.infinite_lives: self.lives -= 1 self.invuln = frame_seconds(config.spider.invuln_time) + self.dead_time if self.fling_object is not None: self.fling(None) if self.web_enemy is not None: self.web_enemy = None self.web_enemy_time = 0 self.respawn_location = self.rect.center + Vec2d(self.dead_time, 0) self.rect.center = 0, 0
def __init__(self, parent): anim = open(config.spider.free_movement.file) self.free_movement_frames = [pygame.image.load(config.assets_folder + frame.rstrip()) for frame in anim] anim = open(config.spider.web_movement.file) self.web_movement_frames = [pygame.image.load(config.assets_folder + frame.rstrip()) for frame in anim] anim.close() self.web_ball = pygame.image.load(config.spider.web_ball_image) self.rect = self.free_movement_frames[0].get_rect(center = config.spider.starting_postion) self.movement_target = Vec2d(config.spider.starting_postion) self.movement = False self.movement_state = movement_states.free_movement self.parent = parent self.position_on_web = 0 #used for web movement self.angle = 0 self.frame = 0 self.charge = Charge() self.fling_object = None self.lives = config.spider.starting_lives self.invuln = 0 self.dead_time = 0 #countdown timer self.blink_time = 0 self.respawn_location = None self.web_enemy = None self.web_enemy_time = 0 self.min_web_enemy_time = frame_seconds(config.spider.min_enemy_web_time) self.web_ball_angle = 0
def __init__(self, xloc, yloc): self.image = self.images[0] self.rect = self.image.get_rect(topleft=(xloc, yloc)) self.vel = Vec2d(config.wasp.velocicty) self.bullet_clock = 0 self.move_clock = 0 self.frame = 0 self.frame_clock = 0 self.dead = False self.webbed = False self.moving = False self.web_clock = frame_seconds(config.wasp.web_time) self.move_time = config.wasp.move_time self.frames = config.wasp.frame_rate all_wasps.append(self)
def __init__(self, xloc, yloc): self.image = self.images[0] self.rect = self.image.get_rect(topleft = (xloc, yloc)) self.vel = Vec2d(config.wasp.velocicty) self.bullet_clock = 0 self.move_clock = 0 self.frame = 0 self.frame_clock = 0 self.dead = False self.webbed = False self.moving = False self.web_clock = frame_seconds(config.wasp.web_time) self.move_time = config.wasp.move_time self.frames = config.wasp.frame_rate all_wasps.append(self)
def web(self): self.webbed = True self.web_clock = frame_seconds(config.wasp.web_time)
def web(self): if self.shooting_state != shoot_states.shooting: self.webbed = frame_seconds(config.frog.time_webbed) self.shooting_state = shoot_states.aiming self.shoot_clock = 0
def update(self): self.charge += 1.0/frame_seconds(config.spider.venom_regen_time) if self.charge > 1: self.charge = 1.0
def __init__(self, victim): self.victim = victim self.timer = frame_seconds(config.bomb.explode_time) all_bombs.append(self)