# Shorty #01: Board constructor

# Introduction

The Board object is the base of your level design. As such it is very important to master the different options of the constructor so your Board look and behave how you like.

Good luck! 👩‍🎓 👨‍🎓

# hac-game-lib

To follow this tutorial you will need the hac-game-lib on your system.
You can either get it on Github or (this is the preferred solution) install it from PyPi by running:

pip3 install virtualenv --user
virtualenv hgl-shorty-1
cd hgl-shorty-1
source bin/activate
pip3 install -i https://test.pypi.org/simple/ hac-game-lib

# Video

This shorty is done under the form of a code along video available on Youtube (still a bad one but bear with us, it'll become better over time). It is also using the interactive interpreter, so we don't save any files here. The code section is therefor more an example of what you are going to find in the tutorial than anything else.

# Code

Here is an example of the code, you'll find in this shorty video.

from gamelib.Board import Board
import gamelib.Utils as Utils
import gamelib.Sprites as Sprites

myboard = Board(
    size=[5,5], 
    ui_border_top=Utils.WHITE_SQUARE, 
    ui_border_left=Utils.WHITE_SQUARE, 
    ui_border_bottom=Utils.MAGENTA_SQUARE, 
    ui_border_right=Utils.MAGENTA_SQUARE,
    ui_board_void_cell=Utils.BLACK_SQUARE
    )

myboard.display()

myboard = Board(
    size=[5,5], 
    ui_borders=Sprites.WALL , 
    ui_board_void_cell=Utils.BLACK_SQUARE
    )

myboard.display()

# Get creative!
myboard = Board(
    size=[5,5], 
    ui_borders=Sprites.UNICORN_FACE , 
    ui_board_void_cell=Utils.CYAN_SQUARE,
    player_starting_position=[2,3]
    )

myboard.display()

# Share

If you like that content, feel free to share it on social platforms:

# Comments

Last Updated: 5/18/2019, 6:46:55 AM