basic reformatting work for PEP8 guidelines

This commit is contained in:
Xevion
2020-04-18 01:36:13 -05:00
parent d24e166e72
commit 3961414279
3 changed files with 12 additions and 13 deletions

View File

@@ -4,6 +4,7 @@ Holds all constants used for setting up the game.
May later hold functions for loading/saving configuration files. May later hold functions for loading/saving configuration files.
""" """
class Config(object): class Config(object):
""" """
A simple class dedicated to loading, storing and organizing constants. A simple class dedicated to loading, storing and organizing constants.

View File

@@ -8,6 +8,7 @@ import arcade
from config import Config from config import Config
class Game(arcade.Window): class Game(arcade.Window):
""" """
Main application class. Main application class.
@@ -29,7 +30,7 @@ class Game(arcade.Window):
# Our physics engine # Our physics engine
self.physics_engine = None self.physics_engine = None
#list to keep track of keypresses # list to keep track of keypresses
self.prev_keypress = [] self.prev_keypress = []
# Used to keep track of our scrolling # Used to keep track of our scrolling
@@ -108,38 +109,31 @@ class Game(arcade.Window):
self.prev_keypress.remove(key) self.prev_keypress.remove(key)
if self.prev_keypress: if self.prev_keypress:
self.on_key_press(self.prev_keypress.pop(0), '') self.on_key_press(self.prev_keypress.pop(0), 0)
def on_update(self, delta_time): def on_update(self, delta_time):
""" Movement and game logic """ """ Movement and game logic """
# Move the player with the physics engine # Move the player with the physics engine
self.physics_engine.update() self.physics_engine.update()
changed = False # Track if we need to change the viewport
# --- Manage Scrolling --- # Below manages all scrolling mechanics
# Track if we need to change the viewport
changed = False
# Scroll left # Scroll left
left_boundary = self.view_left + Config.LEFT_VIEWPORT_MARGIN left_boundary = self.view_left + Config.LEFT_VIEWPORT_MARGIN
if self.player_sprite.left < left_boundary: if self.player_sprite.left < left_boundary:
self.view_left -= left_boundary - self.player_sprite.left self.view_left -= left_boundary - self.player_sprite.left
changed = True changed = True
# Scroll right # Scroll right
right_boundary = self.view_left + Config.SCREEN_WIDTH - Config.RIGHT_VIEWPORT_MARGIN right_boundary = self.view_left + Config.SCREEN_WIDTH - Config.RIGHT_VIEWPORT_MARGIN
if self.player_sprite.right > right_boundary: if self.player_sprite.right > right_boundary:
self.view_left += self.player_sprite.right - right_boundary self.view_left += self.player_sprite.right - right_boundary
changed = True changed = True
# Scroll up # Scroll up
top_boundary = self.view_bottom + Config.SCREEN_HEIGHT - Config.TOP_VIEWPORT_MARGIN top_boundary = self.view_bottom + Config.SCREEN_HEIGHT - Config.TOP_VIEWPORT_MARGIN
if self.player_sprite.top > top_boundary: if self.player_sprite.top > top_boundary:
self.view_bottom += self.player_sprite.top - top_boundary self.view_bottom += self.player_sprite.top - top_boundary
changed = True changed = True
# Scroll down # Scroll down
bottom_boundary = self.view_bottom + Config.BOTTOM_VIEWPORT_MARGIN bottom_boundary = self.view_bottom + Config.BOTTOM_VIEWPORT_MARGIN
if self.player_sprite.bottom < bottom_boundary: if self.player_sprite.bottom < bottom_boundary:
@@ -159,8 +153,11 @@ class Game(arcade.Window):
Config.SCREEN_HEIGHT + self.view_bottom) Config.SCREEN_HEIGHT + self.view_bottom)
def main(): def main() -> None:
""" Main method """ """
Setups up window classes and runs the game.
"""
window = Game() window = Game()
window.setup() window.setup()
arcade.run() arcade.run()

View File

@@ -7,6 +7,7 @@ import arcade
from config import Config from config import Config
class Mob(object): class Mob(object):
""" """
Represents a Mob. No defined behaviour, it has no intelligence. Represents a Mob. No defined behaviour, it has no intelligence.