From 9c26aa156f7ebc91c927a1720d2ae55506fdad5d Mon Sep 17 00:00:00 2001 From: Cameron Smart Date: Wed, 22 Apr 2020 23:11:36 -0700 Subject: [PATCH] Shift key to cycle recipes --- triple-dungeon/config.py | 2 +- triple-dungeon/main.py | 19 +++++++++++-------- triple-dungeon/mobs.py | 9 ++++++--- triple-dungeon/recipe.py | 5 +---- 4 files changed, 19 insertions(+), 16 deletions(-) diff --git a/triple-dungeon/config.py b/triple-dungeon/config.py index ddf7fc0..393d685 100644 --- a/triple-dungeon/config.py +++ b/triple-dungeon/config.py @@ -47,7 +47,7 @@ class Config(object): DEBUG = False # Monster Count to be spawned - MONSTER_COUNT = 6 + MONSTER_COUNT = 10 class Enums(Enum): diff --git a/triple-dungeon/main.py b/triple-dungeon/main.py index 430c93a..2ecb526 100644 --- a/triple-dungeon/main.py +++ b/triple-dungeon/main.py @@ -73,16 +73,18 @@ class Game(arcade.Window): # Create the dungeon self.dungeon = Dungeon(0, 3) + # Set up recipes + self.active_recipe = ActiveRecipe() + self.active_recipe.set_ghosts() + # 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.active_recipe.active # x, y = level.center() - self.active_recipe = ActiveRecipe() - self.active_recipe.set_ghosts() - # Set up monsters for count in range(Config.MONSTER_COUNT//2): mob = Enemy(filename="resources/images/monsters/ghost/ghost1.png", dungeon=self.dungeon) @@ -181,6 +183,7 @@ class Game(arcade.Window): self.close() elif key == 65505: self.active_recipe.next_recipe() + self.player.cur_recipe = self.active_recipe.active def on_key_release(self, key, modifiers): """Called when the user releases a key. """ @@ -281,12 +284,12 @@ class Game(arcade.Window): # Enemy activation and update for enemy in reversed(self.enemy_list): if ( - enemy.bottom > self.view_bottom and - enemy.top < self.view_bottom + Config.SCREEN_HEIGHT and - enemy.right < self.view_left + Config.SCREEN_WIDTH and - enemy.left > self.view_left + enemy.bottom > self.view_bottom and + enemy.top < self.view_bottom + Config.SCREEN_HEIGHT and + enemy.right < self.view_left + Config.SCREEN_WIDTH and + enemy.left > self.view_left ): - if Config.DEBUG: + if Config.DEBUG: print("Activate Enemy") self.active_enemies.append(enemy) self.enemy_list.remove(enemy) diff --git a/triple-dungeon/mobs.py b/triple-dungeon/mobs.py index 82c2546..9560f13 100644 --- a/triple-dungeon/mobs.py +++ b/triple-dungeon/mobs.py @@ -55,15 +55,18 @@ class Player(Mob): self.prev = Enums.IDLE self.texture = next(self.map[self.prev]) self.kill_list = [] - self.cur_recipe = ['ghost', 'ghost', 'ghost'] + self.cur_recipe = None def add_kill(self, creature): # Adds a kill to kill_list. If 3 or more check the recipe then give a power up if it matches. - self.kill_list.append(creature) - if self.cur_recipe.sort() == self.kill_list.sort(): + print(self.kill_list) + print(self.cur_recipe) + if self.cur_recipe == self.kill_list: print("+++++++++++++++++++++++++++++++++++++++++++++++++++++++") self.kill_list = [] + elif len(self.kill_list) >= 3: + self.kill_list = [] def update_animation(self, delta_time: float = 1 / 60) -> None: """ diff --git a/triple-dungeon/recipe.py b/triple-dungeon/recipe.py index c8e5f3f..2a35ca0 100644 --- a/triple-dungeon/recipe.py +++ b/triple-dungeon/recipe.py @@ -4,10 +4,8 @@ Recipes are combinations of three monsters. When a player fills a recipe they ge import arcade -from enum import Enum - -class Recipe(Enum): +class Recipe: ''' A class of different recipes ''' @@ -41,7 +39,6 @@ class ActiveRecipe(arcade.SpriteList): sprite.draw() def next_recipe(self): - self.cycle_recipes[self.pos]() self.pos += 1 if self.pos == len(self.cycle_recipes):