mirror of
https://github.com/n0remac/game-jam-2020.git
synced 2025-12-06 03:13:12 -06:00
Active recipe in top right corner. Shift cycles recipes.
This commit is contained in:
@@ -47,7 +47,7 @@ class Config(object):
|
||||
DEBUG = False
|
||||
|
||||
#Monster Count to be spawned
|
||||
MONSTER_COUNT = 20
|
||||
MONSTER_COUNT = 0
|
||||
|
||||
|
||||
class Enums(Enum):
|
||||
|
||||
@@ -15,6 +15,7 @@ from config import Config
|
||||
from map import Dungeon
|
||||
from mobs import Player, Enemy
|
||||
from projectiles import Temp
|
||||
from recipe import ActiveRecipe
|
||||
|
||||
|
||||
class FPSCounter:
|
||||
@@ -56,6 +57,7 @@ class Game(arcade.Window):
|
||||
self.physics_engine = None # Our physics engine
|
||||
# Used to keep track of our scrolling
|
||||
self.view_bottom = self.view_left = 0
|
||||
self.active_recipe = []
|
||||
|
||||
arcade.set_background_color(arcade.color.BLACK)
|
||||
|
||||
@@ -78,6 +80,9 @@ class Game(arcade.Window):
|
||||
self.player.center_x, self.player.center_y = level.center()
|
||||
# x, y = level.center()
|
||||
|
||||
self.active_recipe = ActiveRecipe()
|
||||
self.active_recipe.set_ghosts()
|
||||
|
||||
#Set up monsters
|
||||
for count in range(Config.MONSTER_COUNT):
|
||||
mob = Enemy(filename="resources/images/monsters/ghost/ghost1.png", dungeon=self.dungeon)
|
||||
@@ -86,28 +91,7 @@ class Game(arcade.Window):
|
||||
mob.scale = 4
|
||||
mob.monster_type = 'ghost'
|
||||
self.enemy_list.append(mob)
|
||||
'''
|
||||
mob = Mob(filename="resources/images/monsters/ghost/ghost1.png", dungeon=self.dungeon)
|
||||
mob.center_x, mob.center_y = random.choice(self.dungeon.levelList).center()
|
||||
mob.target = self.player
|
||||
mob.scale = 4
|
||||
self.enemy_list.append(mob)
|
||||
mob = Mob(filename="resources/images/monsters/ghost/ghost1.png", dungeon=self.dungeon)
|
||||
mob.center_x, mob.center_y = random.choice(self.dungeon.levelList).center()
|
||||
mob.target = self.player
|
||||
mob.scale = 4
|
||||
self.enemy_list.append(mob)
|
||||
mob = Mob(filename="resources/images/monsters/ghost/ghost1.png", dungeon=self.dungeon)
|
||||
mob.center_x, mob.center_y = random.choice(self.dungeon.levelList).center()
|
||||
mob.target = self.player
|
||||
mob.scale = 4
|
||||
self.enemy_list.append(mob)
|
||||
mob = Mob(filename="resources/images/monsters/ghost/ghost1.png", dungeon=self.dungeon)
|
||||
mob.center_x, mob.center_y = random.choice(self.dungeon.levelList).center()
|
||||
mob.target = self.player
|
||||
mob.scale = 4
|
||||
self.enemy_list.append(mob)
|
||||
'''
|
||||
|
||||
# Setup viewport
|
||||
self.view_bottom = self.player.center_x - (0.5 * Config.SCREEN_WIDTH) + 300
|
||||
self.view_left = self.player.center_x - (0.5 * Config.SCREEN_WIDTH)
|
||||
@@ -116,10 +100,6 @@ class Game(arcade.Window):
|
||||
self.view_bottom,
|
||||
Config.SCREEN_HEIGHT + self.view_bottom)
|
||||
|
||||
# Create monsters
|
||||
# self.enemy_list.append(Enemy("resources/images/monsters/ghost/ghost1.png", 200, 200, 4))
|
||||
# self.enemy_list.append(Enemy("resources/images/monsters/frog/frog1.png", 200, 1000, 4))
|
||||
|
||||
# Create the 'physics engine'
|
||||
self.physics_engine = arcade.PhysicsEngineSimple(self.player, self.dungeon.getWalls())
|
||||
|
||||
@@ -135,6 +115,7 @@ class Game(arcade.Window):
|
||||
self.enemy_list.draw()
|
||||
self.active_enemies.draw()
|
||||
self.bullet_list.draw()
|
||||
self.active_recipe.render()
|
||||
|
||||
if Config.DEBUG:
|
||||
x, y = self.player.position
|
||||
@@ -191,6 +172,8 @@ class Game(arcade.Window):
|
||||
self.prev_keypress.append(key)
|
||||
elif key == 65307:
|
||||
self.close()
|
||||
elif key == 65505:
|
||||
self.active_recipe.next_recipe()
|
||||
|
||||
def on_key_release(self, key, modifiers):
|
||||
"""Called when the user releases a key. """
|
||||
@@ -207,6 +190,7 @@ class Game(arcade.Window):
|
||||
elif key == arcade.key.RIGHT or key == arcade.key.D:
|
||||
self.player.change_x = 0
|
||||
self.prev_keypress.remove(key)
|
||||
|
||||
if self.prev_keypress:
|
||||
self.on_key_press(self.prev_keypress.pop(0), 0)
|
||||
|
||||
@@ -215,8 +199,6 @@ class Game(arcade.Window):
|
||||
Called whenever the mouse is clicked.
|
||||
"""
|
||||
|
||||
|
||||
|
||||
# Create a bullet TEMP SPRITE, currently wielding frog slingshot
|
||||
bullet = Temp()
|
||||
# Position the bullet at the player's current location
|
||||
@@ -322,7 +304,6 @@ class Game(arcade.Window):
|
||||
self.player.add_kill(enemy_hit_list[0].monster_type)
|
||||
enemy_hit_list[0].remove_from_sprite_lists()
|
||||
|
||||
|
||||
# If the bullet flies off-screen, remove it. TEMP change to range calc
|
||||
if (
|
||||
bullet.bottom < self.view_bottom or
|
||||
|
||||
@@ -63,7 +63,7 @@ class Player(Mob):
|
||||
# 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 == self.kill_list:
|
||||
if self.cur_recipe.sort() == self.kill_list.sort():
|
||||
print("+++++++++++++++++++++++++++++++++++++++++++++++++++++++")
|
||||
self.kill_list = []
|
||||
|
||||
|
||||
60
triple-dungeon/recipe.py
Normal file
60
triple-dungeon/recipe.py
Normal file
@@ -0,0 +1,60 @@
|
||||
'''
|
||||
Recipes are combinations of three monsters. When a player fills a recipe they get an updgrade
|
||||
'''
|
||||
import arcade
|
||||
|
||||
from enum import Enum
|
||||
|
||||
|
||||
class Recipe(Enum):
|
||||
'''A class of different recipes'''
|
||||
|
||||
GHOSTS = ['ghost', 'ghost', 'ghost']
|
||||
FROGS = ['frog', 'frog', 'frog']
|
||||
GHOST_FROG = ['ghost', 'ghost', 'frog']
|
||||
FROG_GHOST = ['ghost', 'frog', 'frog']
|
||||
|
||||
|
||||
class ActiveRecipe(arcade.SpriteList):
|
||||
'''
|
||||
Keeps track of the active recipe and draws it.
|
||||
'''
|
||||
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.active = Recipe.GHOSTS
|
||||
self.cycle_recipes = [self.set_frogs, self.set_ghosts]
|
||||
self.pos = 0
|
||||
|
||||
|
||||
def render(self) -> None:
|
||||
x = 0
|
||||
for sprite in self.sprite_list:
|
||||
screen_right = arcade.get_viewport()[1] - 100
|
||||
screen_top = arcade.get_viewport()[3] - 80
|
||||
sprite.scale = 4
|
||||
sprite.center_x = screen_right - x
|
||||
sprite.center_y = screen_top
|
||||
x += 70
|
||||
sprite.draw()
|
||||
|
||||
def next_recipe(self):
|
||||
|
||||
self.cycle_recipes[self.pos]()
|
||||
self.pos += 1
|
||||
if self.pos == len(self.cycle_recipes):
|
||||
self.pos = 0
|
||||
|
||||
def set_ghosts(self) -> None:
|
||||
self.active = Recipe.GHOSTS
|
||||
self.sprite_list = []
|
||||
self.sprite_list.append(arcade.Sprite(filename="resources/images/monsters/ghost/ghost1.png"))
|
||||
self.sprite_list.append(arcade.Sprite(filename="resources/images/monsters/ghost/ghost1.png"))
|
||||
self.sprite_list.append(arcade.Sprite(filename="resources/images/monsters/ghost/ghost1.png"))
|
||||
|
||||
def set_frogs(self) -> None:
|
||||
self.active = Recipe.FROGS
|
||||
self.sprite_list = []
|
||||
self.sprite_list.append(arcade.Sprite(filename="resources/images/monsters/frog/frog1.png"))
|
||||
self.sprite_list.append(arcade.Sprite(filename="resources/images/monsters/frog/frog1.png"))
|
||||
self.sprite_list.append(arcade.Sprite(filename="resources/images/monsters/frog/frog1.png"))
|
||||
Reference in New Issue
Block a user