player

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2024 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Input

type Input struct {
	Up   bool
	Down bool
}

Input represents the input of the player.

type Local

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

Local represents a player that is controlled by the user.

func NewLocal

func NewLocal(name string, side geometry.Side, screenWidth, screenHeight, fieldBorderWidth float64) *Local

NewLocal creates a new player to play locally.

func (*Local) BouncerHeight

func (p *Local) BouncerHeight() float64

BouncerHeight returns the height of the bouncer.

func (*Local) BouncerWidth

func (p *Local) BouncerWidth() float64

BouncerWidth returns the width of the bouncer.

func (*Local) Bounds

func (p *Local) Bounds() geometry.Rect

Bounds returns the bounds of the player.

func (*Local) Name

func (p *Local) Name() string

Name returns the name of the player.

func (*Local) Position

func (p *Local) Position() geometry.Vector

Position returns the position of the player.

func (*Local) Reset

func (p *Local) Reset()

Reset resets the position of the player.

func (*Local) SetPosition

func (p *Local) SetPosition(y float64)

SetPosition sets the Y position of the player.

func (*Local) Side

func (p *Local) Side() geometry.Side

Side returns the side of the player.

func (*Local) Update

func (p *Local) Update(input Input)

Update updates the position of the player based on the input.

type Network

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

Network represents a player that is controlled by the network. It is used to represent the player on the other side of the network.

func NewNetwork

func NewNetwork(name string, side geometry.Side, screenWidth, screenHeight float64) *Network

NewNetwork creates a new player to play in a network game.

func (*Network) BouncerHeight

func (p *Network) BouncerHeight() float64

BouncerHeight returns the height of the bouncer.

func (*Network) BouncerWidth

func (p *Network) BouncerWidth() float64

BouncerWidth returns the width of the bouncer.

func (*Network) Bounds

func (p *Network) Bounds() geometry.Rect

Bounds returns the bounds of the player.

func (*Network) Name

func (p *Network) Name() string

Name returns the name of the player.

func (*Network) Position

func (p *Network) Position() geometry.Vector

Position returns the position of the player.

func (*Network) Reset

func (*Network) Reset()

Reset will panic because it is not implemented.

func (*Network) SetPosition

func (p *Network) SetPosition(y float64)

SetPosition sets the Y position of the player.

func (*Network) Side

func (p *Network) Side() geometry.Side

Side returns the side of the player.

func (*Network) Update

func (*Network) Update(_ Input)

Update will panic because it is not implemented.

type Player

type Player interface {
	BouncerHeight() float64
	BouncerWidth() float64
	Bounds() geometry.Rect
	Name() string
	Side() geometry.Side
	Position() geometry.Vector
	Reset()
	SetPosition(y float64)
	Update(input Input)
}

Player represents a player.

Jump to

Keyboard shortcuts

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