def update(self): self.spawn_counter.run() if self.spawn_counter.expired: ran_y = random.randint(200, 600) # print(warning_sign.x) game_object.recycle(WarningSign, 1200, ran_y) game_object.recycle(Carrot, 1365, ran_y) self.spawn_counter.reset()
def shoot(self): if self.input_manager.x_pressed and not self.shoot_lock: game_object.recycle(PlayerBullet, self.x, self.y - 40) self.shoot_lock = True if self.shoot_lock: self.counter.run() if self.counter.expired: self.shoot_lock = False self.counter.reset()
def spawn(self): platform_speed = 6 end_index = random.randint(4, 6) ran_y = random.randint(200, 570) for i in range(end_index): if i == 0: spike = game_object.recycle(SpikeLeft, 1343 + i * 64 - 64 + 27, ran_y) spike.v_x = platform_speed if i == end_index - 1: spike = game_object.recycle(SpikeRight, 1343 + i * 64 - 27, ran_y) spike.v_x = platform_speed else: platform = game_object.recycle(Platform, 1343 + i * 64, ran_y) platform.v_x = platform_speed
def shoot_left(self): if self.input_manager.left_mouse_clicked and self.has_shoot1: self.has_shoot1 = False # print('left hitu') # game_object.recycle(Shot1) try: distance = (get_distance( (self.x, self.y), (self.input_manager.mouse_x, self.input_manager.mouse_y))) shot1 = game_object.recycle(Shot1, self.x, self.y) shot1.velocity = ((self.input_manager.mouse_x - self.x) / distance * 5, (self.input_manager.mouse_y - self.y) / distance * 5) shot1.counter.reset() except ZeroDivisionError: # game_object.add(shot1) pass
def shoot_right(self): if self.input_manager.right_mouse_clicked and self.has_shoot2: self.has_shoot2 = False try: distance = (get_distance( (self.x, self.y), (self.input_manager.mouse_x, self.input_manager.mouse_y))) shot2 = game_object.recycle(Shot2, self.x, self.y - 10) shot2.velocity = ((self.input_manager.mouse_x - self.x) / distance * 10, (self.input_manager.mouse_y - self.y) / distance * 10) shot2.time_before_disappear.reset() except ZeroDivisionError: # game_object.add(shot1) pass if self.has_shoot2 == False: self.counter2.run() if self.counter2.expired: self.has_shoot2 = True self.counter2.reset()
def spawn(self): platform = game_object.recycle(Platform, 1343, 650) platform.v_x = 3
def spawn(self): return game_object.recycle(Enemy, 300, 100)
def spawn(self): ran_y = random.randint(100, 600) game_object.recycle(Items, 1343, ran_y)
def spawn(self): return game_object.recycle(Enemy, self.spawn_x, self.spawn_y)
def spawn(self): return game_object.recycle(Dog, self.x, self.y)