Managing states

You don’t appreciate just how complex a pinball machine is until you write one. Even something as simple as powering up the machine requires event handling code.

For example, if the previous player lost  (or powered the machine down) while balls were locked, we need to get those into the trough to start. There could also be a ball stuck in the second stage ball save, or the pit. Maybe one in all three!

This last state ensures we can’t just ‘Fire all the solenoids!’ as we’d quickly find ourselves with one less fuse on our hands; and for good reason. All three of those solenoids are 50v and even if the fuse was upgraded for it, the power supply would likely choke on the inrush. So we need to separate the events with timers. Not a huge deal… But we also have to consider the mutiball locks are a closed loop, so we need to kick out the diverter at the right time as well.

After solving these problems, I made sure the game state is self contained. This means we can switch in and out of the game state as needed. The idea is when we drain, we’ll hop into a “Collect bonus” state, then launch back into the game state again. The fun complexity here is monitoring and remembering how many balls counts as “drained”, especially once multiple players become involved.

Leave a Reply

Your email address will not be published. Required fields are marked *