def __init__(self): self.left_animation = Animation([ "images/player_left/player1_right2.png", "images/player_left/player1_right3.png", "images/player_left/player1_right4.png", "images/player_left/player1_right5.png", "images/player_left/player1_right6.png", "images/player_left/player1_right7.png", ], loop = True) self.right_animation = Animation([ "images/player_right/player2.png", "images/player_right/player3.png", "images/player_right/player4.png", "images/player_right/player5.png", "images/player_right/player6.png", "images/player_right/player7.png", ], loop = True) self.straight_animation = Animation([ "images/player_right/player2.png", ], loop=True) self.down_animation = Animation([]) self.current_animation = self.right_animation
def __init__(self, x, y): GameObject.__init__(self, x, y) rnd = random.randint(1, 3) if rnd == 1: self.renderer = Animation(["images/banana.png"], loop=True) if rnd == 2: self.renderer = Animation(["images/pizza.png"], loop=True) if rnd == 3: self.renderer = Animation(["images/fish.png"], loop=True) self.box_collider = BoxCollider(64, 64)
def update(self): GameObject.update(self) if self.stun: self.renderer = Animation(enemy_stun, loop=True, frame_delay=1) self.stunCooldown -= 1 if self.stunCooldown == 0: self.renderer = Animation(list_enemy, loop=True, frame_delay=1) self.stun = False self.stunCooldown = 20 if not self.stun: self.enemy_move(3) self.deactivate_if_need()
def __init__(self, x, y): GameObject.__init__(self, x, y) self.renderer = Animation(["images/warning_sign.png"], loop=True) self.box_collider = BoxCollider(64, 64) self.count = FrameCounter(50) pygame.mixer.Channel(3).play( pygame.mixer.Sound("music/warning (1).wav"))
def __init__(self, x, y): GameObject.__init__(self, x, y) self.box_collider = BoxCollider(50, 50) self.first_move = False self.sec_move = False self.renderer = Animation(list_enemy, loop=True, frame_delay=1) self.stun = False self.stunCooldown = 20 self.isDeath = False
def __init__(self, x, y): GameObject.__init__(self, x, y) self.renderer = Animation([ "images/enemy/bacteria_dead1.png", "images/enemy/bacteria_dead2.png", "images/enemy/bacteria_dead3.png", "images/enemy/bacteria_dead4.png", "images/enemy/bacteria_dead5.png" ])
def __init__(self): self.left_animation = Animation(["images/player/player_left1.png", "images/player/player_left2.png", "images/player/player_left3.png", "images/player/player_left4.png",], loop=True) self.straight_animation = Animation(["images/player/player1.png", "images/player/player2.png", "images/player/player3.png", "images/player/player4.png",], loop=True) self.right_animation = Animation(["images/player/player_right1.png", "images/player/player_right2.png", "images/player/player_right3.png", "images/player/player_right4.png"], loop=True) self.current_animation = self.straight_animation
def __init__(self,x,y): GameObject.__init__(self,x,y-20) self.frame_counter = FrameCounter(30) self.shoot_lock = False self.box_collider = BoxCollider(64,80) # self.tower_circle = Tower_circle(0,0) self.rangeCheck = False self.range = 0 self.enemy_x = tower_defense.game_object.get_position_from_main[0] self.enemy_y = tower_defense.game_object.get_position_from_main[1] self.renderer = Animation(list_tower_aoe,loop=True,frame_delay=30)
def __init__(self, x, y): GameObject.__init__(self, x, y) # 1 load image self.image_urls = [ "assets/images/sprite/enemy/tower/tower1.png", "assets/images/sprite/enemy/tower/tower2.png", "assets/images/sprite/enemy/tower/tower3.png", "assets/images/sprite/enemy/tower/tower4.png" ] self.renderer = Animation(self.image_urls, True) self.frame_counter = FrameCounter(100)
def __init__(self,x,y,e_x,e_y): GameObject.__init__(self,x,y) self.box_collider = BoxCollider(15,15) self.renderer = Animation(list_bullet_shotgun,loop=True,frame_delay=1) self.e_x = e_x self.e_y = e_y self.cooldown = 80 self.velocity = (0,0) self.vectorX = 0 self.vectorY = 0 self.velocityX = 0 self.velocityY = 0
def __init__(self, x, y): GameObject.__init__(self, x, y) self.renderer = Animation([ "images/player_dies/sprite-0003.png", "images/player_dies/sprite-0004.png", "images/player_dies/sprite-0005.png", "images/player_dies/sprite-0006.png", "images/player_dies/sprite-0007.png", "images/player_dies/sprite-0008.png", "images/player_dies/sprite-0009.png", "images/player_dies/sprite-0010.png" ], loop=False)
def __init__(self, x, y): GameObject.__init__(self, x, y) self.box_collider = BoxCollider(64, 32) self.renderer = Animation([ "images/carrot_animation/carrot1.png", "images/carrot_animation/carrot2.png", "images/carrot_animation/carrot3.png", "images/carrot_animation/carrot4.png", "images/carrot_animation/carrot5.png", "images/carrot_animation/carrot6.png" ], loop=True) self.spawn_counter = FrameCounter(50)
def __init__(self, x, y): GameObject.__init__(self, x, y) self.box_collider = BoxCollider(30, 30) self.renderer = Animation([ "images/enemy/bacteria1.png", "images/enemy/bacteria2.png", "images/enemy/bacteria3.png", "images/enemy/bacteria4.png", "images/enemy/bacteria5.png", "images/enemy/bacteria6.png", ], loop=True, frame_delay=10)
def __init__(self,x ,y, dx, dy): GameObject.__init__(self,x ,y) self.dam = 30 self.x = x self.y = y self.overlap = False self.dx = dx self.dy = dy # 1 load image self.renderer = Animation(["assets/images/sprite/enemy/bullet_tank/bullet_tank1.png", "assets/images/sprite/enemy/bullet_tank/bullet_tank2.png", "assets/images/sprite/enemy/bullet_tank/bullet_tank3.png"],True) self.width = 20 self.height = 20 self.box_collider = BoxCollider(self.width, self.height)
def __init__(self, x, y): GameObject.__init__(self, x, y) self.overlap = False # 1 load image self.image_urls = [ "assets/images/sprite/gift/coinup.png", "assets/images/sprite/gift/coinup_2.png", "assets/images/sprite/gift/coin_down1.png", "assets/images/sprite/gift/coin_down.png" ] self.renderer = Animation(self.image_urls, True) self.width = 20 self.height = 20 self.box_collider = BoxCollider(self.width, self.height)
def __init__(self,x,y): GameObject.__init__(self,x,y) self.renderer = Animation(["images/gameover1.png", "images/gameover2.png", "images/gameover3.png", "images/gameover4.png", "images/gameover5.png", "images/gameover6.png", "images/gameover7.png", "images/gameover8.png",],loop = True,frame_delay=10) # def update(self): # GameObject.update(self) # if global_input_manager.enter_pressed: # gameplay_scene = GamePlayScene() # global_scene_manager.change_scene(gameplay_scene)
def update(self): GameObject.update(self) if not self.overlap: for game_object in game_objects: if type(game_object) == Player: overlap = BoxCollider.overlap(self.box_collider, game_object.box_collider) if overlap and game_object.count_coin == 7: self.overlap = True game_object.can_shoot = True if self.overlap: image_urls = ["assets/images/sprite/gift/gift_close.png", "assets/images/sprite/gift/gift_opening.png", "assets/images/sprite/gift/gift_open.png"] self.renderer = Animation(image_urls,False) self.renderer = ImageRenderer("assets/images/sprite/gift/gift_open.png") enemy_tower = EnemyTower(10*16+8, 15*16) add(enemy_tower)
def __init__(self, x, y): GameObject.__init__(self, x, y) self.renderer = Animation([ "images/gamestartscreen1.png", "images/gamestartscreen2.png", "images/gamestartscreen3.png", "images/gamestartscreen4.png", "images/gamestartscreen5.png", "images/gamestartscreen6.png", "images/gamestartscreen7.png", "images/gamestartscreen8.png", "images/gamestartscreen9.png", "images/gamestartscreen10.png", "images/gamestartscreen11.png", ], loop=True, frame_delay=10)
def update(self, player_dx, player_dy): if player_dx > 0: if player_dy >= 0: self.current_animation = self.right_animation else: self.current_animation = self.straight_animation elif player_dx < 0: if player_dy >= 0: self.current_animation = self.left_animation else: self.current_animation =Animation(["images/player_left/player1_right2.png"], loop = True) else: if player_dy >= 0: self.current_animation = self.right_animation else: self.current_animation = self.straight_animation
def __init__(self, x, y): GameObject.__init__(self, x, y) self.renderer = Animation(["images/background.png"], loop=True)
def __init__(self, _type): self._type = _type if self._type == "normal": self.down = Animation([ "assets/images/sprite/enemy/enemy1_down.png", "assets/images/sprite/enemy/enemy1_down1.png" ], True) self.up = Animation([ "assets/images/sprite/gift/coinup.png", "assets/images/sprite/gift/coinup_2.png", "assets/images/sprite/gift/coin_down1.png", "assets/images/sprite/gift/coin_down.png" ], True) self.right = Animation([ "assets/images/sprite/gift/coinup.png", "assets/images/sprite/gift/coinup_2.png", "assets/images/sprite/gift/coin_down1.png", "assets/images/sprite/gift/coin_down.png" ], True) self.left = Animation([ "assets/images/sprite/enemy/enemy1_left.png", "assets/images/sprite/enemy/enemy1_left1.png" ], True) elif self._type == "invisible": self.down = Animation([ "assets/images/sprite/enemy/enemy2_down.png", "assets/images/sprite/enemy/enemy2_down1.png" ], True) self.up = Animation([ "assets/images/sprite/enemy/enemy2_up.png", "assets/images/sprite/enemy/enemy2_down1.png" ], True) self.right = Animation([ "assets/images/sprite/enemy/enemy2_right.png", "assets/images/sprite/enemy/enemy2_right1.png" ], True) self.left = Animation([ "assets/images/sprite/enemy/enemy2_left.png", "assets/images/sprite/enemy/enemy2_left1.png" ], True) elif self._type == "tank": self.down = Animation( ["assets/images/sprite/enemy/enemy3_down.png"], True) self.up = Animation(["assets/images/sprite/enemy/enemy3_up.png"], True) self.right = Animation( ["assets/images/sprite/enemy/enemy3_right.png"], True) self.left = Animation( ["assets/images/sprite/enemy/enemy3_left.png"], True) self.current_animation = self.down
def __init__(self, x, y, dx, dy, _type): GameObject.__init__(self, x, y) self._type = _type if self._type == "normal": self.diedown = Animation([ "assets/images/sprite/enemy/enemy1_down.png", "assets/images/sprite/enemy/enemydiedown/die1.png", "assets/images/sprite/enemy/enemydiedown/die2.png" ], False) self.dieup = Animation([ "assets/images/sprite/enemy/enemy1_up.png", "assets/images/sprite/enemy/enemydieup/die1.png", "assets/images/sprite/enemy/enemydieup/die2.png" ], False) self.dieleft = Animation([ "assets/images/sprite/enemy/enemy1_left.png", "assets/images/sprite/enemy/enemydieleft/die1.png", "assets/images/sprite/enemy/enemydieleft/die2.png" ], False) self.dieright = Animation([ "assets/images/sprite/enemy/enemy1_right.png", "assets/images/sprite/enemy/enemydieright/die1.png", "assets/images/sprite/enemy/enemydieright/die2.png" ], False) elif self._type == "invisible": self.diedown = Animation([ "assets/images/sprite/enemy/enemy2_down.png", "assets/images/sprite/enemy/enemydiedown/die11.png", "assets/images/sprite/enemy/enemydiedown/die21.png" ], False) self.dieup = Animation([ "assets/images/sprite/enemy/enemy2_up.png", "assets/images/sprite/enemy/enemydieup/die11.png", "assets/images/sprite/enemy/enemydieup/die21.png" ], False) self.dieleft = Animation([ "assets/images/sprite/enemy/enemy2_left.png", "assets/images/sprite/enemy/enemydieleft/die11.png", "assets/images/sprite/enemy/enemydieleft/die21.png" ], False) self.dieright = Animation([ "assets/images/sprite/enemy/enemy2_right.png", "assets/images/sprite/enemy/enemydieright/die11.png", "assets/images/sprite/enemy/enemydieright/die21.png" ], False) elif self._type == "tank": self.diedown = Animation([ "assets/images/sprite/enemy/enemy3_down.png", "assets/images/sprite/enemy/enemydiedown/die12.png", "assets/images/sprite/enemy/enemydiedown/die22.png" ], False) self.dieup = Animation([ "assets/images/sprite/enemy/enemy3_up.png", "assets/images/sprite/enemy/enemydieup/die12.png", "assets/images/sprite/enemy/enemydieup/die22.png" ], False) self.dieleft = Animation([ "assets/images/sprite/enemy/enemy3_left.png", "assets/images/sprite/enemy/enemydieleft/die12.png", "assets/images/sprite/enemy/enemydieleft/die22.png" ], False) self.dieright = Animation([ "assets/images/sprite/enemy/enemy3_right.png", "assets/images/sprite/enemy/enemydieright/die12.png", "assets/images/sprite/enemy/enemydieright/die22.png" ], False) self.dx = dx self.dy = dy if self.dy > 0: self.renderer = self.diedown elif self.dy < 0: self.renderer = self.dieup elif self.dx > 0: self.renderer = self.dieright elif self.dx < 0: self.renderer = self.dieleft
def __init__(self, x, y): GameObject.__init__(self, x, y) self.renderer = Animation(enemydie)
def __init__(self, x, y): GameObject.__init__(self, x, y) self.box_collider = BoxCollider(64, 64) self.v_x = game_object.game_speed #velocity self.renderer = Animation(["images/map/forest.png"], loop=True)
def __init__(self): self.left_animation = Animation(left_player, loop=True) self.straight_animation = Animation(straight_player, loop=True) self.right_animation = Animation(right_player, loop=True) self.build_animation = Animation(build_animation, loop=True) self.current_animation = self.straight_animation