def update(self): GameObject.update(self) collide_list = collide_with(self.box_collider, Player) for game_object in collide_list: if game_object.win == True: game_object.deactivate() winning_scene = WinningScene() global_scene_manager.change_scene(winning_scene)
def update(self): GameObject.update(self) self.update_animator() self.frame_counter.run() if self.frame_counter.expired: self.black_screen = True self.counter.run() if self.counter.expired: self.black_screen = False self.counter.reset() self.frame_counter.reset() if not self.black_screen: self.move() else: pass collide_list = collide_with(self.box_collider, Player) for game_object in collide_list: game_object.deactivate() game_over = GameOverScene() global_scene_manager.change_scene(game_over)
def update(self): if global_input_manager.enter_pressed: gameplay_scene = GameplayScene() global_scene_manager.change_scene(gameplay_scene)
# 1. Init pygame pygame.init() # 2. Set screen SIZE = (800, 620) canvas = pygame.display.set_mode(SIZE) # 3. Clock clock = pygame.time.Clock() loop = True generate_map("image/map/map.json") menu_scene = MenuScene() global_scene_manager.change_scene(menu_scene) # guide_scene = GuideScene() # global_scene_manager.change_scene(guide_scene) # player = Player(32, 320, input_manager) # enemy = Enemy(368, 608) # enemy1 = Enemy(640, 300) # # black_slave = BlackSlave(768, 240) # black_screen = BlackScreen(0, 0) # main_door = MainDoor(16, 320) # # game_objects.add(enemy) # game_objects.add(black_slave) # game_objects.add(main_door) # game_objects.add(enemy1)
def deactivate(self): GameObject.deactivate(self) death = PlayerDies(self.x, self.y) add_game_object(death) over = GameoverScene() global_scene_manager.change_scene(over)
def lose(self): global_scene_manager.change_scene(GameOverScene()) gamelevel.clear()
from scenes.scene_manager import global_scene_manager from scenes.menu_scene import MenuScene from scenes.game_over_scene import EndScene from tower_defense.boss_spawner import * pygame.init() myfont = pygame.font.SysFont("monospace", 30) clock = pygame.time.Clock() SCREEN_SIZE = (600, 800) canvas = pygame.display.set_mode(SCREEN_SIZE) background_image = pygame.image.load("images/background/background.png") pygame.display.set_caption("Tower Defense") menu_scene = MenuScene() global_scene_manager.change_scene(menu_scene) # if tower_defense.game_object.hp_castle == 0: # end = End(300,400) # global_scene_manager.change_scene(end) loop = True new_wave = False while loop: for game_object in game_objects: if type(game_object) == EndScene and game_object.is_active: if global_input_manager.enter_pressed: menu_scene = MenuScene() global_scene_manager.change_scene(menu_scene) tower_defense.game_object.coin = 35