spin

package module
v0.7.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 1, 2022 License: MIT Imports: 13 Imported by: 0

README

spin

The Super Pinball System.

Yes, that is a generic name, but it makes for a great package name. And it is the name of a great venue in DC.

I am now an owner of a Judge Dredd pinball machine.

Judge Dredd

It came with a color dot-matrix display, LED lighting, and even a secondary power supply. That means it is time to get back to doing some pinball development work. I am using the P-ROC to control the machine via USB. I've already blown one fuse by hooking it up wrong.

Plan

I would like to do the following:

  • Judge Dredd Remix: The Judge Dredd we all know and love but with some improvements and tweaks here and there.
  • Speed Run: A game that takes 45 minutes to play when done efficiently. A lot longer when not done efficiently. Probably a Mega Man theme.
  • Single Ball Challenge: One ball, simple progression of objectives, get as many points as possible. Dr. Mario themed.
  • PinGolf: Because everyone loves this. Maybe bring in some No Good Gofers? So appropriate since this is written in Go!
  • Tribute: Fan service to the great games out there. This may or may not be a good idea.

Status

A work in progress. Judge Dredd Remix is first.

Version alpha-v7 was for getting the chain modes playable on the actual machine. The next version will be for polishing up the base mode, adding multiball, drain shield, crime scenes, etc.

Demo

License

MIT

Documentation

Index

Constants

View Source
const (
	Font04B_03_7px = "04B-03-7px"
	Font09x5       = "Font09x5"
	Font09x6       = "Font09x6"
	Font09x7       = "Font09x7"
	Font14x9       = "Font14x9"
	Font14x8       = "Font14x8"
	Font14x10      = "Font14x10"
	Font18x10      = "Font18x10"
	Font18x11      = "Font18x11"
	Font18x12      = "Font18x12"

	FontPfArmaFive8                   = "FontPfArmaFive8"
	FontPfRondaSeven8                 = "FontPfRondaSeven8"
	FontPfRondaSevenBold8             = "FontPfRondaSevenBold8"
	FontPfTempestaFive8               = "FontPfTempestaFive8"
	FontPfTempestaFiveBold8           = "FontPfTempestaFiveBold8"
	FontPfTempestaFiveCompressed8     = "FontPfTempestaFiveCompressed8"
	FontPfTempestaFiveCompressedBold8 = "FontPfTempestaFiveCompressedBold8"
	FontPfTempestaFiveCondensed8      = "FontPfTempestaFiveCondensed8"
	FontPfTempestaFiveCondensedBold8  = "FontPfTempestaFiveCondensedBold8"
	FontPfTempestaFiveExtended8       = "FontPfTempestaFiveExtended8"
	FontPfTempestaFiveExtendedBold8   = "FontPfTempestaFiveExtendedBold8"
)
View Source
const (
	ScriptGroupMode = "GroupMode"
	ScriptGroupBall = "GroupBall"
)
View Source
const (
	Version = "alpha-v7"
	Date    = "1 Feb 2022"
)
View Source
const (
	DebugStackTrace = "StackTrace"
)
View Source
const (
	LayerPriority = "LayerPriority"
)
View Source
const (
	PriorityAudioModeCallout = 1
)

Variables

View Source
var (
	ColorBlack = color.RGBA{0x00, 0x00, 0x00, 0xff}
	ColorWhite = color.RGBA{0xff, 0xff, 0xff, 0xff}
)
View Source
var AssetDir = os.Getenv("SPIN_ASSET_DIR")

Functions

func CountdownLoop added in v0.6.0

func CountdownLoop(e *ScriptEnv, timer *int, tickMs int, end Event) bool

func Error

func Error(format string, a ...interface{})

func FormatAction added in v0.3.0

func FormatAction(a Action) string

func FormatEvent added in v0.3.0

func FormatEvent(e Event) string

func FormatScore

func FormatScore(format string, a ...interface{}) string

func Info added in v0.6.0

func Info(format string, a ...interface{})

func Log

func Log(format string, a ...interface{})

func RGBAToUint32 added in v0.5.0

func RGBAToUint32(c color.RGBA) uint32

func RegisterFonts added in v0.6.0

func RegisterFonts(eng *Engine)

func RegisterLoggingSystem

func RegisterLoggingSystem(eng *Engine)

func RegisterTrackerSystem added in v0.6.0

