commit 08df1ae377189703c03a7c9f17a06c19ee007249
parent 5c38967ff1ecd75943143cc495d5168a233c47f1
Author: Erik Letson <hmagellan@hmagellan.com>
Date: Mon, 2 Nov 2020 13:25:22 -0600
Some refactoring
Diffstat:
3 files changed, 27 insertions(+), 69 deletions(-)
diff --git a/src/menu.py b/src/menu.py
@@ -113,7 +113,7 @@ class Menu(object):
# Load buttons, if any
for b in self.definition["buttons"]:
- nmb = vgo.MenuButton(b, self.contained_entities,
+ nmb = MenuButton(b, self.contained_entities,
self.manager.game.sheet_manager.loaded_sheets[self.definition["buttons"][b]["sheet"]],
tuple(self.definition["buttons"][b]["sprite"]), None, False, True, None, self.definition["buttons"][b]["effects"])
nmb.rect.topleft = tuple(self.definition["buttons"][b]["pos"])
@@ -129,3 +129,29 @@ class Menu(object):
if surface != None:
# TODO: Add the other groups when they get made
self.button_group.update(surface)
+
+#############################
+# Section 3 - Menu Entities #
+#############################
+
+class MenuButton(vgo.Entity):
+ """
+ Object that represents pushable menu buttons in menu mode. Created
+ and managed by Menu objects.
+ """
+ # TODO: MenuButton should probably eventually be passed info on its draw layer.
+
+ def __init__(self, name, ent_id, sheet, sprite = (0, 0), animation = None, animated = False, passable = True, unit = None, effects = []):
+
+ # Parent initialization
+ super().__init__(name, ent_id, sheet, sprite, animation, animated, passable, unit)
+
+ # Saved values
+ self.effects = effects # A list of effects. Each effect goes with a method in MenuManager, and each one is triggered on a press.
+
+ # VGO settings
+ self.custom_flags = None
+
+ # DirtySprite settings
+ self.layer = 1
+
diff --git a/src/move.py b/src/move.py
@@ -1,47 +0,0 @@
-import pygame
-from . import board
-from .constants import TILE_WIDTH, TILE_HEIGHT
-
-
-###########
-# move.py #
-###########
-
-# This file contains:
-# 1. The GenericMove class, which contains helper methods and values used by entities to move on the game board.
-# 2. The AIMove class, which inherits GenericMove and is used by entities with AI control to move.
-
-# NOTE: Player-controlled units just get the GenericMove class, since Interface or a Manager can use the methods
-# it contains to move such a unit.
-
-#####################################
-# Section 1 - The GenericMove class #
-#####################################
-
-class GenericMove(object):
- """
- GenericMove contains data, structures, values, and
- methods that are used by Entities in a tile board to
- move from tile to tile. An entity is created with a
- 'move' value that is a GenericMove object or one of
- its child objects.
- """
-
- def __init__(self, entity):
-
- self.entity = entity
-
-################################
-# Section 2 - The AIMove class #
-################################
-
-class AIMove(GenericMove):
- """
- GenericMove class with additional functionality for
- AI-controlled entities.
- """
-
- def __init__(self, entity):
-
- # Parent initialization
- super().__init__(entity)
diff --git a/src/vgo.py b/src/vgo.py
@@ -240,27 +240,6 @@ class Entity(VisibleGameObject):
# Section 3 - Various Entity subclasses #
#########################################
-class MenuButton(Entity):
- """
- Object that represents pushable menu buttons in menu mode. Created
- and managed by Menu objects.
- """
- # TODO: MenuButton should probably eventually be passed info on its draw layer.
-
- def __init__(self, name, ent_id, sheet, sprite = (0, 0), animation = None, animated = False, passable = True, unit = None, effects = []):
-
- # Parent initialization
- super().__init__(name, ent_id, sheet, sprite, animation, animated, passable, unit)
-
- # Saved values
- self.effects = effects # A list of effects. Each effect goes with a method in MenuManager, and each one is triggered on a press.
-
- # VGO settings
- self.custom_flags = None
-
- # DirtySprite settings
- self.layer = 1
-
class TileCursor(Entity):
"""
Object that follows the cursor to indicate selected/highlighted