Return to repo list

heart-of-gold

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

commit 673554315117b47ac2b76f455db05af565aa8e1c
parent db274a2b0d909e89599feb1f8768ae06df35f422
Author: Erik Letson <hmagellan@hmagellan.com>
Date:   Sun, 20 Sep 2020 12:52:25 -0500

Brief cleanup

Diffstat:
Msrc/board.py | 4+---
Msrc/game.py | 6++----
Msrc/vgo.py | 16+---------------
3 files changed, 4 insertions(+), 22 deletions(-)

diff --git a/src/board.py b/src/board.py @@ -92,12 +92,10 @@ class BoardManager(manager.Manager): move range from overlay if no entity is passed. """ if ent != None: - bt = ent.tile_pos - mv = ent.unit.active_stats["MOVE"] for layer in self.current_board.tmx_data.visible_layers: if isinstance(layer, pytmx.TiledTileLayer): for x, y, gid in layer: - if abs(x - bt[0]) <= mv and abs(y - bt[1]) <= mv: + if abs(x - ent.tile_pos[0]) <= ent.unit.active_stats["MOVE"] and abs(y - ent.tile_pos[1]) <= ent.unit.active_stats["MOVE"]: v = vgo.VisibleGameObject(self.game.sheet_manager.loaded_sheets["board_overlays_1"]) v.set_position((x * self.current_board.tmx_data.tilewidth, y * self.current_board.tmx_data.tileheight)) v.set_sprite((1, 0)) diff --git a/src/game.py b/src/game.py @@ -167,8 +167,7 @@ class GameInterface(GameSubsystem): React to a mousebutton being clicked. """ if event.button == 1: - t = self.game.board_manager.get_tile_at_position(pygame.mouse.get_pos()) - self.game.entity_manager.select_entities_with_tile_cursor(t) + self.game.entity_manager.select_entities_with_tile_cursor(self.game.board_manager.get_tile_at_position(pygame.mouse.get_pos())) def handle_mouse_release(self, event): """ @@ -183,5 +182,4 @@ class GameInterface(GameSubsystem): e.g. an Entity, and is logic-only. """ # Update cursor position - t = self.game.board_manager.get_tile_at_position(pygame.mouse.get_pos()) - self.game.entity_manager.position_tile_cursor(t) + self.game.entity_manager.position_tile_cursor(self.game.board_manager.get_tile_at_position(pygame.mouse.get_pos())) diff --git a/src/vgo.py b/src/vgo.py @@ -212,11 +212,10 @@ class EntityManager(manager.Manager): j = json.load(open(os.path.join(ENTITY_JSON_PATH, entsjson))) for e in j: - s = self.game.unit_manager.get_stats(j[e]["name"]) ne = Entity(j[e]["name"], self.total_entities, self.game.sheet_manager.loaded_sheets[j[e]["sheet"]], self.game.sheet_manager.animations[j[e]["sheet"]][j[e]["animation"]], - j[e]["animated"], j[e]["passable"], unit.Unit(self, s)) + j[e]["animated"], j[e]["passable"], unit.Unit(self, self.game.unit_manager.get_stats(j[e]["name"]))) ne.assign_tile(self.game.board_manager.get_tile_at_tile_pos(tuple(j[e]["tile"]))) ne.snap_to_tile() self.add_entity(ne) @@ -234,21 +233,8 @@ class EntityManager(manager.Manager): Snap the TileCursor object's position to 'pos' and set the tile GID there as the current tile_cursor's selected tile. """ - # TODO: Cleanup this. It is mostly a bunch of additional - # stuff that doesn't have to be here. It just helps with - # debug. The only important things are the two calls to - # self.tile_cursor methods. - #ot = (self.tile_cursor.tile_pos, self.tile_cursor.tile_gid) self.tile_cursor.assign_tile(tile_def) self.tile_cursor.snap_to_tile() - #if ot != (self.tile_cursor.tile_pos, self.tile_cursor.tile_gid): - # e = self.get_entities_by_tile(tile_def) - # print(self.game.board_manager.get_tile_at_tile_pos(self.tile_cursor.tile_pos)) - # if e != []: - # for en in e: - # if en.unit != None: - # print("Occupied by: " + en.name + "(" + str(en.ent_id) + ")") - # print("HP: " + str(en.unit.active_stats["HP"])) def get_entities_by_tile(self, tile_def): """