Difference between revisions of "Gameboard"
From Future Skill
KimSimmons (talk | contribs) |
KimSimmons (talk | contribs) |
||
Line 45: | Line 45: | ||
</nowiki> | </nowiki> | ||
</div> | </div> | ||
+ | You can use it as-is for many cases or create your own derived class from it for more flexibility. |
Revision as of 11:03, 8 April 2021
[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)
You can use it as-is for many cases or create your own derived class from it for more flexibility.