Piader v2 – skeleton

LCDmanger doesn’t care about application logic its job is to display. So its up to us and application to use events and change views. Each app may have different actions and effects.

So what now ?
Simple we will create new project Piader and use LCD Manager as external package. This way we will have two separate projects. And we may focus on develop them separately.

Install LCD Manager in development mode

Piader require manager but we want to keep projects apart. Simplest solution is to install manager in developer mode. This will allow us to import it anywhere and still we are able to change its code.

It’s quite simple, prepare project to distribute by adding all files that PIP require and in project root type:

sudo python setup.py develop

This will create and install package.

Piader – again

As a base for game I will use previous version of Piader. We have basic game logic, sprites and events. I won’t go into details what was copied and changed. I will just point things that made me change lcdmanager class. And when we reach a basic structure I will post code.

First problem I ran into was not being able to read width and height. Yep we forgot about such simple functionality. Open manager.py and add

        self.size = {
            'width': self.lcd.get_width(),
            'height': self.lcd.get_height()

into __init__ function and add property readers:

    def width(self):
        """manager width"""
        return self.size['width']

    def height(self):
        """manager height"""
        return self.size['height']

In Piader 1 we had a single game main loop. We need to change this.  We will create three tabs. First one home tab with game menu. Second a game tab and third with options.
Lets think how we can consume and run proper events. Why ? Because each screen has different work flow. Home screen will use up, down and action events. Third will add left, right and back. For now lets ignore second screen. Of course we need main loop to rule them all 🙂

Main loop is responsible for keeping fps, for reading events and calling proper action tab, depending on current gui state. As for gui sate, first try will be with simple variable: gui_current_tab. I was thinking about state machine for gui but it would be overkill 🙂

Stop! Jenkins time!

That was mess, I forgot to replace imports after coping files from old Piader. It gave many errors 🙂
Next few tweaks with variables and comments and finally 0 errors 🙂


We have refactored and prepared code for Piader v2. In next part we will focus on home screen and views.

Download source


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.