game

package
v0.0.0-...-05212bf Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2022 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TickDuration = 50 * time.Millisecond
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Difficulty

type Difficulty int
const (
	DifficultyPeaceful Difficulty = iota
	DifficultyEasy
	DifficultyNormal
	DifficultyHard
)

func (Difficulty) String

func (i Difficulty) String() string

type Game

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

func New

func New(world world.World, opts ...Option) (*Game, error)

func (*Game) AddPlayer

func (g *Game) AddPlayer(p *Player)

func (*Game) AmountOfConnectedPlayers

func (g *Game) AmountOfConnectedPlayers() int

func (*Game) Disconnect

func (g *Game) Disconnect(p *Player)

func (*Game) DisconnectWithReason

func (g *Game) DisconnectWithReason(p *Player, reason chat.Chat)

func (*Game) Ready

func (g *Game) Ready() <-chan struct{}

func (*Game) Start

func (g *Game) Start(ctx context.Context)

Start will start the game by starting to process incoming messages. This will also start the tick loop. This method will not terminate until the given context is canceled.

func (*Game) WritePacket

func (g *Game) WritePacket(p *Player, pkg packet.Clientbound)

type Gamemode

type Gamemode int
const (
	GamemodeSurvival Gamemode = iota
	GamemodeCreative
	GamemodeAdventure
	GamemodeSpectator
)

func (Gamemode) String

func (i Gamemode) String() string

type Option

type Option func(*Game)

func WithLogger

func WithLogger(log zerolog.Logger) Option

type Player

type Player struct {
	sync.Mutex

	*entity.Player
	// contains filtered or unexported fields
}

func NewPlayer

func NewPlayer(uuid uuid.UUID, name string, conn *network.Conn) *Player

func (*Player) Chunk

func (p *Player) Chunk() voxel.V2

func (*Player) Disconnect

func (p *Player) Disconnect()

type Sentinel

type Sentinel string
const (
	// ErrPlayerNotExist indicates that the player that wanted to join does not exist and
	// needs to be created.
	ErrPlayerNotExist Sentinel = "player does not exist"
)

func (Sentinel) Error

func (s Sentinel) Error() string

Directories

Path Synopsis
Package block provides means for registering blocks and creating blocks from registered block descriptors.
Package block provides means for registering blocks and creating blocks from registered block descriptors.

Jump to

Keyboard shortcuts

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