move everything into init and use restart kwarg, remove setup function

This commit is contained in:
Xevion
2020-04-24 17:21:35 -05:00
parent 67677eb6ce
commit ad04d2a6e1
2 changed files with 7 additions and 22 deletions

View File

@@ -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

View File

@@ -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
if not restart:
super().__init__(Config.SCREEN_WIDTH, Config.SCREEN_HEIGHT, Config.SCREEN_TITLE) super().__init__(Config.SCREEN_WIDTH, Config.SCREEN_HEIGHT, Config.SCREEN_TITLE)
# 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) 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()
@@ -298,7 +284,6 @@ def main() -> None:
""" """
window = Game() window = Game()
window.setup()
arcade.run() arcade.run()