Return to repo list

heart-of-gold

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

commit 1e364ab27f62898deb69ee8f7b1a56f6c5b2d13d
parent 648d7c11b35c470799957f2f11bbe81bbc9ee618
Author: Erik Letson <hmagellan@hmagellan.com>
Date:   Fri, 18 Sep 2020 22:34:02 -0500

Very very basic movement calculation

Diffstat:
Msrc/board.py | 15+++++++++++++++
Msrc/game.py | 2++
2 files changed, 17 insertions(+), 0 deletions(-)

diff --git a/src/board.py b/src/board.py @@ -86,6 +86,21 @@ class BoardManager(manager.Manager): return (x, y, gid) return None + def display_selected_unit_move_range(self): + """ + Display the move range of the selected unit. + """ + bt = self.game.entity_manager.selected_entities[0].tile_pos + mv = self.game.entity_manager.selected_entities[0].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: + 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)) + self.board_overlay.add(v) + def update_board(self, surface = None): """ Update the current board. diff --git a/src/game.py b/src/game.py @@ -170,7 +170,9 @@ class GameInterface(GameSubsystem): t = self.game.board_manager.get_tile_at_position(pygame.mouse.get_pos()) self.game.entity_manager.select_entities_with_tile_cursor(t) # TODO: This is just debug code below + # TODO: displaying move range needs to be undone if clicking no unit if self.game.entity_manager.selected_entities != None: + self.game.board_manager.display_selected_unit_move_range() for e in self.game.entity_manager.selected_entities: if e.name != "Tile_Cursor": print(e.name)