Documentation
¶
Overview ¶
Package game holds the shared code for Termacade games.
Index ¶
- Constants
- Variables
- func Lerp(x, y, blend float64) float64
- func Lerp32(x, y, blend float32) float32
- type AIConfig
- type AIInputDesc
- type CreateFunc
- type Interface
- type SavedState
- type State
- func (s *State) AIClearButtons()
- func (s *State) AIForceButtons(buttons ...input.Button)
- func (s *State) AISpamButton(btn input.Button)
- func (s *State) ComputeWait(seconds float64) uint64
- func (s *State) DrawButtons(tb *sprites.Batch, x, y, z, scale float32)
- func (s *State) Fade(target, amount float32)
- func (s *State) FadeTo(target float32)
- func (s *State) FinalizeRecording()
- func (s *State) Load(saved *SavedState)
- func (s *State) Save() *SavedState
- type WeightedButton
Constants ¶
const ( // FrameRate is the number of frames per second at which the Termacade runs. FrameRate = 60 // FrameTime is the reciprocal of FrameRate. FrameTime = time.Second / FrameRate )
Variables ¶
var DrawButtons bool
DrawButtons causes buttons pressed in a game to be displayed on the screen.
Functions ¶
Types ¶
type AIConfig ¶
type AIConfig struct {
NumInput int
Press, Toggle []WeightedButton
PositionOverride []int
InputDesc []AIInputDesc
}
AIConfig is the configuration for the AI.
type AIInputDesc ¶
AIInputDesc describes an input to the AI.
type CreateFunc ¶
CreateFunc allocates structures for game-specific logic.
type Interface ¶
type Interface interface {
Type() arcade.Game
Rules() arcade.GameRules
HighScore() float64
Init(context.Context) error
Generate(context.Context, func(percent int)) error
StartGameplay(context.Context) error
Logic(context.Context) error
Render()
Cleanup(context.Context) error
RenderAttract(progress int, fadeIn, fadeOut bool)
StartPressed()
StartMusic()
InitAI() *AIConfig
AIInput() (input []float64, reward float64)
SaveState() interface{}
LoadState(interface{})
}
Interface is the set of methods implemented by each Termacade game.
type SavedState ¶
type SavedState struct {
// contains filtered or unexported fields
}
SavedState is a snapshot of State.
type State ¶
type State struct {
TickCount uint64
Score float64
Seed string
RNG *rng.RNG
Interface Interface
Input *input.Context
Camera gfx.Camera
CRT crt.CRT
Exit bool
Playback *arcade.Recording
PlaybackInput *input.Context
// contains filtered or unexported fields
}
State holds the state of a Termacade game.
func PlayRecording ¶
PlayRecording replays a recorded playthrough of a game.
func (*State) AIClearButtons ¶
func (s *State) AIClearButtons()
AIClearButtons returns control of the input to the AI.
func (*State) AIForceButtons ¶
AIForceButtons forces the AI to hold a set of buttons.
func (*State) AISpamButton ¶
AISpamButton forces the AI to press a button every other frame.
func (*State) ComputeWait ¶
ComputeWait determines the number of ticks to wait.
func (*State) DrawButtons ¶
DrawButtons displays the currently-held buttons on the screen.
func (*State) FinalizeRecording ¶
func (s *State) FinalizeRecording()
FinalizeRecording does bookkeeping to finish the game recording.
func (*State) Load ¶
func (s *State) Load(saved *SavedState)
Load replaces State with a recorded snapshot.
type WeightedButton ¶
WeightedButton is a button with a weight (1 is normal).