func RegisterTrackerSystem(eng *Engine)

func RenderFrameLoop added in v0.6.0

func RenderFrameLoop(e *ScriptEnv, fn func(*ScriptEnv)) bool

func ScoreHurryUpLoop added in v0.6.0

func ScoreHurryUpLoop(e *ScriptEnv, score *int, tickMs int, decScore int, endScore int) bool

func ScorePanel added in v0.6.0

func ScorePanel(e *ScriptEnv)

func ShotSequenceLoop added in v0.6.0

func ShotSequenceLoop(e *ScriptEnv, shot string, timeMs int, switches ...string)

func WaitForBallArrivalFunc added in v0.6.0

func WaitForBallArrivalFunc(e *ScriptEnv, sw string, timeMs int) func() bool

func WaitForBallArrivalLoop added in v0.6.0

func WaitForBallArrivalLoop(e *ScriptEnv, sw string, timeMs int) bool

func WaitForBallDepartureLoop added in v0.6.0

func WaitForBallDepartureLoop(e *ScriptEnv, sw string, timeMs int) bool

func Warn

func Warn(format string, a ...interface{})

func WatcherTimerLoop added in v0.6.0

func WatcherTimerLoop(e *ScriptEnv, timer *int, fn func(v int)) bool

Types

type Action

type Action interface {
	// contains filtered or unexported methods
}

type ActionHandler

type ActionHandler interface {
	HandleAction(Action)
}

type AddBall added in v0.6.0

type AddBall struct {
	N int
}

type AddPlayer

type AddPlayer struct{}

type AdvanceEvent added in v0.6.0

type AdvanceEvent struct {
	ID string
}

func (AdvanceEvent) Key added in v0.6.0

func (e AdvanceEvent) Key() interface{}

type AdvanceGame

type AdvanceGame struct{}

type AllLampsOff added in v0.7.0

type AllLampsOff struct{}

type AnchorX

type AnchorX int
const (
	AnchorLeft AnchorX = iota
	AnchorCenter
	AnchorRight
)

type AnchorY

type AnchorY int
const (
	AnchorTop AnchorY = iota
	AnchorMiddle
	AnchorBottom
)

type AutoPulse added in v0.4.0

type AutoPulse struct {
	ID         string
	SwitchAddr interface{}
	CoilAddr   interface{}
	Time       int // milliseconds
}

type AutoPulseOff added in v0.4.0

type AutoPulseOff struct {
	ID string
}

type AutoPulseOn added in v0.4.0

type AutoPulseOn struct {
	ID string
}

type AwardScore

type AwardScore struct {
	Val int
}

type BallAddedEvent added in v0.6.0

type BallAddedEvent struct {
	BallsInPlay int
}

func (BallAddedEvent) Key added in v0.6.0

func (e BallAddedEvent) Key() interface{}

type BallDrainEvent added in v0.5.0

type BallDrainEvent struct {
	BallsInPlay int
}

func (BallDrainEvent) Key added in v0.5.0

func (e BallDrainEvent) Key() interface{}

type BallHold added in v0.7.0

type BallHold struct {
	Switch string
	Coil   string
}

type BallWillDrainEvent added in v0.5.0

type BallWillDrainEvent struct{}

func (BallWillDrainEvent) Key added in v0.5.0

func (e BallWillDrainEvent) Key() interface{}

type Config added in v0.3.0

type Config struct {
	CoilTrough string

	SwitchDrain                 string
	SwitchEnterServiceButton    string
	SwitchExitServiceButton     string
	SwitchLeftFlipperButton     string
	SwitchNextServiceButton     string
	SwitchPreviousServiceButton string
	SwitchRightFlipperButton    string
	SwitchShooterLane           string
	SwitchStartButton           string
	SwitchTroughJam             string
	SwitchWillDrain             []string

	LampStartButton string

	GI []string

	NumBalls int
}

type Debug added in v0.4.0

type Debug struct {
	ID string
}

type Display

type Display interface {
	Clear(string)
	Renderer(string) (Renderer, *Graphics)
	Width() int
	Height() int
	At(int, int) color.Color
}

type DisplayOptions

type DisplayOptions struct {
	ID     string
	Width  int
	Height int
	Layers []string
}

type Done added in v0.5.0

type Done struct{}

func (Done) Key added in v0.5.0

func (e Done) Key() interface{}

type Driver added in v0.3.0

