Jump to: navigation, search

Difference between revisions of "Programming"

(Light Shows)
(Procedures)
Line 92: Line 92:
  
 
[[Extra Ball]]
 
[[Extra Ball]]
 +
 +
=== Kickback ===
  
 
[[Kickback]]
 
[[Kickback]]

Revision as of 23:16, 25 January 2015

After the initial whitewood has been built, it is time to bring it to life by programming the control system and adding game rules.

Rules

As pinball hardware advanced in complexity from simple relays to transistors, so did game rules. Electromechanical (EM) pinball machines often struggled to register multiple switch hits at the same time, while early Solid State (SS) games allowed fast response times and multiple concurrent switch hits to be registered. Faster CPUs with more memory allow for the deeper rule sets of modern pinball.

Rules can be as simple as Complete the rollovers for bonus multiplier to stacking several mode-scoring multiballs together.

Maintaining State

Deeper rule tracking requires maintaining State, which is a map (in memory) of the current switch conditions, such as:

  • What was the state of all the switches N seconds ago?
  • Has anything changed in N seconds?
  • How many times has a switch been hit total?


These are all States and the control program keeping track of these allows for modes and other advanced rules.

Think of an orbit shot: two switches, one of the left side orbit entry, one of the right side orbit entry. An orbit is complete if both switches are hit in order. It takes time for the ball to travel from one side to the other - there may be 5 seconds or more if the ball is slow, struggles to get to the apex, or dribbles down the other side. A failed orbit may count two hits to only one of the switches. It may count only one hit if the ball just makes it and rolls back down. The orbit shot is a good example of needing to know the previous switch state, the question then becomes, how many previous states to track?

Example: If an orbit is a multiball jackpot shot, how to handle when a second ball enters the left orbit before the first ball has triggered the right orbit switch? This means an orbit that can be fed from either direction is probably not a good way to score a jackpot. This is why a ramp shot is very easy to track a jackpot on - ramps have an apex and once your past the apex, any exit switch hit from the ramp is easily countable.

Another example of an advanced rule would be tracking the order of something - having five drop targets that give an extra bonus if hit in order of one to five, or five to one. This is a variable outside of standard switch state and it has to be managed outside of just target hits, as well as be reset on a ball drain, reset if a mode changes, or reset if the drop targets are reset.

Code complexity is increased by remembering the state of that variable and which targets have been hit or not between changing players.

The deeper rules become, the more variables, flags and timers that are needed to be tracked and managed, and the more difficult the code becomes to debug and maintain.

Some other examples of maintaining state:

  • If a target enables a kickback, will extra kick backs be added if it is already lit?
  • Knowing how many balls are in the ball trough before lighting the add-a-ball insert.

Rule Flow

For an example of a typical layout of rules and how the logic should flow, see the Rule Flow page.

Priority

Modes, display events and sounds all need to be prioritized relative to each other - for example, background displays or sounds are a lower priority than a switch hit or score display.

For example, if a high priority sound is playing, and the ball hits a switch that triggers a low priority sound effect, the control program can skip playing the lower priority sound, or play it at a lower volume. Or, if there is a display event for a pop bumper hit, it will be higher priority than the score display.

Light Shows

With modern CPU-controlled lamps, it is possible to use general illumination, flashers and playfield insert lamps to produce Light Shows during Attract mode to bring attention to the game from a passer-by, or while the game is active to convey information to the player.

For example, lighting lamps from the bottom of the playfield up to the top, then turn them off from the bottom up would be a distinct lamp show used during Attract mode. Below shows part of the attract mode for High Speed which uses multiple techniques.

High-speed-attract-mode.gif

Mission Pinball Framework supports the concept of Light scripts, which allow a maker to script what lamps are lit, for how long, and at a specific brightness to produce various effects.

Light Groups

Lights can be put into groups of similar lamps that allow for specific light effects. For example High Speed has the circular rev lamps, which lend themselves to a circular lamp effect, or the lamps in a row above them are well suited to a side-to-side effect.

Backbox

Most modern games have abandoned controlled lamps in the backbox to save on costs, but a garage maker has no such restrictions on creativity and can add various light effects to the backglass. Separating sections off to light separately is a common technique.

Backbox-light-show.gif

Modes

mini-modes - Drop target sets, etc

modes

special modes

Settings / Preferences

Auditing

Settings

Diagnostics

Scoring

Bonus Lanes

Basic scoring

Procedures

Ball Seek

Ball Save

Extra Ball

Kickback

Kickback

Skill Shot

Tilt

Game Start

Game End

Replay

Status Report - Holding down a flipper for a status report

Hardware-specific procedures

Drop Targets

Slingshots

Kicker cup

Divertors

VUKs - Vertical Up-Kickers

Languages

The programming language being used is going to be dictated primarily by the hardware control system chosen. Off the shelf systems such as P-ROC or Fast have a close relationship to PyProcGame, which is dedicated exclusively to the P-ROC, or the Mission Pinball Framework which supports both P-ROC and FAST and is a more higher level programming framework.

For more lower-level control, there is the libpinproc library for P-ROC boards, which allow binding into other languages and building of custom frameworks using things like SDL or SFML which provides access to OpenGL and other graphics APIs.

If using custom hardware, you likely have the means for writing control software without the help of this guide.

Pinball Frameworks

  • Mission Pinball: Currently supports both P-ROC and FAST controllers, written in Python
  • PyProcGame: Developed specifically for the P-ROC controllers, written in Python
  • libPinPROC: Lower level C library for P-ROC

Sound

Sound is a critical component of any pinball machine. EM games used bells and chimes to inform the player while modern games use digitized voice callouts and stereo music.

Some things to consider when deciding on how to incorporate sound in a game include:

  • Avoid playing sounds continuously over the top of one another. For example, having an explosion sound when a pop bumper is triggered - if the ball is getting a lot of pop bumper action and it triggers three pops in very fast succession, restarting the sound event on each trigger would sound like white noise. Thus, choose not to play the same sound effect unless N time has passed (say 3 seconds), or never play the same sound affect at the same time.
  • Too many sound effects playing over each over mutes the effect it should have on the player and can be confusing.
  • Timing of sound events should be kept short, as the longer the sound, the more likely it will overlap with another switch event trigger, leading to too many overlapping sound events or the white noise problem mentioned earlier.
  • Normalize the volume of all the sound effects to the same level to maintain a common volume level on the machine itself.

sound assignments

Music loops

Basic sounds

voice callouts