The playing field (Board)¶
The first world¶
We create a first world. This can be created with the following code:
1import miniworldmaker 2 3board = miniworldmaker.TiledBoard() 4board.add_background("images/soccer_green.jpg") 5board.columns = 20 6board.rows = 8 7board.tile_size = 42 8board.speed = 30 9 10board.run()
What happens here?¶
Line 1: The miniworldmaker library is imported.
Line 3: A new object of type
Line 4: The new object gets a
Line 5-8: Various attributes of
Line 10: The game is started. With
board.run()a mainloop is started, which draws the board over and over again. This statement must always be the last line of your code.
Depending on the background image, your result will look like this:
Some theory: How does Miniworldmaker work?¶
In Miniworldmaker there are two different types of objects you can create:
Board: A game board on which there are game pieces.
Token: Game pieces that have numerous attributes and methods, e.g. movement,
collision detection, ….
In the next chapters you will learn how to create tokens that can communicate with each other.
Outlook: Different boards¶
There are several child classes of board
TiledBoardis appropriate for boards where actors move on “tiles”.
PixelBoardis intended for pixel-precise representations.
PhysicsBoardsimulates physical properties and objects on the board.
Some features of the boards (e.g. collisions) differ slightly.