type Driver struct {
	ID   string
	Type DriverType
	Addr interface{}
}

type DriverOff added in v0.3.0

type DriverOff struct {
	ID string
}

type DriverOn added in v0.3.0

type DriverOn struct {
	ID string
}

type DriverPWM added in v0.3.0

type DriverPWM struct {
	ID  string
	On  int // milliseconds
	Off int // milliseconds
}

type DriverPulse added in v0.3.0

type DriverPulse struct {
	ID   string
	Time int // millseconds
}

type DriverType added in v0.3.0

type DriverType int
const (
	Coil DriverType = iota
	Flasher
	Lamp
	Magnet
	Motor
)

type EndOfBallEvent

type EndOfBallEvent struct {
	Player int
	Ball   int
}

func (EndOfBallEvent) Key

func (e EndOfBallEvent) Key() interface{}

type EndOfGameEvent

type EndOfGameEvent struct{}

func (EndOfGameEvent) Key

func (e EndOfGameEvent) Key() interface{}

type Engine

type Engine struct {
	Config  Config
	Options Options
	Actions map[string]Action
	Events  map[string]Event
	// contains filtered or unexported fields
}

func NewEngine

func NewEngine(config Config, options Options) *Engine

func (*Engine) Display added in v0.6.0

func (e *Engine) Display(id string) Display

func (*Engine) Do

func (e *Engine) Do(act Action)

func (*Engine) GetVars added in v0.6.0

func (e *Engine) GetVars(name string) (interface{}, bool)

func (*Engine) NewCoroutine added in v0.6.0

func (e *Engine) NewCoroutine(fn func(*ScriptEnv))

func (*Engine) Post

func (e *Engine) Post(evt Event)

func (*Engine) RegisterAction

func (e *Engine) RegisterAction(act Action)

func (*Engine) RegisterActionHandler

func (e *Engine) RegisterActionHandler(h ActionHandler)

func (*Engine) RegisterEvent

func (e *Engine) RegisterEvent(evt Event)

func (*Engine) RegisterEventHandler

func (e *Engine) RegisterEventHandler(h EventHandler)

func (*Engine) RegisterServer

func (e *Engine) RegisterServer(s Server)

func (*Engine) RegisterVars

func (e *Engine) RegisterVars(name string, vars interface{})

func (*Engine) Run

func (e *Engine) Run()

func (*Engine) Stop added in v0.6.0

func (e *Engine) Stop()

type Event

type Event interface {
	Key() interface{}
}

type EventHandler

type EventHandler interface {
	HandleEvent(Event)
}

type FadeOutMusic

type FadeOutMusic struct {
	Time int // milliseconds
}

type Flipper added in v0.4.0

type Flipper struct {
	ID            string
	SwitchAddr    interface{}
	PowerCoilAddr interface{}
	HoldCoilAddr  interface{}
	// contains filtered or unexported fields
}

type FlippersOff added in v0.4.0

type FlippersOff struct {
	FlipperIDs []string
}

type FlippersOn added in v0.4.0

type FlippersOn struct {
	FlipperIDs []string
}

type GameOverEvent added in v0.4.0

type GameOverEvent struct{}

func (GameOverEvent) Key added in v0.4.0

func (e GameOverEvent) Key() interface{}

type GameVars

type GameVars struct {
	BallActive   bool
	BallsInPlay  int
	BallsPerGame int
	Player       int
	Ball         int
	MaxPlayers   int
	NumPlayers   int
	ExtraBalls   int
	IsExtraBall  bool
}

func GetGameVars added in v0.5.0

func GetGameVars(store Store) *GameVars

type Graphics

type Graphics struct {
	X       int32
	Y       int32
	W       int32
	H       int32
	Color   uint32
	Font    string
	AnchorX AnchorX
	AnchorY AnchorY
}

type Message

type Message struct {
	ID string
}

func (Message) Key

func (e Message) Key() interface{}

type MusicFinishedEvent added in v0.5.0

type MusicFinishedEvent struct{}

func (MusicFinishedEvent) Key added in v0.5.0

func (e MusicFinishedEvent) Key() interface{}

type MusicVolume added in v0.4.0

type MusicVolume struct {
	Set int
	Add int
	Mul float64
}

type Options added in v0.4.0

type Options struct {
	RegisterEOS bool
}

func DefaultOptions added in v0.4.0

