mirror of
https://github.com/n0remac/game-jam-2020.git
synced 2025-12-06 03:13:12 -06:00
Added frogs. Linting.
This commit is contained in:
@@ -45,9 +45,9 @@ class Config(object):
|
||||
|
||||
# All debug statements and renderings should use this
|
||||
DEBUG = False
|
||||
|
||||
#Monster Count to be spawned
|
||||
MONSTER_COUNT = 0
|
||||
|
||||
# Monster Count to be spawned
|
||||
MONSTER_COUNT = 6
|
||||
|
||||
|
||||
class Enums(Enum):
|
||||
|
||||
@@ -83,14 +83,21 @@ class Game(arcade.Window):
|
||||
self.active_recipe = ActiveRecipe()
|
||||
self.active_recipe.set_ghosts()
|
||||
|
||||
#Set up monsters
|
||||
for count in range(Config.MONSTER_COUNT):
|
||||
# Set up monsters
|
||||
for count in range(Config.MONSTER_COUNT//2):
|
||||
mob = Enemy(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
|
||||
mob.monster_type = 'ghost'
|
||||
self.enemy_list.append(mob)
|
||||
for count in range(Config.MONSTER_COUNT//2):
|
||||
mob = Enemy(filename="resources/images/monsters/frog/frog1.png", dungeon=self.dungeon)
|
||||
mob.center_x, mob.center_y = random.choice(self.dungeon.levelList).center()
|
||||
mob.target = self.player
|
||||
mob.scale = 4
|
||||
mob.monster_type = 'frog'
|
||||
self.enemy_list.append(mob)
|
||||
|
||||
# Setup viewport
|
||||
self.view_bottom = self.player.center_x - (0.5 * Config.SCREEN_WIDTH) + 300
|
||||
@@ -122,10 +129,10 @@ class Game(arcade.Window):
|
||||
arcade.draw_rectangle_outline(round(x / Config.TILE_SIZE) * Config.TILE_SIZE,
|
||||
round(y / Config.TILE_SIZE) * Config.TILE_SIZE,
|
||||
Config.TILE_SIZE, Config.TILE_SIZE, arcade.color.RED)
|
||||
#self.player.draw_hit_box()
|
||||
#arcade.draw_text(str((x, y)), x - 40, y + 50, arcade.color.WHITE, 15, font_name='Arial')
|
||||
#arcade.draw_text(f"FPS: {self.fps.get_fps():3.0f}", self.view_left + 50, self.view_bottom + 30,
|
||||
# arcade.color.WHITE, 16, font_name='Arial')
|
||||
self.player.draw_hit_box()
|
||||
arcade.draw_text(str((x, y)), x - 40, y + 50, arcade.color.WHITE, 15, font_name='Arial')
|
||||
arcade.draw_text(f"FPS: {self.fps.get_fps():3.0f}", self.view_left + 50, self.view_bottom + 30,
|
||||
arcade.color.WHITE, 16, font_name='Arial')
|
||||
|
||||
# Draw paths for all mobs
|
||||
for mob in self.active_enemies:
|
||||
@@ -133,8 +140,8 @@ class Game(arcade.Window):
|
||||
t1 = time.time()
|
||||
path = mob.get_path()
|
||||
t2 = time.time()
|
||||
#print(f'Path acquired in {round(t2 - t1, 4)}s')
|
||||
#self.draw_path(path)
|
||||
print(f'Path acquired in {round(t2 - t1, 4)}s')
|
||||
self.draw_path(path)
|
||||
mob.tick(path)
|
||||
|
||||
self.fps.tick()
|
||||
@@ -271,7 +278,7 @@ class Game(arcade.Window):
|
||||
Config.SCREEN_WIDTH + self.view_left,
|
||||
self.view_bottom,
|
||||
Config.SCREEN_HEIGHT + self.view_bottom)
|
||||
#Enemy activation and update
|
||||
# Enemy activation and update
|
||||
for enemy in reversed(self.enemy_list):
|
||||
if (
|
||||
enemy.bottom > self.view_bottom and
|
||||
@@ -279,9 +286,10 @@ class Game(arcade.Window):
|
||||
enemy.right < self.view_left + Config.SCREEN_WIDTH and
|
||||
enemy.left > self.view_left
|
||||
):
|
||||
if Config.DEBUG: print("Activate Enemy")
|
||||
self.active_enemies.append(enemy)
|
||||
self.enemy_list.remove(enemy)
|
||||
if Config.DEBUG:
|
||||
print("Activate Enemy")
|
||||
self.active_enemies.append(enemy)
|
||||
self.enemy_list.remove(enemy)
|
||||
try:
|
||||
for enemy in self.active_enemies:
|
||||
enemy.update()
|
||||
@@ -293,7 +301,7 @@ class Game(arcade.Window):
|
||||
# Projectile updates
|
||||
self.bullet_list.update()
|
||||
for bullet in self.bullet_list:
|
||||
|
||||
|
||||
# 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)
|
||||
|
||||
@@ -32,8 +32,6 @@ class Mob(arcade.Sprite):
|
||||
self.target = None
|
||||
|
||||
|
||||
|
||||
|
||||
class Player(Mob):
|
||||
"""
|
||||
Represents a Player.
|
||||
@@ -67,7 +65,6 @@ class Player(Mob):
|
||||
print("+++++++++++++++++++++++++++++++++++++++++++++++++++++++")
|
||||
self.kill_list = []
|
||||
|
||||
|
||||
def update_animation(self, delta_time: float = 1 / 60) -> None:
|
||||
"""
|
||||
Updates animations for the Player.
|
||||
@@ -161,4 +158,3 @@ class Enemy(Mob):
|
||||
paths, runs = self.dungeon.finder.find_path(start, end, self.dungeon.grid)
|
||||
self.dungeon.grid.cleanup()
|
||||
return paths
|
||||
|
||||
|
||||
@@ -1,60 +1,62 @@
|
||||
'''
|
||||
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']
|
||||
'''
|
||||
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.
|
||||
'''
|
||||
'''
|
||||
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 __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 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 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_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"))
|
||||
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