fighters

package
v0.3.11 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2021 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package fighters is a prototype of The Everlasting Fighters.

Index

Constants

View Source
const MaxSoundFrames = 120

Variables

View Source
var (
	FakeDrop    float64
	FakeLatency time.Duration
	FakeJitter  time.Duration
)

Network code testing variables.

Functions

This section is empty.

Types

type Character

type Character struct {
	Sprites []*sprites.Sprite
	States  []CharacterState
}

func (*Character) Render

func (c *Character) Render(ps *PlayerState, b *sprites.Batch, sx float32)

func (*Character) Update

func (c *Character) Update(s *State, ps *PlayerState, inputs InputFrame)

type CharacterState

type CharacterState struct {
	Sprite int
	Sound  *audio.Sound
	Update func(s *State, ps *PlayerState, inputs InputFrame)
}

type Game

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

func New

func New(ctx context.Context) (*Game, error)

func (*Game) Render

func (g *Game) Render(ctx context.Context) error

func (*Game) Resize

func (g *Game) Resize(ctx context.Context) error

func (*Game) Update

func (g *Game) Update(ctx context.Context, frameAdvance bool) error

type InputBuf

type InputBuf struct {
	StartFrame uint64
	Length     uint64
	FrameAdv   int64
	Packed     []byte
	Bits       uint8 // number of bits remaining in final byte of packed buffer
}

func (*InputBuf) Append

func (b *InputBuf) Append(prev *InputFrame, ictx *input.Context)

func (*InputBuf) AppendFrame

func (b *InputBuf) AppendFrame(prev, frame InputFrame)

func (*InputBuf) Decode

func (b *InputBuf) Decode(frames *InputFrames) error

func (*InputBuf) MarshalBinary

func (b *InputBuf) MarshalBinary() ([]byte, error)

func (*InputBuf) Skip

func (b *InputBuf) Skip(frames uint64) *InputBuf

func (*InputBuf) UnmarshalBinary

func (b *InputBuf) UnmarshalBinary(buf []byte) error

type InputFrame

type InputFrame [input.NumButtons]bool

InputFrame is an array of held buttons for a frame.

type InputFrames

type InputFrames []InputFrame

InputFrames is a slice of InputFrame. The index in the slice corresponds to the frame number.

func (InputFrames) Predict

func (f InputFrames) Predict(num uint64) InputFrame

Predict returns the predicted input for a specified frame number. If the frame is known, the actual input is returned. Otherwise, the last known input is returned.

type MatchState

type MatchState int
const (
	StateMatchmakingWait MatchState = iota
	StateMatchmakingConnecting
	StateMatchReady
	StateConnectionFailed
)

type PlayerState

type PlayerState struct {
	Char  *Character
	Pos   [2]float32
	Vel   [2]float32
	Flip  bool
	State int
	Count int
	Sound [MaxSoundFrames]*audio.Sound
}

func (*PlayerState) SetState

func (ps *PlayerState) SetState(i int)

type State

type State struct {
	Frame  uint64
	Player [2]PlayerState
}

func (*State) Render

func (s *State) Render(b *sprites.Batch, sx float32)

func (*State) Update

func (s *State) Update(p1, p2 InputFrame)

Jump to

Keyboard shortcuts

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