Taming the Processing loop

In Mikamai we do a lot of reasearch on non conventional hardware, we make prototypes and create unusual interfaces that are very domain specific.

Like this one


Seriously, we did it.

To quickly sketch ideas, we often rely on Processing, it’s super easy and its loop based execution model gives the feeling of programming a video game.
The drawback is that it is so fast to get something working, that you will be tempted to make the mistake of creating a polished prototpe.
Your prototype code ends up in production and there’s no way back from there.

To resist the temptation of releasing a blob of code, I borrowed a technique from one of the Rob Pike’s talks to keep things easy, while keeping them clean at the same time.

It is basically an implementation of a state machime.
We’re gonna have a StateMachine class that handles the inputs and the state changes, and several state classes that implement the State interface.
The interface is very simple and contains only one method

Continue reading “Taming the Processing loop”