def __init__(self, score_label, hp_label, gem_times, gem_lanes, enemy_types, enemy_chords, enemy_manager, audio_controller): super(Player, self).__init__() self.audio_controller = audio_controller self.MAX_HEALTH = 1000 self.score = 0 self.hp = self.MAX_HEALTH self.state = "idle" self.lane = 0 self.score_label = score_label self.hp_label = hp_label # The image asset has it so that the now bbbar is at 12.15% of the width self.nowbar_x = Window.width*0.1215 self.hero = Hero((0,0)) self.hero.change_lane(1) self.add(self.hero) self.gem_times = gem_times self.gem_lanes = gem_lanes self.enemy_types = enemy_types self.enemy_chords = enemy_chords self.elapsed_time = 0 self.prev_time = time.time() self.playing = True self.enemy_manager = enemy_manager self.current_enemy_index = 0 self.enemy_spawn_index = 0 self.notes_down = []
def build(self): hero1 = Hero(name="Hero 1", deck=self.generateDeck()) hero2 = Hero(name="Hero 2", deck=self.generateDeck()) board = Board(hero1, hero2) return board
def main(): # create the cast {key: tag, value: list} cast = {} # add the tower tower = TowerSprite() cast["tower"] = [tower] # add the zombies cast['zombies'] = arcade.SpriteList() # add the wall cast["walls"] = arcade.SpriteList() # add the bullets cast["bullets"] = [] # add the turret cast["turrets"] = arcade.SpriteList() # add the hero hero = Hero(cast) cast["hero"] = [hero] melee = Melee(cast) cast["melee"] = [melee] # add the score score = Score() cast["score"] = [score] # add the resource counter resource_counter = ResourceCounter(200,50) cast['resource_counter'] = [resource_counter] # add the magic cast['magicks'] = arcade.SpriteList() # add the resources cast['resources'] = arcade.SpriteList() # create the script {key: tag, value: list} script = {} input_service = ArcadeInputService() output_service = ArcadeOutputService() control_actors_action = ControlActorsAction(input_service) move_actors_action = MoveActorsAction() handle_collisions_action = HandleCollisionsAction() draw_actors_action = DrawActorsAction(output_service) window = arcade.Window(constants.MAX_X, constants.MAX_Y, "Towerz") start_screen = StartView(cast, script, input_service) handle_lose_or_win = HandleLoseOrWinAction(window, start_screen, script) script["input"] = [control_actors_action] script["update"] = [move_actors_action, handle_collisions_action, handle_lose_or_win] script["output"] = [draw_actors_action] # start the game window.show_view(start_screen) arcade.run()