game

package
v0.0.0-...-881dcfe Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2024 License: MIT Imports: 31 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultKeyBindings = KeyBindings{
	ActionWalkUp:    []ebiten.Key{ebiten.KeyW, ebiten.KeyUp},
	ActionWalkDown:  []ebiten.Key{ebiten.KeyS, ebiten.KeyDown},
	ActionWalkLeft:  []ebiten.Key{ebiten.KeyA, ebiten.KeyLeft},
	ActionWalkRight: []ebiten.Key{ebiten.KeyD, ebiten.KeyRight},

	ActionFullScreen: []ebiten.Key{ebiten.KeyF11},
}

Functions

This section is empty.

Types

type Action

type Action uint
const (
	ActionWalkUp Action
	ActionWalkDown
	ActionWalkLeft
	ActionWalkRight

	ActionFullScreen
)

type DrawCall

type DrawCall struct {
	Y float64
	F func()
}

type EventType

type EventType uint
const (
	EventStartServer EventType
	EventConnectedToServer
	EventDisconnectedFromServer
)

type Game

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

func NewGame

func NewGame(
	ctx context.Context,
	cancel context.CancelFunc,
) *Game

func (*Game) Draw

func (g *Game) Draw(screen *ebiten.Image)

func (*Game) Init

func (g *Game) Init() error

func (*Game) Layout

func (g *Game) Layout(_, _ int) (screenWidth, screenHeight int)

func (*Game) Shutdown

func (g *Game) Shutdown()

func (*Game) Update

func (g *Game) Update() error

type KeyBindings

type KeyBindings map[Action][]ebiten.Key

func (KeyBindings) Clone

func (k KeyBindings) Clone() KeyBindings

func (KeyBindings) IsActionJustPressed

func (k KeyBindings) IsActionJustPressed(action Action) bool

func (KeyBindings) IsActionPressed

func (k KeyBindings) IsActionPressed(action Action) bool

type Player

type Player struct {
	Name       string
	Pos        space.Vec2F
	Dir        space.Vec2I
	Moving     bool
	Collider   *collider.Object
	TickOffset int
}

func NewPlayer

func NewPlayer(cw *collider.World) *Player

func (*Player) Draw

func (p *Player) Draw(screen, spriteSheet *ebiten.Image, ticks int) DrawCall

func (*Player) UpdatePosition

func (p *Player) UpdatePosition()

Jump to

Keyboard shortcuts

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