Return to repo list

heart-of-gold

Tactical RPG written in python, using pygame.
Return to HMagellan.com

commit f852d39a3dcddc612b3b5165b5eec95907744619
parent 8f44b99515282e043d8eacec80b040115880825c
Author: Erik Letson <hmagellan@hmagellan.com>
Date:   Wed, 14 Oct 2020 20:17:39 -0500

Enummed piece facing directions

Diffstat:
Msrc/constants.py | 1+
Msrc/vgo.py | 16++++++++--------
2 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/src/constants.py b/src/constants.py @@ -37,3 +37,4 @@ MENU_JSON_PATH = os.path.join(JSON_PATH, "menus") # Enums STATE_MODES = enum.Enum('STATE_MODES', 'Main_Menu_Mode Battle_Mode') CTRL_MODES = enum.Enum('CTRL_MODES', 'Main_Menu_Normal Turn_Normal Turn_Select_Move') +FACE_DIR = enum.Enum('FACE_DIR', 'U D L R') diff --git a/src/vgo.py b/src/vgo.py @@ -1,6 +1,6 @@ import pygame, json, os, math from . import manager, unit -from .constants import ENTITY_JSON_PATH, STATUS_JSON_PATH, TILE_WIDTH, TILE_HEIGHT +from .constants import * ########## # vgo.py # @@ -249,7 +249,7 @@ class Piece(Entity): super().__init__(name, ent_id, sheet, animation, animated, passable, unit) # Face settings - self.facing = "D" # TODO: This should ABSOLUTELY be an enum + self.facing = FACE_DIR.L # Others self.team = team # TODO: team maybe should be defined in unit @@ -267,20 +267,20 @@ class Piece(Entity): my = target_pos[1] - self.rect.topleft[1] a = math.atan2(mx, my) * 180 / math.pi if a >= -67.5 and a < 0: - self.facing = "D" + self.facing = FACE_DIR.D elif a >= 0 and a < 112.5: - self.facing = "R" + self.facing = FACE_DIR.R elif a > 112.5 or a < -112.5: - self.facing = "U" + self.facing = FACE_DIR.U else: - self.facing = "L" + self.facing = FACE_DIR.L # Set a movement animation # TODO: It may be neccessary in the future to indicate whether or not this # animation should be assigned according to whether or not a board move is # actually taking place. Also, this is a very roundabout way to reference # the sheet's animations. Maybe sheets should be aware of their anims? - self.set_animation(self.sheet.manager.animations[self.sheet.name]["walk_" + self.facing], True) + self.set_animation(self.sheet.manager.animations[self.sheet.name]["walk_" + self.facing.name], True) self.back_to_stand = True def act(self): @@ -290,7 +290,7 @@ class Piece(Entity): # TODO: Something else should be done so that this doesn't overwrite other # legit non-walking, non-standing anims. THIS MAY NOT BE THE BEST. if self.motion == {} and self.back_to_stand: - self.set_animation(self.sheet.manager.animations[self.sheet.name]["stand_" + self.facing], True) + self.set_animation(self.sheet.manager.animations[self.sheet.name]["stand_" + self.facing.name], True) self.back_to_stand = False ##############################################