mirror of
https://github.com/n0remac/game-jam-2020.git
synced 2025-12-06 15:13:13 -06:00
move everything into init and use restart kwarg, remove setup function
This commit is contained in:
@@ -44,7 +44,7 @@ class Config(object):
|
|||||||
TOP_VIEWPORT_MARGIN = 350
|
TOP_VIEWPORT_MARGIN = 350
|
||||||
|
|
||||||
# All debug statements and renderings should use this
|
# All debug statements and renderings should use this
|
||||||
DEBUG = False
|
DEBUG = True
|
||||||
|
|
||||||
# Monster Count to be spawned
|
# Monster Count to be spawned
|
||||||
MONSTER_COUNT = 6
|
MONSTER_COUNT = 6
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ from mobs import Player, MobHandler, Mob
|
|||||||
from projectiles import Temp
|
from projectiles import Temp
|
||||||
from recipe import ActiveRecipe
|
from recipe import ActiveRecipe
|
||||||
|
|
||||||
|
|
||||||
class FPSCounter:
|
class FPSCounter:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.time = time.perf_counter()
|
self.time = time.perf_counter()
|
||||||
@@ -41,27 +42,12 @@ class Game(arcade.Window):
|
|||||||
Main application class.
|
Main application class.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self, restart=False):
|
||||||
# Call the parent class and set up the window
|
# Call the parent class and set up the window
|
||||||
super().__init__(Config.SCREEN_WIDTH, Config.SCREEN_HEIGHT, Config.SCREEN_TITLE)
|
if not restart:
|
||||||
|
super().__init__(Config.SCREEN_WIDTH, Config.SCREEN_HEIGHT, Config.SCREEN_TITLE)
|
||||||
|
arcade.set_background_color(arcade.color.BLACK)
|
||||||
|
|
||||||
# Sprite Lists
|
|
||||||
self.enemy_list = None
|
|
||||||
self.active_enemies = []
|
|
||||||
self.bullet_list = None
|
|
||||||
self.player = None
|
|
||||||
# Game Objects
|
|
||||||
self.dungeon = None
|
|
||||||
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.enemies_in_range = []
|
|
||||||
|
|
||||||
arcade.set_background_color(arcade.color.BLACK)
|
|
||||||
|
|
||||||
def setup(self):
|
|
||||||
""" Set up the game here. Call this function to restart the game. """
|
|
||||||
# Create the Sprite lists
|
# Create the Sprite lists
|
||||||
self.fps = FPSCounter()
|
self.fps = FPSCounter()
|
||||||
self.bullet_list = arcade.SpriteList()
|
self.bullet_list = arcade.SpriteList()
|
||||||
@@ -116,7 +102,7 @@ class Game(arcade.Window):
|
|||||||
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:
|
||||||
@@ -298,7 +284,6 @@ def main() -> None:
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
window = Game()
|
window = Game()
|
||||||
window.setup()
|
|
||||||
arcade.run()
|
arcade.run()
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user