diff --git a/triple-dungeon/main.py b/triple-dungeon/main.py index b1b0151..7fee28c 100644 --- a/triple-dungeon/main.py +++ b/triple-dungeon/main.py @@ -13,11 +13,10 @@ from typing import Tuple, List import arcade from config import Config from map import Dungeon -from mobs import Player, MobHandler +from mobs import Player, MobHandler, Mob from projectiles import Temp from recipe import ActiveRecipe - class FPSCounter: def __init__(self): self.time = time.perf_counter() @@ -56,7 +55,7 @@ class Game(arcade.Window): self.prev_keypress = [] # A list that assists with tracking keypress events # Used to keep track of our scrolling self.view_bottom = self.view_left = 0 - self.Recipe = [] + self.recipe = [] self.enemies_in_range = [] arcade.set_background_color(arcade.color.BLACK) @@ -71,15 +70,15 @@ class Game(arcade.Window): self.dungeon = Dungeon(0, 3) # Set up recipes - self.Recipe = ActiveRecipe() - self.Recipe.set_ghosts() + self.recipe = ActiveRecipe() + self.recipe.activateGhost() # Set up the player, specifically placing it at these coordinates. self.player = Player(self.dungeon) self.player.scale = 1 level = random.choice(self.dungeon.levelList) self.player.center_x, self.player.center_y = level.center() - self.player.cur_recipe = self.Recipe.active + self.player.cur_recipe = self.recipe.active self.player.monster_collisions = arcade.PhysicsEngineSimple(self.player, self.dungeon.getWalls()) # Set up monsters @@ -107,7 +106,7 @@ class Game(arcade.Window): self.Mobs.render() self.active_enemies.draw() self.bullet_list.draw() - self.Recipe.render() + self.recipe.render() if Config.DEBUG: x, y = self.player.position @@ -165,8 +164,8 @@ class Game(arcade.Window): elif key == 65307: self.close() elif key == 65505: - self.Recipe.next_recipe() - self.player.cur_recipe = self.Recipe.active + self.recipe.next_recipe() + self.player.cur_recipe = self.recipe.active def on_key_release(self, key, modifiers): """Called when the user releases a key. """ @@ -273,13 +272,13 @@ class Game(arcade.Window): # Collision Checks hit_list = arcade.check_for_collision_with_list(bullet, self.dungeon.getWalls()) - enemy_hit_list = arcade.check_for_collision_with_list(bullet, self.active_enemies) + enemy_hit_list: List[Mob] = arcade.check_for_collision_with_list(bullet, self.active_enemies) # If it did, get rid of the bullet if len(hit_list) > 0: bullet.remove_from_sprite_lists() - if len(enemy_hit_list): + if len(enemy_hit_list) > 0: self.player.add_kill(enemy_hit_list[0].monster_type) - self.Recipe.add_kill(enemy_hit_list[0].monster_type) + self.recipe.addKill(enemy_hit_list[0].monster_type) enemy_hit_list[0].remove_from_sprite_lists() bullet.remove_from_sprite_lists() diff --git a/triple-dungeon/recipe.py b/triple-dungeon/recipe.py index e6fdb06..a783997 100644 --- a/triple-dungeon/recipe.py +++ b/triple-dungeon/recipe.py @@ -1,5 +1,5 @@ """ -Recipes are combinations of three monsters. When a player fills a recipe they get an updgrade +Recipes are combinations of three monsters. When a player fills a recipe they get an upgrade. """ import arcade @@ -32,6 +32,9 @@ class ActiveRecipe(arcade.SpriteList): self.kill_num = 0 def render(self) -> None: + """ + Renders all current Recipe sprites at the top right of the screen in a row. + """ x = 0 for sprite in self.sprite_list: screen_right = arcade.get_viewport()[1] - 100 @@ -43,13 +46,20 @@ class ActiveRecipe(arcade.SpriteList): x += 70 sprite.draw() - def nextRecipe(self): + def nextRecipe(self) -> None: + """ + Iterates to the next recipe in the list. + """ self.cycle_recipes[self.pos]() self.pos += 1 if self.pos == len(self.cycle_recipes): self.pos = 0 - def addKill(self, monster_type): + def addKill(self, monster_type) -> None: + """ + Adds the kill and darkens the sprite if the monster type matches. + :param monster_type: The monster type. + """ for sprite in self.sprite_list: if monster_type == sprite: sprite.color = tuple(spectrum * 0.5 for spectrum in sprite.color)