commit 9f62977576f42a6b356b79b0236bf24562bb1151
parent 2c7debef693365617e76815c31c83a4a117312bd
Author: Erik Letson <hmagellan@hmagellan.com>
Date: Mon, 19 Oct 2020 19:32:11 -0500
Remove GameSubsystem and consolidate it to Manager
Diffstat:
3 files changed, 6 insertions(+), 25 deletions(-)
diff --git a/main.py b/main.py
@@ -18,7 +18,6 @@ from src import game
# manager objects could access the exposed values by talking to the bus. Additionally, the bus could enumerate all the managers that have been given
# bus access, and could expose these managers to other managers as part of a public list/dict. These features would eliminate the ugly "so-and-so.game"
# calls that are popping up all over the code here.
-# 6. Get rid of subsystem objects and make Interface a manager.
# Initialization of pygame and submodules
pygame.mixer.pre_init(44100, -16, 4, 1024)
diff --git a/src/game.py b/src/game.py
@@ -1,5 +1,5 @@
import pygame
-from . import images, sound, board, vgo, unit, menu, scene
+from . import manager, images, sound, board, vgo, unit, menu, scene
from .constants import *
###########
@@ -8,8 +8,7 @@ from .constants import *
# This file contains:
# 1. The 'Game' class, which defines the overarching game object
-# 2. The generic 'GameSubsystem' class which defines general behavior for all subsystems
-# 3. The 'GameInterface' subsystem, which handles all pygame events
+# 2. The 'GameInterface' subsystem, which handles all pygame events
###########################
# Section 1 - Game object #
@@ -145,29 +144,11 @@ class Game(object):
# When we turn off, cleanup and end
pygame.quit()
-############################################
-# Section 2 - Generic GameSubsystem Object #
-############################################
-
-class GameSubsystem(object):
- """
- Generic class for all top-level game element controllers
- that are used by the Game object for various things. This
- class is relatively simple. All subsystems can talk to
- Game directly, but should avoid changing values in other
- objects and rely on calling methods in those objects.
- """
-
- def __init__(self, game):
-
- # Universal Subsystem values
- self.game = game
-
##############################################
-# Section 3 - GameInterface Subsystem Object #
+# Section 2 - GameInterface Subsystem Object #
##############################################
-class GameInterface(GameSubsystem):
+class GameInterface(manager.Manager):
"""
GameInterface handles all PyGame events, meaning it is
responsible for all input and the responses to that
diff --git a/src/scene.py b/src/scene.py
@@ -138,6 +138,8 @@ class StillScene(object):
# First, clear up and prepare
self.displayed_strings = [""]
self.rendered_text_surfaces = [None]
+ self.rendered_name = None
+ self.rendered_name_topleft = (0, 0)
self.line_number = 0
self.current_line_starting_index = 0
self.displayed_characters.empty()
@@ -157,7 +159,6 @@ class StillScene(object):
self.displayed_characters.add(nc)
if self.script[self.script_index]["speaker"] != None:
self.rendered_name = self.current_name_font.render(self.script[self.script_index]["speaker"], False, (255, 255, 255)).convert()
- #self.rendered_name_topleft = (self.name_box_pos[0] + (self.rendered_name.get_width() / 2) + (self.name_box.image.get_width() / 2), self.name_box_pos[1] + (self.rendered_name.get_height() / 2) + (self.name_box.image.get_width() / 2))
self.rendered_name_topleft = (self.name_box_pos[0] + ((self.name_box.image.get_width() / 2) - (self.rendered_name.get_width() / 2)), self.name_box_pos[1] + ((self.name_box.image.get_height() / 2) - (self.rendered_name.get_height() / 2)))
def write_text(self):