game

package
v0.0.0-...-155ab08 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2022 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HIT_TYPE_TORSO uint8 = 0
	HIT_TYPE_HEAD  uint8 = 1
	HIT_TYPE_ARMS  uint8 = 2
	HIT_TYPE_LEGS  uint8 = 3
	HIT_TYPE_MELEE uint8 = 4

	DAMAGE_TYPE_FALL   uint8 = 0
	DAMAGE_TYPE_WEAPON uint8 = 1
)

Variables

View Source
var Config = map[string]string{
	"gamemode":   "creative",
	"serverName": "gospades default name",
	"maxPlayers": "64",
	"team1Name":  "Red",
	"team2Name":  "Blue",
}
View Source
var ErrPlayerExists = errors.New("player already exists")

Functions

func LoadConfigFromLua

func LoadConfigFromLua(gamemode string) error

func SetConfigVariable

func SetConfigVariable(l *lua.LState) int

SetConfigVariable is called from conf.lua as 'config(string string)` to override defaults

Types

type Player

type Player struct {
	Username                     string
	Position                     util.Vec3Float
	LastPosition                 util.Vec3Float
	Orientation                  util.Vec3Float
	ExistingPlayerPacketReceived bool
	IP                           string
	ID                           uint8
	Team                         uint8
	Weapon                       uint8
	Held                         uint8
	Kills                        uint32
	BlockColor                   util.Color
	Peer                         enet.Peer
	KeyState                     uint8
	WeaponState                  uint8
	Tool                         uint8 // 0-spade, 1-block, 2-gun, 3-grenade
	Health                       uint8
}

func NewPlayer

func NewPlayer(peer enet.Peer, username string, id uint8, ip string) Player

func (*Player) Hit

func (p *Player) Hit(dmg uint8)

func (*Player) IsFiringPrimary

func (p *Player) IsFiringPrimary() bool

func (*Player) IsFiringSecondary

func (p *Player) IsFiringSecondary() bool

func (*Player) IsHoldingCrouch

func (p *Player) IsHoldingCrouch() bool

func (*Player) IsHoldingDown

func (p *Player) IsHoldingDown() bool

func (*Player) IsHoldingJump

func (p *Player) IsHoldingJump() bool

func (*Player) IsHoldingLeft

func (p *Player) IsHoldingLeft() bool

func (*Player) IsHoldingRight

func (p *Player) IsHoldingRight() bool

func (*Player) IsHoldingSneak

func (p *Player) IsHoldingSneak() bool

func (*Player) IsHoldingSprint

func (p *Player) IsHoldingSprint() bool

func (*Player) IsHoldingUp

func (p *Player) IsHoldingUp() bool

type State

type State struct {
	Config            map[string]string
	Players           map[uint8]*Player
	CompressedMap     []byte
	CompressedMapSize []byte
}

func NewState

func NewState(c map[string]string) (State, error)

func (*State) AddPlayer

func (gs *State) AddPlayer(ev enet.Event) (*Player, error)

func (*State) GetPlayerByID

func (gs *State) GetPlayerByID(id uint8) (*Player, error)

func (*State) GetPlayerByIP

func (gs *State) GetPlayerByIP(ip string) (*Player, error)

func (*State) RemovePlayerByIP

func (gs *State) RemovePlayerByIP(ip string)

func (*State) UpdatePlayer

func (gs *State) UpdatePlayer(playerID uint8, name []byte, team uint8, weapon uint8, held uint8, kills []byte, color util.Color) error

func (*State) UpdatePlayerBlockColor

func (gs *State) UpdatePlayerBlockColor(playerID uint8, red uint8, green uint8, blue uint8) error

Jump to

Keyboard shortcuts

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