class Kemul(Player): def __init__(self, x, y, handler): health = 1100 damage = 50 win_quote = "Chewbacca" lose_quote = "Chewbacca" name = "Kemul" defense = .7 movespeed = 5 super().__init__(health, damage, win_quote, lose_quote, name, x, y, movespeed, handler.getPlatformArray(), handler.getAttackList(), handler, defense) self.special_active = False self.special_cooldown = Cooldown(3) self.special_duration = Cooldown(2) self.caravan_sprite = pygame.image.load( "media/Players/Kemul/Kemul 2.png").convert_alpha() self.caravan_x = 1100 self.caravan_y = 0 self.caravan_loaded = True def special(self): if self.special_cooldown.isDone(): self.special_active = True self.caravan_y = self.handler.getOtherPlayer(self).rect.y def update(self, screen): super().update(screen) if not self.special_cooldown.isDone(): self.special_cooldown.update() if self.special_active and not self.sleeping: self.special_duration.update() if not self.special_duration.isDone(): self.caravan_x -= 20 screen.blit(self.caravan_sprite, [self.caravan_x, self.caravan_y]) if -15 < (self.handler.getOtherPlayer(self).rect.x - self.caravan_x) < 15 and -15 < ( self.handler.getOtherPlayer(self).rect.y - self.caravan_y) < 15 and self.caravan_loaded: self.handler.getOtherPlayer(self).takeTrueDamage(100) self.caravan_loaded = False else: self.special_active = False self.caravan_x = 1100 self.caravan_loaded = True self.special_cooldown.update()
class David(Player): def __init__(self, x, y, handler): health = 1200 damage = 75 win_quote = "I always start the party" lose_quote = "Zzz" name = "David" defense = .4 movespeed = 3 self.handler = handler super().__init__(health, damage, win_quote, lose_quote, name, x, y, movespeed, handler.getPlatformArray(), handler.getAttackList(), handler, defense) self.attacksprite = pygame.image.load( "media/Players/David/DavidAttack.png").convert_alpha() self.specialsprite = pygame.image.load( "media/Players/David/DavidSpecial.png").convert_alpha() # special self.special_cooldown = Cooldown(5) self.special_duration = Cooldown(1) self.special_active = False self.targetMoveSpeed = 0 def special(self): if self.special_cooldown.isDone(): self.special_active = True def update(self, screen): super().update(screen) if not self.special_cooldown.isDone(): self.special_cooldown.update() if self.special_active and not self.sleeping: self.special_duration.update() if not self.special_duration.isDone(): screen.blit(self.specialsprite, (0, 0)) if self.handler.getPlayer1().name == "David": self.handler.getPlayer2().stunned = True if self.handler.getPlayer2().name == "David": self.handler.getPlayer1().stunned = True else: self.special_active = False if self.handler.getPlayer1().name == "David": self.handler.getPlayer2().stunned = False if self.handler.getPlayer2().name == "David": self.handler.getPlayer1().stunned = False self.special_cooldown.update()
class Smo(Player): def __init__(self, x, y, handler): health = 1100 damage = 50 win_quote = "up to the board" lose_quote = "this will delay my victory" name = "Smo" defense = .5 movespeed = 5 super().__init__(health, damage, win_quote, lose_quote, name, x, y, movespeed, handler.getPlatformArray(), handler.getAttackList(), handler, defense) self.special_active = False self.special_range = 300 self.startdefense = defense self.rangedcount = 0 self.rangedavailable = True self.attackavailable = True self.special_available = True self.special_cooldown = Cooldown(5) self.special_duration = Cooldown(3) self.damage = damage self.pundatabase = PunDatabase() self.pun = self.pundatabase.getRandomPun() self.target_health_update() def GeneratePun(self): self.pun = self.pundatabase.getRandomPun() def special(self): if self.special_cooldown.isDone(): self.special_active = True def target_health_update(self): if self.handler.getPlayer1().name == "Smo": self.target_health = self.handler.getPlayer2().health else: self.target_health = self.handler.getPlayer1().health def update(self, screen): super().update(screen) if not self.special_cooldown.isDone(): self.special_cooldown.update() if self.special_active and not self.sleeping: self.special_duration.update() screen.blit(font.render(self.pun, False, colors.get("BLACK")), (self.rect.x, self.rect.y - 100)) if self.handler.getPlayer1().name == "Smo": if abs(self.rect.x - self.handler.getPlayer2().rect.x) <= self.special_range and abs(self.rect.y - self.handler.getPlayer2().rect.y) <= self. special_range: if (self.target_health - 10) <= self.handler.getPlayer2().health: self.handler.player2.takeDamage(50) if self.handler.getPlayer2().name == "Smo": if abs(self.rect.x - self.handler.getPlayer1().rect.x) <= self.special_range and abs(self.rect.y - self.handler.getPlayer1().rect.y) <= self.special_range: if (self.target_health - 10) <= self.handler.getPlayer1().health: self.handler.player1.takeDamage(50) if self.special_duration.isDone(): self.GeneratePun() self.special_cooldown.update() self.target_health_update() self.special_active = False
class Reynaldo(Player): def __init__(self, x, y, handler): health = 1000 damage = 100 win_quote = "Pog Champerino!!!!" lose_quote = "I was lagging!" name = "Reynaldo" movespeed = 6 defense = .5 self.handler = handler super().__init__(health, damage, win_quote, lose_quote, name, x, y, movespeed, handler.getPlatformArray(), handler.getAttackList(), handler, defense) self.ranged_cooldown = Cooldown(1.5) self.ranged_count = 0 self.ranged_active = False self.start_tick = 0 self.special_sprite = pygame.image.load("media/Players/Reynaldo/ReynaldoSpecial.png").convert_alpha() self.special_sprite_rect = self.special_sprite.get_rect() self.special_active = False self.start_pos = [] self.special_count = 0 self.special_travel_speed = 20 self.special_range = 800 self.special_stage = 1 self.special_cooldown = Cooldown(5) self.special_hit = False self.start_direction = 0 def attack(self, screen): if self.ranged_cooldown.isDone(): self.ranged_active = True def special(self): if self.special_cooldown.isDone(): self.special_active = True # A BIG OLD BOOMERANG AHRI Q THAT DOESNT DO DAMAGE ON THE WAY OUT BUT A LOTTA DAMAGE ON THE WAY BACK def update(self, screen): super().update(screen) screen.blit(self.sprite, [self.rect.x, self.rect.y]) if self.ranged_cooldown.isDone() and self.ranged_active: if self.ranged_count == 0: self.start_tick = self.handler.getTick() self.ranged_count += 1 if (self.handler.getTick() - self.start_tick) % 5 == 0: self.handler.getAttackList().add(Attack(self, self.damage, self.handler)) if (self.handler.getTick() - self.start_tick) == 10: self.ranged_cooldown.update() if not self.ranged_cooldown.isDone(): self.ranged_cooldown.update() self.ranged_count = 0 self.ranged_active = False if self.special_active: if self.special_count == 0: self.start_pos = [self.rect.x, self.rect.y] self.special_sprite_rect.x = self.rect.x self.special_sprite_rect.y = self.rect.y - 30 self.special_count += 1 self.start_direction = self.facing screen.blit(self.special_sprite, [self.special_sprite_rect.x, self.special_sprite_rect.y]) if abs(self.start_pos[0] - self.special_sprite_rect.x) >= self.special_range: self.special_stage = 2 if self.special_stage is 1: self.movespeed = 10 if self.start_direction == 1: self.special_sprite_rect.x += self.special_travel_speed if self.start_direction == -1: self.special_sprite_rect.x -= self.special_travel_speed if self.special_stage is 2: pygame.transform.rotate(self.special_sprite, 10) x_dist = self.special_sprite_rect.x - self.rect.x y_dist = self.special_sprite_rect.y - self.rect.y + 30 xy_dist = math.sqrt((x_dist * x_dist) + (y_dist * y_dist)) y_angle = math.asin(x_dist / xy_dist) x_angle = math.acos(y_dist / xy_dist) x_speed = self.special_travel_speed * math.sin(y_angle) y_speed = self.special_travel_speed * math.cos(x_angle) if pygame.Rect.colliderect(self.special_sprite_rect, self.rect): self.special_stage = 3 if pygame.Rect.colliderect(self.handler.getOtherPlayer(self).rect, self.special_sprite_rect) and not self.special_hit: self.handler.getOtherPlayer(self).takeTrueDamage(200) self.special_hit = True self.special_sprite_rect.x -= x_speed self.special_sprite_rect.y -= y_speed if self.special_stage is 3: self.special_count = 0 self.special_stage = 1 self.special_active = False self.special_hit = False self.movespeed = 6 self.special_cooldown.update() if not self.special_cooldown.isDone(): self.special_cooldown.update()
class Greg(Player): def __init__(self, x, y, handler): health = 1000 damage = 75 win_quote = "Broken like Katarina" lose_quote = "I don't even care" name = "Greg" movespeed = 5 defense = .7 super().__init__(health, damage, win_quote, lose_quote, name, x, y, movespeed, handler.getPlatformArray(), handler.getAttackList(), handler, defense) self.count = 0 self.special_active = False self.special_cooldown = Cooldown(5) self.special_duration = Cooldown(1) self.attacksprite = pygame.image.load("media/Misc/fist.png").convert() self.specialsprite = pygame.image.load( "media/Players/Greg/GregSpecial.png").convert() self.specialframe1 = pygame.image.load( "media/Players/Greg/GregSpecial1.png").convert_alpha() self.specialframe2 = pygame.image.load( "media/Players/Greg/GregSpecial2.png").convert_alpha() self.specialnum = 1 self.damage_ranged = 200 self.damage_special = 125 self.startgravity = self.gravity self.attacking = False self.attackcount = 0 self.attackradius = 100 self.ranged_cooldown = Cooldown(2) self.walk_animation_delay = 8 # Animation self.walkSpriteList = [ pygame.image.load("media/Players/Greg/Greg1.png").convert_alpha(), pygame.image.load("media/Players/Greg/Greg2.png").convert_alpha(), pygame.image.load("media/Players/Greg/Greg3.png").convert_alpha(), pygame.image.load("media/Players/Greg/Greg4.png").convert_alpha() ] self.walkAnimation = Animation(self.handler, self, self.walkSpriteList) self.animation_manager = AnimationManager(self, self.walkAnimation) def attack(self, screen): if self.ranged_cooldown.isDone(): self.attacking = True targetPlayer = self.handler.getOtherPlayer(self) if self.facing == 1: if self.rect.x <= 900 - self.width: self.rect.x += 200 elif self.rect.x > 900 - self.width: self.rect.x += (1100 - self.rect.x - self.width) if self.attackradius + ( self.width * .5 ) >= targetPlayer.rect.x - self.rect.x >= -self.attackradius + ( self.width * .5) and self.attackradius + ( self.width * .5) >= self.handler.getPlayer2( ).rect.y - self.rect.y >= -self.attackradius + ( self.width * .5): targetPlayer.takeDamage(self.damage_ranged) self.gregMeleeHit.playSound() if self.facing == -1: if self.rect.x >= 200: self.rect.x += -200 elif self.rect.x < 200: self.rect.x += -self.rect.x if 150 >= targetPlayer.rect.x - self.rect.x >= -150 and 150 >= targetPlayer.rect.y - self.rect.y >= -150: targetPlayer.takeDamage(self.damage_ranged) self.gregMeleeHit.playSound() self.ranged_cooldown.update() def special(self): if self.special_cooldown.isDone(): self.special_active = True def moveX(self): self.rect.x += self.xchange platList = pygame.sprite.spritecollide(self, self.platArray, False) for platform in platList: if self.xchange > 0 and self.rect.right < platform.rect.right: # Moving right and left of platform self.rect.right = platform.rect.left elif self.xchange < 0 and self.rect.left > platform.rect.left: # Moving left and right of platform self.rect.left = platform.rect.right self.xchange = 0 def duck(self): self.gravity = 1 def unduck(self): self.gravity = .25 def update(self, screen): self.animation_manager.update() if not self.ranged_cooldown.isDone(): self.ranged_cooldown.update() if self.attacking: if self.attackcount % 2 == 1: screen.blit(self.specialframe1, (self.rect.x - 125, self.rect.y - 125)) if self.attackcount % 2 == 0: screen.blit(self.specialframe2, (self.rect.x - 125, self.rect.y - 125)) self.attackcount += 1 if self.attackcount > 6: self.attacking = False self.attackcount = 1 if not self.special_active: super().update(screen) if not self.special_cooldown.isDone(): self.special_cooldown.update() if self.special_active and not self.sleeping: self.sprite = self.specialsprite self.special_duration.update() if not self.special_duration.isDone(): self.specialnum += 1 if self.specialnum > 8: self.specialnum = 1 self.xchange = 0 self.ychange = 0 self.gravity = 0 if self.specialnum == 1: self.handler.getAttackList().add( CustomAttack(self, self.damage_special, self.handler, 15, 0)) if self.specialnum == 2: self.handler.getAttackList().add( CustomAttack(self, self.damage_special, self.handler, 15, 15)) if self.specialnum == 3: self.handler.getAttackList().add( CustomAttack(self, self.damage_special, self.handler, 0, 15)) if self.specialnum == 4: self.handler.getAttackList().add( CustomAttack(self, self.damage_special, self.handler, -15, 15)) if self.specialnum == 5: self.handler.getAttackList().add( CustomAttack(self, self.damage_special, self.handler, -15, 0)) if self.specialnum == 6: self.handler.getAttackList().add( CustomAttack(self, self.damage_special, self.handler, -15, -15)) if self.specialnum == 7: self.handler.getAttackList().add( CustomAttack(self, self.damage_special, self.handler, 0, -15)) if self.specialnum == 8: self.handler.getAttackList().add( CustomAttack(self, self.damage_special, self.handler, 15, -15)) if self.special_duration.isDone(): self.special_active = False self.gravity = self.startgravity self.sprite = self.stansprite self.sprite = self.stansprite self.special_cooldown.update() screen.blit(self.sprite, [self.rect.x, self.rect.y])
class Jarod(Player): def __init__(self, x, y, handler): health = 1100 damage = 15 win_quote = "yikes" lose_quote = "yikes" name = "Jarod" defense = .5 movespeed = 4 super().__init__(health, damage, win_quote, lose_quote, name, x, y, movespeed, handler.getPlatformArray(), handler.getAttackList(), handler, defense) self.special_active = False self.special_available = False self.special_cooldown = Cooldown(15) self.damage = damage self.rangedavailable = False self.released = True self.tick = 0 def attack(self, screen): self.rangedavailable = True def update(self, screen): if self.tick != 0: self.xchange /= 2 super().update(screen) if not self.special_cooldown.isDone(): self.special_cooldown.update() else: self.movespeed += 1 self.special_cooldown.update() if self.rangedavailable and not self.released: self.tick += 1 self.ranged_cooldown.current_cooldown = self.tick / 60 if self.ranged_cooldown.current_cooldown <= 1: if self.tick % 16 == 0: self.handler.getAttackList().add( CustomAttack(self, self.damage, self.handler, 12 * self.facing, 0)) elif self.ranged_cooldown.current_cooldown <= 2: if self.tick % 12 == 0: self.handler.getAttackList().add( CustomAttack(self, self.damage, self.handler, 12 * self.facing, random.randint(-2, 2))) elif self.ranged_cooldown.current_cooldown <= 3: if self.tick % 8 == 0: self.handler.getAttackList().add( CustomAttack(self, self.damage, self.handler, 12 * self.facing, random.randint(-4, 4))) elif self.ranged_cooldown.current_cooldown <= 4: if self.tick % 4 == 0: self.handler.getAttackList().add( CustomAttack(self, self.damage, self.handler, 12 * self.facing, random.randint(-6, 6))) elif self.ranged_cooldown.current_cooldown > 4: if self.tick % 2 == 0: self.handler.getAttackList().add( CustomAttack(self, self.damage, self.handler, 12 * self.facing, random.randint(-8, 8))) else: self.tick = 0
class Collin(Player): def __init__(self, x, y, handler): health = 1200 damage = 60 win_quote = "ROOOOOOSE" lose_quote = "at least I still have Kaitlin" name = "Collin" movespeed = 5 defense = .6 super().__init__(health, damage, win_quote, lose_quote, name, x, y, movespeed, handler.getPlatformArray(), handler.getAttackList(), handler, defense) self.handler = handler self.currenttick = 0 # attacks self.damage = damage self.attacking = False self.enemydistx = 0 self.enemydisty = 0 # media left_attack1 = pygame.image.load( "media/Players/Collin/CollinRangedLeft1.png").convert_alpha() left_attack2 = pygame.image.load( "media/Players/Collin/CollinRangedLeft2.png").convert_alpha() right_attack1 = pygame.image.load( "media/Players/Collin/CollinRangedRight1.png").convert_alpha() right_attack2 = pygame.image.load( "media/Players/Collin/CollinRangedRight2.png").convert_alpha() self.leftAnimation = CircularQueue() self.leftAnimation.addData(left_attack1) self.leftAnimation.addData(left_attack2) self.rightAnimation = CircularQueue() self.rightAnimation.addData(right_attack1) self.rightAnimation.addData(right_attack2) self.rightAttImg = self.rightAnimation.get() self.leftAttImg = self.leftAnimation.get() # special self.special_sprite = pygame.image.load( "media/Players/Collin/CollinSpecial.png") self.specialAnimation = CircularQueue() for i in range(0, 72): self.specialAnimation.addData( pygame.transform.rotate(self.special_sprite, i * 5)) self.special_cooldown = Cooldown(5) self.special_damage = 50 self.special_active = False def attack(self, screen): self.attacking = True def special(self): if self.special_cooldown.isDone(): self.special_active = True def update(self, screen): self.currenttick += 1 # original super().update(screen) # attacks if self.attacking and not self.released: self.movespeed = 2 targetPlayer = self.handler.getOtherPlayer(self) self.enemydistx = self.rect.x - targetPlayer.rect.x self.enemydisty = self.rect.y - targetPlayer.rect.y if self.facing == -1: if self.currenttick % 4 == 0: self.leftAttImg = self.leftAnimation.get() screen.blit(self.leftAttImg, (self.rect.x - 330, self.rect.y + 15)) if 330 > self.enemydistx > 0 and 30 >= self.enemydisty >= -30: if self.currenttick % 5 == 0: targetPlayer.takeDamage(self.damage) if self.facing == 1: if self.currenttick % 4 == 0: self.rightAttImg = self.rightAnimation.get() screen.blit(self.rightAttImg, (self.rect.x + self.width, self.rect.y + 15)) if 0 > self.enemydistx > -330 - self.width and 30 >= self.enemydisty >= -30: if self.currenttick % 5 == 0: targetPlayer.takeDamage(self.damage) else: self.movespeed = 5 if self.special_active and not self.stunned: if self.facing == 1: self.rose = CustomAttack(self, self.special_damage, self.handler, 15, -3, self.special_sprite, .15, self.specialAnimation) self.rose.rect.y -= 20 elif self.facing == -1: self.rose = CustomAttack(self, self.special_damage, self.handler, -15, -3, self.special_sprite, .15, self.specialAnimation) self.rose.rect.y -= 20 self.handler.getAttackList().add(self.rose) self.special_cooldown.update() if not self.special_cooldown.isDone(): self.special_active = False self.special_cooldown.update()
class JaccobBonkley(Player): def __init__(self, x, y, handler): health = 700 damage = 100 defense = .5 movespeed = 10 win_quote = "Spaghet saved me" lose_quote = "I wrote the spaghet" name = "JaccobBonkley" self.handler = handler super().__init__(health, damage, win_quote, lose_quote, name, x, y, movespeed, handler.getPlatformArray(), handler.getAttackList(), handler, defense) self.bullet_speed = 20 self.special_cooldown = Cooldown(3) self.special_duration = Cooldown(3) self.current_health = 0 self.number = 0 self.special_active = False self.keyboard = pygame.image.load("media/Misc/Keyboard.png").convert_alpha() self.keyboard2 = pygame.image.load("media/Misc/Keyboard2.png").convert_alpha() self.mr_smo = pygame.image.load("media/Players/Smo/Smo.png").convert_alpha() self.num = 0 self.walkSpriteList = [ pygame.image.load("media/Players/JaccobBonkley/JaccobBonkley.png").convert_alpha(), pygame.image.load("media/Players/JaccobBonkley/Bonkley2.png").convert_alpha(), pygame.image.load("media/Players/JaccobBonkley/Bonkley3.png").convert_alpha(), pygame.image.load("media/Players/JaccobBonkley/Bonkley4.png").convert_alpha() ] self.walkAnimation = Animation(self.handler, self, self.walkSpriteList) self.walk_animation_delay = 15 self.crouchSpriteList = [ pygame.image.load("media/Players/JaccobBonkley/JaccobBonkleyCrouch.png").convert_alpha(), pygame.image.load("media/Players/JaccobBonkley/BonkleyCrouch2.png").convert_alpha(), pygame.image.load("media/Players/JaccobBonkley/BonkleyCrouch3.png").convert_alpha(), pygame.image.load("media/Players/JaccobBonkley/BonkleyCrouch4.png").convert_alpha() ] self.crouchAnimation = Animation(self.handler, self, self.crouchSpriteList) self.crouch_animation_delay = 8 self.animation_manager = AnimationManager(self, self.walkAnimation, None, self.crouchAnimation) self.keyboardAnimation = CircularQueue() for a in range(0, -90, -5): self.keyboardAnimation.addData(pygame.transform.rotate(self.keyboard, a)) self.keyboardAnimation2 = CircularQueue() for b in range(-90, -180, -5): self.keyboardAnimation2.addData(pygame.transform.rotate(self.keyboard2, b)) def special(self): if self.special_cooldown.isDone(): self.current_health = self.health self.special_active = True self.number = random.randint(1, 5) if self.number == 5: self.special_duration = Cooldown(5) else: self.special_duration = Cooldown(.1) if not self.special_cooldown.isDone(): self.num = 0 def update(self, screen): self.animation_manager.update() super().update(screen) if not self.special_cooldown.isDone(): self.special_cooldown.update() if self.special_active and not self.sleeping: self.special_duration.update() if self.number != 5: if not self.special_duration.isDone(): if self.facing == 1: screen.blit(self.keyboardAnimation.get(), (self.rect.x + 70, self.rect.y - 50)) if self.handler.getPlayer1().name == "JaccobBonkley" and (self.handler.getPlayer2().rect.x - self.rect.x) <= 170 and (self.handler.getPlayer2().rect.x - self.rect.x) >= 0 and (self.handler.getPlayer2().rect.y - self.rect.y) <= 50: self.handler.player2.takeDamage(100) self.special_active = False if self.handler.getPlayer2().name == "JaccobBonkley" and (self.handler.getPlayer1().rect.x - self.rect.x) <= 170 and (self.handler.getPlayer1().rect.x - self.rect.x) >= 0 and (self.handler.getPlayer1().rect.y - self.rect.y) <= 50: self.handler.player1.takeDamage(100) self.special_active = False if self.facing == -1: screen.blit(self.keyboardAnimation2.get(), (self.rect.x - 70, self.rect.y - 50)) if self.handler.getPlayer1().name == "JaccobBonkley" and (self.rect.x - self.handler.getPlayer2().rect.x) <= 170 and (self.rect.x - self.handler.getPlayer2().rect.x) >= 0 and (self.handler.getPlayer2().rect.y - self.rect.y) <= 50: self.handler.player2.takeDamage(100) self.special_active = False if self.handler.getPlayer2().name == "JaccobBonkley" and (self.rect.x - self.handler.getPlayer1().rect.x) <= 170 and (self.rect.x - self.handler.getPlayer1().rect.x) >= 0 and (self.handler.getPlayer1().rect.y - self.rect.y) <= 50: self.handler.player1.takeDamage(100) self.special_active = False else: self.special_active = False self.handler.getPlayer1().stunned = False self.handler.getPlayer2().stunned = False self.special_cooldown.update() self.num = 0 else: if not self.special_duration.isDone(): self.handler.getPlayer1().stunned = True self.handler.getPlayer2().stunned = True if self.facing == 1: if self.num < (self.rect.x - 70): screen.blit(self.mr_smo, (self.num, self.rect.y - 15)) self.num += 10 else: screen.blit(self.mr_smo, (self.num, self.rect.y - 15)) screen.blit(self.keyboardAnimation.get(), (self.rect.x - 70, self.rect.y - 50)) if self.health != (self.current_health - 100): self.takeDamage(100) self.special_duration = Cooldown(.1) if self.facing == -1: if self.num < (1080 - self.rect.x): screen.blit(self.mr_smo, (1150 - self.num, self.rect.y - 15)) self.num += 10 else: screen.blit(self.mr_smo, (1150 - self.num, self.rect.y - 15)) screen.blit(self.keyboardAnimation2.get(), (self.rect.x + 70, self.rect.y - 50)) if self.health != (self.current_health - 100): self.takeDamage(100) self.special_duration = Cooldown(.1) else: self.special_active = False self.handler.getPlayer1().stunned = False self.handler.getPlayer2().stunned = False self.special_cooldown = Cooldown(3) self.special_cooldown.update() self.num = 0
class Shed(Player): def __init__(self, x, y, handler): health = 2000 damage = 75 win_quote = "OH YEAHHHH!" lose_quote = "IMPOSSIBLE!" name = "Lil' Shed" movespeed = 5 defense = .7 super().__init__(health, damage, win_quote, lose_quote, name, x, y, movespeed, handler.getPlatformArray(), handler.getAttackList(), handler, defense) # Misc self.tick = 0 self.jump_pressed = False self.duck_pressed = False # Ranged self.ranged_cooldown = Cooldown(0.5) # Special self.special_cooldown = Cooldown(3) self.special_active = False self.specialx = 5 self.specialy = 15 self.special_phase = 1 self.special_x_change = 1 self.special_y_change = 1 self.movingLeft = False self.movingRight = False self.gravity = 0 def special(self): if self.special_cooldown.isDone(): self.special_active = True def jump(self): self.jump_pressed = True self.jumpreleased = False def unjump(self): self.jumpreleased = True self.jump_pressed = False def duck(self): self.duck_pressed = True self.duckreleased = False def unduck(self): self.duckreleased = True self.duck_pressed = False def moveLeft(self): if self.xchange > self.movespeed * -1: self.xchange -= .2 self.movingLeft = True def moveRight(self): if self.xchange < self.movespeed: self.xchange += .2 self.movingRight = True def attack(self, screen): self.handler.getAttackList().add( Attack(self, self.damage * 4, self.handler)) def update(self, screen): self.tick += 1 if self.jump_pressed and not self.jumpreleased: self.ychange -= 0.2 if self.duck_pressed and not self.duckreleased: self.ychange += 0.2 if self.jumpreleased and round(self.ychange, 1) < 0: self.ychange += 0.1 if self.duckreleased and round(self.ychange, 1) > 0: self.ychange -= 0.1 if not self.movingLeft and round(self.xchange, 1) < 0: self.xchange += 0.1 if not self.movingRight and round(self.xchange, 1) > 0: self.xchange -= 0.1 if self.rect.y <= 0 and self.ychange < 0: self.ychange = 0 if self.special_active and not self.sleeping: self.rapidFire.playSound() self.movespeed = 0 self.ychange = 0 self.xchange = 0 if self.special_phase != 7: if self.tick % 2 == 0: self.handler.getAttackList().add( CustomAttack(self, self.damage, self.handler, self.specialx, self.specialy)) self.handler.getAttackList().add( CustomAttack(self, self.damage, self.handler, -self.specialx, self.specialy)) if self.special_phase == 1: self.special_x_change = 1 self.special_y_change = 1 if self.specialx >= 19: self.special_phase = 2 elif self.special_phase == 2: self.special_x_change = -1 self.special_y_change = 1 if self.specialx <= 3: self.special_phase = 3 elif self.special_phase == 3: self.special_x_change = 1 self.special_y_change = -1 if self.specialx >= 19: self.special_phase = 4 elif self.special_phase == 4: self.special_x_change = -1 self.special_y_change = -1 if self.specialx <= 5: self.special_phase = 5 elif self.special_phase == 5: self.special_x_change = 1 self.special_y_change = 1 if self.specialx >= 19: self.special_phase = 6 elif self.special_phase == 6: self.special_x_change = -1 self.special_y_change = 1 if self.specialx <= 3: self.special_phase = 7 self.specialx += self.special_x_change self.specialy -= self.special_y_change else: self.special_cooldown.update() self.movespeed = 5 self.special_active = False self.specialx = 5 self.specialy = 15 self.special_phase = 1 if not self.special_cooldown.isDone(): self.special_cooldown.update() super().update(screen) self.movingLeft = False self.movingRight = False
class Kyle(Player): def __init__(self, x, y, handler): health = 1100 damage = 150 win_quote = "Are the platforms fixed yet?" lose_quote = "I\'d better try to fix that... emphasis on try" name = "Kyle" defense = .6 movespeed = 5 super().__init__(health, damage, win_quote, lose_quote, name, x, y, movespeed, handler.getPlatformArray(), handler.getAttackList(), handler, defense) self.platformcount = 0 self.special_cooldown = Cooldown(3) self.spriteList = [ pygame.image.load("media/Players/Kyle/Kyle.png").convert_alpha(), pygame.image.load("media/Players/Kyle/Kyle1.png").convert_alpha(), pygame.image.load("media/Players/Kyle/Kyle2.png").convert_alpha(), pygame.image.load("media/Players/Kyle/Kyle3.png").convert_alpha(), pygame.image.load("media/Players/Kyle/Kyle4.png").convert_alpha(), pygame.image.load("media/Players/Kyle/Kyle5.png").convert_alpha(), pygame.image.load("media/Players/Kyle/Kyle6.png").convert_alpha(), pygame.image.load("media/Players/Kyle/Kyle7.png").convert_alpha() ] self.walkAnimation = Animation(self.handler, self, self.spriteList) self.walk_animation_delay = 1 self.crouchSpriteList = [ pygame.image.load( "media/Players/Kyle/KyleCrouch.png").convert_alpha(), pygame.image.load( "media/Players/Kyle/KyleCrouch1.png").convert_alpha(), pygame.image.load( "media/Players/Kyle/KyleCrouch2.png").convert_alpha(), pygame.image.load( "media/Players/Kyle/KyleCrouch3.png").convert_alpha(), pygame.image.load( "media/Players/Kyle/KyleCrouch4.png").convert_alpha(), pygame.image.load( "media/Players/Kyle/KyleCrouch5.png").convert_alpha(), pygame.image.load( "media/Players/Kyle/KyleCrouch6.png").convert_alpha(), pygame.image.load( "media/Players/Kyle/KyleCrouch7.png").convert_alpha() ] self.crouchAnimation = Animation(self.handler, self, self.crouchSpriteList) self.crouch_animation_delay = 1 self.animation_manager = AnimationManager(self, self.walkAnimation, None, self.crouchAnimation) self.frame = 0 def special(self): if self.special_cooldown.isDone(): if self.platformcount == 1: self.handler.getPlatformArray().remove(self.specialplatform) self.platformcount = 0 if 0 <= self.rect.x <= 1100 and 0 <= self.rect.y <= 800: self.specialplatform = Platform(self.screen, self.rect.x - 50, self.rect.y + self.height + 10, self.width + 100, 25, 1) self.handler.getPlatformArray().add(self.specialplatform) self.platformcount += 1 self.special_cooldown.update() def attack(self, screen): self.handler.getAttackList().add( Attack(self, self.damage, self.handler, 5)) def moveX(self): self.rect.x += self.xchange platList = pygame.sprite.spritecollide(self, self.platArray, False) for platform in platList: if self.xchange > 0 and self.rect.right < platform.rect.right: # Moving right and left of platform self.rect.right = platform.rect.left elif self.xchange < 0 and self.rect.left > platform.rect.left: # Moving left and right of platform self.rect.left = platform.rect.right self.xchange = 0 def update(self, screen): if not self.special_cooldown.isDone(): self.special_cooldown.update() self.animation_manager.update() super().update(screen) for p in self.handler.getPlatformArray(): if p.height == 25: pygame.draw.rect(screen, (random.randint(0, 255), random.randint( 0, 255), random.randint(0, 255)), p.rect)
class Will(Player): def __init__(self, x, y, handler): health = 1100 damage = 55 win_quote = "yikes" lose_quote = "yikes" name = "Will" defense = .5 movespeed = 5 super().__init__(health, damage, win_quote, lose_quote, name, x, y, movespeed, handler.getPlatformArray(), handler.getAttackList(), handler, defense) self.special_active = False self.count = 0 self.start_time = 0 self.startgravity = self.gravity self.startdefense = defense self.jumpsprite = pygame.image.load( "media/Players/Will/WillJump.png").convert_alpha() self.specialsprite = pygame.image.load( "media/Players/Will/WillSpecial.png").convert() self.attacksprite = pygame.image.load( "media/Players/Will/Attack2.png").convert_alpha() self.rangedsprite1 = pygame.image.load( "media/Players/Will/WillRanged1.png").convert_alpha() self.rangedsprite2 = pygame.image.load( "media/Players/Will/WillRanged2.png").convert_alpha() self.attack1 = pygame.image.load( "media/Players/Will/Attack1.png").convert_alpha() self.attack2 = pygame.image.load( "media/Players/Will/Attack2.png").convert_alpha() self.attack_animation = CircularQueue() self.attack_animation.addData(self.attack1) self.attack_animation.addData(self.attack2) self.powerattack_animation_right = CircularQueue() self.powerattack_animation_right.addData( pygame.image.load( "media/Players/Will/PowerAttack1.png").convert_alpha()) self.powerattack_animation_right.addData( pygame.image.load( "media/Players/Will/PowerAttack2.png").convert_alpha()) self.powerattack_animation_left = CircularQueue() self.powerattack_animation_left.addData( pygame.transform.flip( pygame.image.load( "media/Players/Will/PowerAttack1.png").convert_alpha(), True, False)) self.powerattack_animation_left.addData( pygame.transform.flip( pygame.image.load( "media/Players/Will/PowerAttack2.png").convert_alpha(), True, False)) self.walkSpriteList = [ pygame.image.load("media/Players/Will/Will.png").convert_alpha(), pygame.image.load("media/Players/Will/Will1.png").convert_alpha(), pygame.image.load("media/Players/Will/Will2.png").convert_alpha(), pygame.image.load("media/Players/Will/Will3.png").convert_alpha() ] self.walkAnimation = Animation(self.handler, self, self.walkSpriteList) self.walk_animation_delay = 8 self.specialSpriteList = [ pygame.image.load( "media/Players/Will/WillSpecial1.png").convert_alpha(), pygame.image.load("media/Players/Will/WillSpecial.png").convert() ] self.specialAnimation = Animation(self.handler, self, self.specialSpriteList) self.crouchSpriteList = [ pygame.image.load( "media/Players/Will/WillCrouch.png").convert_alpha(), pygame.image.load( "media/Players/Will/WillCrouch1.png").convert_alpha(), pygame.image.load( "media/Players/Will/WillCrouch2.png").convert_alpha(), pygame.image.load( "media/Players/Will/WillCrouch3.png").convert_alpha() ] self.crouchAnimation = Animation(self.handler, self, self.crouchSpriteList) self.crouch_animation_delay = 8 self.attackSpriteList = [ pygame.image.load( "media/Players/Will/WillRanged1.png").convert_alpha(), pygame.image.load( "media/Players/Will/WillRanged2.png").convert_alpha() ] self.attackAnimation = Animation(self.handler, self, self.attackSpriteList) self.animation_manager = AnimationManager(self, self.walkAnimation, self.specialAnimation, self.crouchAnimation, self.attackAnimation) self.BIGGnoise = Sound("BIGGDeathSound") self.rangedcount = 0 self.rangedavailable = False self.ranged_cooldown = Cooldown(5) self.attackavailable = False # Special self.special_available = True self.special_cooldown = Cooldown(5) self.special_duration = Cooldown(.25) self.special_count = 0 self.special_start_time = 0 self.roll_speed = 10 self.released = False self.damage = damage self.tickcounter = 0 self.right_ranged_animation = CircularQueue() self.right_ranged_animation.addData(self.rangedsprite1) self.right_ranged_animation.addData(self.rangedsprite2) self.left_ranged_animation = CircularQueue() self.left_ranged_animation.addData( pygame.transform.flip(self.rangedsprite1, True, False)) self.left_ranged_animation.addData( pygame.transform.flip(self.rangedsprite2, True, False)) self.ranged_used = False self.tick = 0 def moveX(self): self.rect.x += self.xchange platList = pygame.sprite.spritecollide(self, self.platArray, False) for platform in platList: if self.xchange > 0 and self.rect.right < platform.rect.right: # Moving right and left of platform self.rect.right = platform.rect.left elif self.xchange < 0 and self.rect.left > platform.rect.left: # Moving left and right of platform self.rect.left = platform.rect.right self.xchange = 0 def special(self): if self.special_cooldown.isDone(): self.special_active = True self.in_special = True def attack(self, screen): self.rangedavailable = True def update(self, screen): self.animation_manager.update() self.tick += 1 if not self.special_cooldown.isDone(): self.special_cooldown.update() if self.special_active and not self.sleeping: self.special_duration.update() if not self.special_duration.isDone(): self.stunned = True self.defense = 0 self.xchange += self.roll_speed * self.facing else: self.special_cooldown.update() self.defense = self.startdefense self.stunned = False self.special_active = False self.in_special = False super().update(screen) if self.rangedavailable: self.tickcounter += 1 self.ranged_cooldown.current_cooldown = self.tickcounter / 60 if self.ranged_cooldown.current_cooldown <= 1 and self.released: attack = Attack(self, self.damage, self.handler) attack.damage = 50 attack.travel_speed = 10 attack.left_animation = self.attack_animation attack.right_animation = self.attack_animation self.handler.getAttackList().add(attack) self.rangedavailable = False self.ranged_used = True self.tickcounter = 0 elif self.ranged_cooldown.current_cooldown <= 2 and self.released: attack = Attack(self, self.damage, self.handler) attack.damage = 125 attack.travel_speed = 15 attack.left_animation = self.attack_animation attack.right_animation = self.attack_animation self.handler.getAttackList().add(attack) self.rangedavailable = False self.ranged_used = True self.tickcounter = 0 elif self.ranged_cooldown.current_cooldown <= 3 and self.released: attack = Attack(self, self.damage, self.handler) attack.damage = 300 attack.travel_speed = 20 attack.left_animation = self.attack_animation attack.right_animation = self.attack_animation self.handler.getAttackList().add(attack) self.rangedavailable = False self.ranged_used = True self.tickcounter = 0 elif self.ranged_cooldown.current_cooldown <= 4 and self.released: attack = Attack(self, self.damage, self.handler) attack.damage = 480 attack.travel_speed = 25 attack.left_animation = self.attack_animation attack.right_animation = self.attack_animation self.handler.getAttackList().add(attack) self.rangedavailable = False self.ranged_used = True self.tickcounter = 0 elif self.ranged_cooldown.current_cooldown > 4 and self.released: attack = Attack(self, self.damage, self.handler) attack.damage = self.ranged_cooldown.current_cooldown * 200 attack.travel_speed = self.ranged_cooldown.current_cooldown * 7 attack.left_animation = self.powerattack_animation_left attack.right_animation = self.powerattack_animation_right self.handler.getAttackList().add(attack) self.rangedavailable = False self.ranged_used = True self.tickcounter = 0 self.BIGGnoise.playSound() self.rangedcount = 0