mirror of
https://github.com/n0remac/game-jam-2020.git
synced 2025-12-06 15:13:13 -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
|
# All debug statements and renderings should use this
|
||||||
DEBUG = False
|
DEBUG = False
|
||||||
|
|
||||||
#Monster Count to be spawned
|
# Monster Count to be spawned
|
||||||
MONSTER_COUNT = 0
|
MONSTER_COUNT = 6
|
||||||
|
|
||||||
|
|
||||||
class Enums(Enum):
|
class Enums(Enum):
|
||||||
|
|||||||
@@ -83,14 +83,21 @@ class Game(arcade.Window):
|
|||||||
self.active_recipe = ActiveRecipe()
|
self.active_recipe = ActiveRecipe()
|
||||||
self.active_recipe.set_ghosts()
|
self.active_recipe.set_ghosts()
|
||||||
|
|
||||||
#Set up monsters
|
# Set up monsters
|
||||||
for count in range(Config.MONSTER_COUNT):
|
for count in range(Config.MONSTER_COUNT//2):
|
||||||
mob = Enemy(filename="resources/images/monsters/ghost/ghost1.png", dungeon=self.dungeon)
|
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.center_x, mob.center_y = random.choice(self.dungeon.levelList).center()
|
||||||
mob.target = self.player
|
mob.target = self.player
|
||||||
mob.scale = 4
|
mob.scale = 4
|
||||||
mob.monster_type = 'ghost'
|
mob.monster_type = 'ghost'
|
||||||
self.enemy_list.append(mob)
|
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
|
# Setup viewport
|
||||||
self.view_bottom = self.player.center_x - (0.5 * Config.SCREEN_WIDTH) + 300
|
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,
|
arcade.draw_rectangle_outline(round(x / Config.TILE_SIZE) * Config.TILE_SIZE,
|
||||||
round(y / Config.TILE_SIZE) * Config.TILE_SIZE,
|
round(y / Config.TILE_SIZE) * Config.TILE_SIZE,
|
||||||
Config.TILE_SIZE, Config.TILE_SIZE, arcade.color.RED)
|
Config.TILE_SIZE, Config.TILE_SIZE, arcade.color.RED)
|
||||||
#self.player.draw_hit_box()
|
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(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.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')
|
arcade.color.WHITE, 16, font_name='Arial')
|
||||||
|
|
||||||
# Draw paths for all mobs
|
# Draw paths for all mobs
|
||||||
for mob in self.active_enemies:
|
for mob in self.active_enemies:
|
||||||
@@ -133,8 +140,8 @@ class Game(arcade.Window):
|
|||||||
t1 = time.time()
|
t1 = time.time()
|
||||||
path = mob.get_path()
|
path = mob.get_path()
|
||||||
t2 = time.time()
|
t2 = time.time()
|
||||||
#print(f'Path acquired in {round(t2 - t1, 4)}s')
|
print(f'Path acquired in {round(t2 - t1, 4)}s')
|
||||||
#self.draw_path(path)
|
self.draw_path(path)
|
||||||
mob.tick(path)
|
mob.tick(path)
|
||||||
|
|
||||||
self.fps.tick()
|
self.fps.tick()
|
||||||
@@ -271,7 +278,7 @@ class Game(arcade.Window):
|
|||||||
Config.SCREEN_WIDTH + self.view_left,
|
Config.SCREEN_WIDTH + self.view_left,
|
||||||
self.view_bottom,
|
self.view_bottom,
|
||||||
Config.SCREEN_HEIGHT + self.view_bottom)
|
Config.SCREEN_HEIGHT + self.view_bottom)
|
||||||
#Enemy activation and update
|
# Enemy activation and update
|
||||||
for enemy in reversed(self.enemy_list):
|
for enemy in reversed(self.enemy_list):
|
||||||
if (
|
if (
|
||||||
enemy.bottom > self.view_bottom and
|
enemy.bottom > self.view_bottom and
|
||||||
@@ -279,9 +286,10 @@ class Game(arcade.Window):
|
|||||||
enemy.right < self.view_left + Config.SCREEN_WIDTH and
|
enemy.right < self.view_left + Config.SCREEN_WIDTH and
|
||||||
enemy.left > self.view_left
|
enemy.left > self.view_left
|
||||||
):
|
):
|
||||||
if Config.DEBUG: print("Activate Enemy")
|
if Config.DEBUG:
|
||||||
self.active_enemies.append(enemy)
|
print("Activate Enemy")
|
||||||
self.enemy_list.remove(enemy)
|
self.active_enemies.append(enemy)
|
||||||
|
self.enemy_list.remove(enemy)
|
||||||
try:
|
try:
|
||||||
for enemy in self.active_enemies:
|
for enemy in self.active_enemies:
|
||||||
enemy.update()
|
enemy.update()
|
||||||
@@ -293,7 +301,7 @@ class Game(arcade.Window):
|
|||||||
# Projectile updates
|
# Projectile updates
|
||||||
self.bullet_list.update()
|
self.bullet_list.update()
|
||||||
for bullet in self.bullet_list:
|
for bullet in self.bullet_list:
|
||||||
|
|
||||||
# Collision Checks
|
# Collision Checks
|
||||||
hit_list = arcade.check_for_collision_with_list(bullet, self.dungeon.getWalls())
|
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 = arcade.check_for_collision_with_list(bullet, self.active_enemies)
|
||||||
|
|||||||
@@ -32,8 +32,6 @@ class Mob(arcade.Sprite):
|
|||||||
self.target = None
|
self.target = None
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class Player(Mob):
|
class Player(Mob):
|
||||||
"""
|
"""
|
||||||
Represents a Player.
|
Represents a Player.
|
||||||
@@ -67,7 +65,6 @@ class Player(Mob):
|
|||||||
print("+++++++++++++++++++++++++++++++++++++++++++++++++++++++")
|
print("+++++++++++++++++++++++++++++++++++++++++++++++++++++++")
|
||||||
self.kill_list = []
|
self.kill_list = []
|
||||||
|
|
||||||
|
|
||||||
def update_animation(self, delta_time: float = 1 / 60) -> None:
|
def update_animation(self, delta_time: float = 1 / 60) -> None:
|
||||||
"""
|
"""
|
||||||
Updates animations for the Player.
|
Updates animations for the Player.
|
||||||
@@ -161,4 +158,3 @@ class Enemy(Mob):
|
|||||||
paths, runs = self.dungeon.finder.find_path(start, end, self.dungeon.grid)
|
paths, runs = self.dungeon.finder.find_path(start, end, self.dungeon.grid)
|
||||||
self.dungeon.grid.cleanup()
|
self.dungeon.grid.cleanup()
|
||||||
return paths
|
return paths
|
||||||
|
|
||||||
|
|||||||
@@ -1,60 +1,62 @@
|
|||||||
'''
|
'''
|
||||||
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 updgrade
|
||||||
'''
|
'''
|
||||||
|
|
||||||
import arcade
|
import arcade
|
||||||
|
|
||||||
from enum import Enum
|
from enum import Enum
|
||||||
|
|
||||||
|
|
||||||
class Recipe(Enum):
|
class Recipe(Enum):
|
||||||
'''A class of different recipes'''
|
'''
|
||||||
|
A class of different recipes
|
||||||
GHOSTS = ['ghost', 'ghost', 'ghost']
|
'''
|
||||||
FROGS = ['frog', 'frog', 'frog']
|
|
||||||
GHOST_FROG = ['ghost', 'ghost', 'frog']
|
GHOSTS = ['ghost', 'ghost', 'ghost']
|
||||||
FROG_GHOST = ['ghost', 'frog', 'frog']
|
FROGS = ['frog', 'frog', 'frog']
|
||||||
|
GHOST_FROG = ['ghost', 'ghost', 'frog']
|
||||||
|
FROG_GHOST = ['ghost', 'frog', 'frog']
|
||||||
|
|
||||||
|
|
||||||
class ActiveRecipe(arcade.SpriteList):
|
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):
|
def __init__(self):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self.active = Recipe.GHOSTS
|
self.active = Recipe.GHOSTS
|
||||||
self.cycle_recipes = [self.set_frogs, self.set_ghosts]
|
self.cycle_recipes = [self.set_frogs, self.set_ghosts]
|
||||||
self.pos = 0
|
self.pos = 0
|
||||||
|
|
||||||
|
|
||||||
def render(self) -> None:
|
def render(self) -> None:
|
||||||
x = 0
|
x = 0
|
||||||
for sprite in self.sprite_list:
|
for sprite in self.sprite_list:
|
||||||
screen_right = arcade.get_viewport()[1] - 100
|
screen_right = arcade.get_viewport()[1] - 100
|
||||||
screen_top = arcade.get_viewport()[3] - 80
|
screen_top = arcade.get_viewport()[3] - 80
|
||||||
sprite.scale = 4
|
sprite.scale = 4
|
||||||
sprite.center_x = screen_right - x
|
sprite.center_x = screen_right - x
|
||||||
sprite.center_y = screen_top
|
sprite.center_y = screen_top
|
||||||
x += 70
|
x += 70
|
||||||
sprite.draw()
|
sprite.draw()
|
||||||
|
|
||||||
def next_recipe(self):
|
def next_recipe(self):
|
||||||
|
|
||||||
self.cycle_recipes[self.pos]()
|
self.cycle_recipes[self.pos]()
|
||||||
self.pos += 1
|
self.pos += 1
|
||||||
if self.pos == len(self.cycle_recipes):
|
if self.pos == len(self.cycle_recipes):
|
||||||
self.pos = 0
|
self.pos = 0
|
||||||
|
|
||||||
def set_ghosts(self) -> None:
|
def set_ghosts(self) -> None:
|
||||||
self.active = Recipe.GHOSTS
|
self.active = Recipe.GHOSTS
|
||||||
self.sprite_list = []
|
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"))
|
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:
|
def set_frogs(self) -> None:
|
||||||
self.active = Recipe.FROGS
|
self.active = Recipe.FROGS
|
||||||
self.sprite_list = []
|
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"))
|
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