Return to repo list

heart-of-gold

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

commit f12233fd6de3394a046c34c09c5bb337b73c8ed3
parent 71f2b137322bc99074f9d04c6346551c5acb2c7b
Author: Erik Letson <hmagellan@hmagellan.com>
Date:   Wed,  9 Sep 2020 22:55:39 -0500

Board is now drawable

Diffstat:
Msrc/board.py | 13++++++-------
Msrc/game.py | 11++++++++++-
Msrc/manager.py | 5+++++
3 files changed, 21 insertions(+), 8 deletions(-)

diff --git a/src/board.py b/src/board.py @@ -1,4 +1,4 @@ -import pygame, pytmx +import pygame, pytmx, os from . import manager from .constants import BOARD_PATH @@ -55,10 +55,9 @@ class BoardManager(manager.Manager): class Board(object): """ - Board is a manager object for tiles. It maintains a grid of - tiles that represent the play area, and handles things like - creating these tiles, telling them what tiles they are - adjacent to, and updating the tile through its tile group. + Board is an object that consists of a Pytmx Tiled map and + some functions for drawing it. Board is managed by a + BoardManager object. """ def __init__(self, manager, filename): @@ -68,11 +67,11 @@ class Board(object): self.filename = filename # Pytmx values - self.tmx_data = pytmx.load_pygame(self.filename) + self.tmx_data = pytmx.load_pygame(os.path.join(BOARD_PATH, self.filename)) self.grid_width = self.tmx_data.width * self.tmx_data.tilewidth self.grid_height = self.tmx_data.height * self.tmx_data.tileheight - def draw_map(self, surface = None): + def draw_board(self, surface = None): """ Draw the tiles of the board onto the provided PyGame surface object. diff --git a/src/game.py b/src/game.py @@ -1,4 +1,5 @@ import pygame +from . import board, vgo from .constants import SCREEN_WIDTH, SCREEN_HEIGHT, FRAMERATE ########### @@ -37,6 +38,14 @@ class Game(object): # Subsystems self.interface = GameInterface(self) + # Managers + self.board_manager = board.BoardManager(self) + + # Setup (This is WIP) + # TODO: Fix this up, will see lots of revision + self.board_manager.load_board_from_file("testmap1.tmx") + self.board_manager.switch_to_board("testmap1.tmx") + def shift_frames(self): """ Shift to the next frame using the PyGame Clock object. @@ -53,7 +62,7 @@ class Game(object): self.screen.fill((0, 0, 0)) # Next, update all the subsurfaces/game objects and draw them - # TODO + self.board_manager.update_board(self.screen) # Last, update the screen pygame.display.update() diff --git a/src/manager.py b/src/manager.py @@ -1,6 +1,11 @@ import pygame class Manager(object): + """ + Extremely simple parent type for the various + managers of different game elements, such as + the play board or the UI. + """ def __init__(self, game):