func DefaultOptions() Options

type PlayMusic

type PlayMusic struct {
	ID     string
	Vol    int
	Loops  int
	Notify bool
}

type PlayScript

type PlayScript struct {
	ID string
}

type PlaySound

type PlaySound struct {
	ID     string
	Vol    int
	Loop   bool
	Repeat int
	Notify bool
	Duck   float64
}

type PlaySpeech

type PlaySpeech struct {
	ID       string
	Vol      int
	Priority int
	Notify   bool
	Duck     float64
}

type PlayerAddedEvent added in v0.4.0

type PlayerAddedEvent struct {
	Player int
}

func (PlayerAddedEvent) Key added in v0.4.0

func (e PlayerAddedEvent) Key() interface{}

type PlayerVars added in v0.5.0

type PlayerVars struct {
	Score int
}

func GetPlayerVars added in v0.5.0

func GetPlayerVars(store Store) *PlayerVars

func GetPlayerVarsFor added in v0.5.0

func GetPlayerVarsFor(store Store, player int) *PlayerVars

type RegisterAutoPulse added in v0.4.0

type RegisterAutoPulse struct {
	ID         string
	SwitchAddr interface{}
	CoilAddr   interface{}
	Time       int // millseconds
}

type RegisterCoil added in v0.3.0

type RegisterCoil struct {
	ID   string
	Addr interface{}
}

type RegisterDisplay

type RegisterDisplay struct {
	ID      string
	Display Display
}

type RegisterFlasher added in v0.3.0

type RegisterFlasher struct {
	ID   string
	Addr interface{}
}

type RegisterFlipper added in v0.4.0

type RegisterFlipper struct {
	ID            string
	SwitchAddr    interface{}
	PowerCoilAddr interface{}
	HoldCoilAddr  interface{}
}

type RegisterFont

type RegisterFont struct {
	ID   string
	Path string
	Size int
}

type RegisterLamp added in v0.3.0

type RegisterLamp struct {
	ID   string
	Addr interface{}
}

type RegisterMagnet added in v0.3.0

type RegisterMagnet struct {
	ID   string
	Addr interface{}
}

type RegisterMotor added in v0.3.0

type RegisterMotor struct {
	ID   string
	Addr interface{}
}

type RegisterMusic

type RegisterMusic struct {
	ID   string
	Path string
}

type RegisterScript

type RegisterScript struct {
	ID     string
	Script ScriptFn
	Group  string
}

type RegisterSound

type RegisterSound struct {
	ID   string
	Path string
}

type RegisterSpeech

type RegisterSpeech struct {
	ID   string
	Path string
}

type RegisterSwitch added in v0.3.0

type RegisterSwitch struct {
	ID   string
	Addr interface{}
	NC   bool
}

type Renderer

type Renderer interface {
	Graphics() *Graphics
	Fill(color.RGBA)
	FillRect(*Graphics)
	Height() int32
	Print(*Graphics, string, ...interface{})
	Width() int32
	Clear()
}

type Resources

type Resources struct {
	Fonts    map[string]struct{}
	Switches map[string]*Switch
}

func GetResourceVars added in v0.6.0

func GetResourceVars(store Store) *Resources

type ScriptEnv added in v0.6.0

type ScriptEnv struct {
	Config Config
	// contains filtered or unexported fields
}

func (*ScriptEnv) Display added in v0.6.0

func (e *ScriptEnv) Display(id string) Display

func (*ScriptEnv) Do added in v0.6.0

func (e *ScriptEnv) Do(act Action)

func (*ScriptEnv) GetVars added in v0.6.0

func (e *ScriptEnv) GetVars(name string) (interface{}, bool)

func (*ScriptEnv) NewCoroutine added in v0.6.0

func (e *ScriptEnv) NewCoroutine(fn ScriptFn)

func (*ScriptEnv) Post added in v0.6.0

func (e *ScriptEnv) Post(evt Event)

func (*ScriptEnv) RegisterVars added in v0.6.0

func (e *ScriptEnv) RegisterVars(name string, vars interface{})

func (*ScriptEnv) Sleep added in v0.6.0

func (e *ScriptEnv) Sleep(ms int) bool

func (*ScriptEnv) WaitFor added in v0.6.0

func (e *ScriptEnv) WaitFor(events ...coroutine.Event) (coroutine.Event, bool)

func (*ScriptEnv) WaitForUntil added in v0.6.0

