Gameboard
From Future Skill
Revision as of 11:00, 8 April 2021 by KimSimmons (talk | contribs)
Revision as of 11:00, 8 April 2021 by KimSimmons (talk | contribs)
[DRAFT] The GameBoard library
A reusable and configurable system for game-like challenges.
[TODO]
- Board quick setup
- Creating and placing a gamepiece
- Pathfinding
- Styling concepts
- Custom board setup
GameBoard quick setup
Here's an example to quickly get up and running:
from gameboard import GameBoard from gameboard_helpers import CommonSetups, Style class Challenge: fn __init__(self, context): ... board = GameBoard() CommonSetups.square(board) Style.topdown(board, context.canvas) board.fill(10, 10)
The CommonSetups class configures the board to use a square tiled grid with four directions. The Styles class then configures how the board is displayed, with what tiles and how they are laid out. [TODO] add link to documentation for CommonSetups and Styles.
You can fit the board into view with the function fit_board_into(board, x, y, w, h), provided in the gameboard_helpers module.
GamePiece
The GamePiece class should be used for anything that can be placed on the GameBoard. You'll mainly control which cell on the board it's located on.
from gameboard import GameBoard, GamePiece class Challenge: def __init__(self, context): board = GameBoard() actor = GamePiece(context.canvas.new_circle(1.0, '#FF00FF')) board.place_game_piece(actor, 1, 1)