scenes

package
v1.13.0 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2019 License: GPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CollisionTypePlayer = 1 << (iota + 1)
	CollisionTypeEnemy
	CollisionTypeWall
)
View Source
const BoostDelay = 7 * time.Second
View Source
const LevelTitleDelay = 3 * time.Second
View Source
const MaxPlayers = 2

Variables

View Source
var (
	GameBounds   = pixel.R(-1920/2, -1080/2, 1920/2, 1080/2)
	PlayerColors = []color.Color{colornames.Gold, colornames.Limegreen}
)
View Source
var Players []ControlScheme

Functions

func DrawCanvas added in v1.11.0

func DrawCanvas(win *pixelgl.Window, canvas *pixelgl.Canvas)

DrawCanvas draws a canvas to the window, properly scaling and moving the canvas to fit within the window.

The aspect ratio of the canvas is maintained when scaled.

func Render

func Render(win *pixelgl.Window)

Render calls the render method of the currently active scene if it exists.

func TransitionTo

func TransitionTo(o Scene)

TransitionTo changes the currently active scene, destroying the previous scene if necessary.

Types

type AnyInputMethod added in v1.6.12

type AnyInputMethod struct {
	Methods []InputMethod
}

func (AnyInputMethod) GetInput added in v1.6.12

func (im AnyInputMethod) GetInput(win *pixelgl.Window) bool

func (AnyInputMethod) String added in v1.6.12

func (im AnyInputMethod) String() string

type ControlScheme

type ControlScheme struct {
	Thrust, Left, Right, Shoot, Boost InputMethod
}

func (ControlScheme) Controls

func (cs ControlScheme) Controls(win *pixelgl.Window) Controls

type ControllerInput

type ControllerInput interface {
	Controls(win *pixelgl.Window) Controls
}

type Controls

type Controls struct {
	Left, Right, Thrust, Boost, Shoot bool
}

type DestroyableScene

type DestroyableScene interface {
	Scene
	Destroy()
}

DestroyableScene represents a scene that must be explicitly disposed of.

type InputMethod

type InputMethod interface {
	GetInput(win *pixelgl.Window) bool
	String() string
}

func AnyInput added in v1.6.12

func AnyInput(methods ...InputMethod) InputMethod

type JoystickAxisInputMethod

type JoystickAxisInputMethod struct {
	Joystick pixelgl.Joystick
	Axis     int
	// Inverse makes GetInput return true when |axis|>threshold && axis < 0.
	Inverse   bool
	Threshold float64
	Alias     string
}

func (JoystickAxisInputMethod) GetInput

func (im JoystickAxisInputMethod) GetInput(win *pixelgl.Window) bool

func (JoystickAxisInputMethod) String

func (im JoystickAxisInputMethod) String() string

type JoystickButtonInputMethod

type JoystickButtonInputMethod struct {
	Joystick pixelgl.Joystick
	Button   int
	Alias    string
}

func (JoystickButtonInputMethod) GetInput

func (im JoystickButtonInputMethod) GetInput(win *pixelgl.Window) bool

func (JoystickButtonInputMethod) String

func (im JoystickButtonInputMethod) String() string

type JoystickControlSchemeFactory added in v1.6.12

type JoystickControlSchemeFactory func(pixelgl.Joystick) ControlScheme

type KeyboardInputMethod

type KeyboardInputMethod struct {
	Button pixelgl.Button
}

func (KeyboardInputMethod) GetInput

func (im KeyboardInputMethod) GetInput(win *pixelgl.Window) bool

func (KeyboardInputMethod) String

func (im KeyboardInputMethod) String() string

type Player

type Player struct {
	Ship           *levelShip
	TargetPosition cp.Vector
	LastBoost      time.Time
	Color          color.Color
	ControlScheme
}

type Scene

type Scene interface {
	// Render is called repeatedly as long as this Scene is the currently active scene (the value of current).
	Render(win *pixelgl.Window)
}

Scene represents a logical division of the game (like a slide in PowerPoint).

func Death

func Death(index int) Scene

func NewLevelScene added in v1.11.0

func NewLevelScene(index int) Scene

func NewMainscreenScene added in v1.11.0

func NewMainscreenScene() Scene

func NewTitleScene added in v1.11.0

func NewTitleScene(index int) Scene

func NewWin added in v1.11.0

func NewWin() Scene

Jump to

Keyboard shortcuts

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