The playing field (Board)

Let’s go!

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 TiledBoard is created.

  • Line 4: The new object gets a background.

  • Line 5-8: Various attributes of board are changed.

  • 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.

Result:

Depending on the background image, your result will look like this:

First Miniworldmaker Example

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

  • A TiledBoard is appropriate for boards where actors move on “tiles”.

  • A PixelBoard is intended for pixel-precise representations.

  • A PhysicsBoard simulates physical properties and objects on the board.

Some features of the boards (e.g. collisions) differ slightly.