func (e *ScriptEnv) WaitForUntil(ms int, s ...coroutine.Event) (coroutine.Event, bool)

type ScriptFinishedEvent added in v0.5.0

type ScriptFinishedEvent struct {
	ID string
}

func (ScriptFinishedEvent) Key added in v0.5.0

func (e ScriptFinishedEvent) Key() interface{}

type ScriptFn added in v0.5.0

type ScriptFn func(*ScriptEnv)

type ScriptStartedEvent added in v0.7.0

type ScriptStartedEvent struct {
	ID string
}

func (ScriptStartedEvent) Key added in v0.7.0

func (e ScriptStartedEvent) Key() interface{}

type Sequencer added in v0.6.0

type Sequencer struct {
	// contains filtered or unexported fields
}

func NewSequencer added in v0.6.0

func NewSequencer(env *ScriptEnv) *Sequencer

func (*Sequencer) Defer added in v0.6.0

func (s *Sequencer) Defer(act Action)

func (*Sequencer) Do added in v0.6.0

func (s *Sequencer) Do(act Action)

func (*Sequencer) DoFunc added in v0.6.0

func (s *Sequencer) DoFunc(fn func())

func (*Sequencer) DoRun added in v0.6.0

func (s *Sequencer) DoRun(fn func() bool)

func (*Sequencer) DoScript added in v0.7.0

func (s *Sequencer) DoScript(fn func(*ScriptEnv))

func (*Sequencer) Loop added in v0.6.0

func (s *Sequencer) Loop()

func (*Sequencer) LoopN added in v0.6.0

func (s *Sequencer) LoopN(n int)

func (*Sequencer) Post added in v0.6.0

func (s *Sequencer) Post(evt Event)

func (*Sequencer) Run added in v0.6.0

func (s *Sequencer) Run() bool

func (*Sequencer) Sleep added in v0.6.0

func (s *Sequencer) Sleep(ms int)

func (*Sequencer) WaitFor added in v0.6.0

func (s *Sequencer) WaitFor(events ...coroutine.Event)

func (*Sequencer) WaitForUntil added in v0.6.0

func (s *Sequencer) WaitForUntil(ms int, events ...coroutine.Event)

type Server

type Server interface {
	Service()
}

type SetScore

type SetScore struct {
	Val int
}

type SetVar added in v0.5.0

type SetVar struct {
	Vars string
	ID   string
	Val  string
}

type ShotEvent added in v0.4.0

type ShotEvent struct {
	ID string
}

func (ShotEvent) Key added in v0.4.0

func (e ShotEvent) Key() interface{}

type SoundFinishedEvent added in v0.6.0

type SoundFinishedEvent struct {
	ID string
}

func (SoundFinishedEvent) Key added in v0.6.0

func (e SoundFinishedEvent) Key() interface{}

type SpeechFinishedEvent added in v0.5.0

type SpeechFinishedEvent struct {
	ID string
}

func (SpeechFinishedEvent) Key added in v0.5.0

func (e SpeechFinishedEvent) Key() interface{}

type StartOfBallEvent

type StartOfBallEvent struct {
	Player     int
	Ball       int
	ShootAgain bool
}

func (StartOfBallEvent) Key

func (e StartOfBallEvent) Key() interface{}

type StopAudio

type StopAudio struct {
}

type StopMusic

type StopMusic struct {
	ID  string
	Any bool
}

type StopScript

type StopScript struct {
	ID string
}

type StopScriptGroup added in v0.7.0

type StopScriptGroup struct {
	ID string
}

type StopSound added in v0.5.0

type StopSound struct {
	ID string
}

type StopSpeech

type StopSpeech struct {
	ID string
}

type Store

type Store interface {
	GetVars(string) (interface{}, bool)
	RegisterVars(string, interface{})
}

type Switch added in v0.3.0

type Switch struct {
	ID     string
	NC     bool
	Active bool
}

type SwitchEvent

type SwitchEvent struct {
	ID       string
	Released bool
}

func (SwitchEvent) Key

func (e SwitchEvent) Key() interface{}

type TimeoutEvent added in v0.6.0

type TimeoutEvent struct {
	ID string
}

func (TimeoutEvent) Key added in v0.6.0

func (e TimeoutEvent) Key() interface{}

Directories

Path Synopsis
cmd
mach
jd
jdx

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL