Difference between revisions of "Gameboard"
From Future Skill
KimSimmons (talk | contribs) |
KimSimmons (talk | contribs) |
||
Line 6: | Line 6: | ||
* Creating and placing a gamepiece | * Creating and placing a gamepiece | ||
* Pathfinding | * Pathfinding | ||
+ | * Styling concepts | ||
* Custom board setup | * Custom board setup | ||
Line 17: | Line 18: | ||
class Challenge: | class Challenge: | ||
fn __init__(self, context): | fn __init__(self, context): | ||
+ | ... | ||
board = GameBoard() | board = GameBoard() | ||
CommonSetups.square(board) | CommonSetups.square(board) | ||
Line 24: | Line 26: | ||
</div> | </div> | ||
− | The CommonSetups class configures the board to use a square tiled grid with four directions. | + | 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. | + | 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. | ||
+ | <div style="background: #F0F0F0"> | ||
+ | <nowiki> | ||
+ | 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) | ||
+ | </nowiki> | ||
+ | </div> |
Revision as of 11:00, 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)