joystick

package
v0.0.0-...-a8eda97 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2022 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Abs

func Abs(x int) int

Types

type Action

type Action int
const (
	DropBomb Action = iota
	FireBomb
)

type Dir

type Dir int

Dir represents a direction.

const (
	DirUp Dir = iota
	DirRight
	DirDown
	DirLeft
)

func (Dir) Oposite

func (d Dir) Oposite() Dir

func (Dir) String

func (d Dir) String() string

String returns a string representing the direction.

func (Dir) Vector

func (d Dir) Vector() (x, y int)

Vector returns a [-1, 1] value for each axis.

type Input

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

Input represents the current key states.

func NewInput

func NewInput() *Input

NewInput generates a new Input object.

func (*Input) Action

func (i *Input) Action() (Action, bool)

func (*Input) Dir

func (i *Input) Dir() (Dir, bool)

Dir returns a currently pressed direction. Dir returns false if no direction key is pressed.

func (*Input) Tap

func (i *Input) Tap() bool

func (*Input) Update

func (i *Input) Update()

Update updates the current input states.

type Joystick

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

Jump to

Keyboard shortcuts

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