Documentation ¶
Index ¶
- Constants
- Variables
- func Connect(userid uint64, server string, options *ConnectOptions) (*net.TCPConn, error)
- func DPAD(b byte) string
- func Endian() binary.ByteOrder
- func GenUUID() uint64
- func MSG(b byte) string
- func Sprint64(i uint64) string
- func SprintByte(c byte) string
- func TYPE(t types.Type) string
- func Vec2Dir(v pixel.Vec) byte
- type ClientUpdate
- type Component
- type ConnectOptions
- type DIR
- type ExpBar
- type HealthBar
- type HealthReport
- type HealthStatus
- type Login
- type ManaBar
- type Message
- type Ping
- type Player
- func (e *Player) DealDamage(from uint64, amount float64) float64
- func (e Player) Health() float64
- func (p Player) ID() uint64
- func (p *Player) MoveTo(xy [2]float64)
- func (p Player) Pos() pixel.Vec
- func (e *Player) SetHealth(hp float64)
- func (p Player) Type() types.Type
- func (p Player) X() float64
- func (p Player) Y() float64
- type PlayerAction
- type PlayerLogoff
- type PlayerMessage
- type Pong
- type ServerUpdate
- type StatBar
- type StatBar64
- type StatusEffect
Constants ¶
View Source
const ( UP byte = 1 << 0 DOWN byte = 1 << 1 LEFT byte = 1 << 2 RIGHT byte = 1 << 3 UPLEFT byte = UP | LEFT UPRIGHT byte = UP | RIGHT DOWNLEFT byte = DOWN | LEFT DOWNRIGHT byte = DOWN | RIGHT ALLDIR byte = UP | DOWN | LEFT | RIGHT UPDOWN byte = UP | DOWN LEFTRIGHT byte = LEFT | RIGHT UPDOWNLEFT byte = UP | DOWN | LEFT UPDOWNRIGHT byte = UP | DOWN | RIGHT LEFTDOWNRIGHT byte = LEFT | DOWN | RIGHT LEFTUPRIGHT byte = LEFT | UP | RIGHT )
View Source
const MaxPacketSize = 1024
MaxPacketSize anything bigger gets booted, or if server sends over 1024 in one packet there will be a read error on the clients For multipart binary transfers we use http to make things easier
Variables ¶
View Source
var Debug = false
View Source
var ErrLength = errors.New("type length is wrong")
View Source
var ErrZero = errors.New("id is zero")
Functions ¶
func Sprint64 ¶
Sprint64 returns a binary representation of 64 bit unsigned integer, but in 8 chunks of 8 bits
func SprintByte ¶
SprintByte returns a binary representation of 8 bits
Types ¶
type ClientUpdate ¶
func (ClientUpdate) Type ¶
func (s ClientUpdate) Type() types.Type
type Component ¶
type Component interface { Type() types.Type Value() interface{} String() string // return short human readable form, Include "Component" or "Component " prefix }
Component type. Such as... Health Mana StatusEffects ArmorClass WeaponDamage
type ConnectOptions ¶
type ConnectOptions struct { }
type HealthReport ¶
type HealthReport struct {
M map[uint64]HealthStatus // current/max health
}
type HealthStatus ¶
type Player ¶
type Player struct { PID uint64 EntityType uint16 PosX float64 PosY float64 // StatBars []StatBar // StatBar64 []StatBar64 HP float64 MP float64 }
Player is a Typer, Positioner, Pos(), and a world.Being (MoveTo, ID, X, Y)
Weird entity names because methods should instead be used by users of this struct. Positions/Components arent guarded, and instead should be guarded by the World or Game
type PlayerAction ¶
func (PlayerAction) Pos ¶
func (p PlayerAction) Pos() [2]float64
func (PlayerAction) Type ¶
func (p PlayerAction) Type() types.Type
type PlayerLogoff ¶
type PlayerLogoff struct {
UID uint64
}
func (PlayerLogoff) Type ¶
func (p PlayerLogoff) Type() types.Type
func (p PlayerLogoff) Encode(b []byte) (n int, err error) { buf := new(bytes.Buffer) err = gob.NewEncoder(buf).Encode(p) if err != nil { log.Println("Encoding Ping:", err) return 0, err } n += copy(b[:], buf.Bytes()) return n, nil }
func (p *PlayerLogoff) Decode(b []byte) (err error) { if len(b) < 10 { return ErrLength } err = gob.NewDecoder(bytes.NewReader(b)).Decode(p) if err != nil && err != io.EOF { log.Println("Decoding:", err) return err } return nil }
type PlayerMessage ¶
func (PlayerMessage) Type ¶
func (p PlayerMessage) Type() types.Type
type ServerUpdate ¶
func (ServerUpdate) Type ¶
func (s ServerUpdate) Type() types.Type
type StatBar ¶
func (StatBar) CurrentMax ¶
type StatBar64 ¶
func (StatBar64) CurrentMax ¶
type StatusEffect ¶
func (StatusEffect) Type ¶
func (s StatusEffect) Type() types.Type
Directories ¶
Path | Synopsis |
---|---|
codec package for encoding/decoding messages over the wire this exists so that we use networking through easy-to-use interfaces, and that when this file changes
|
codec package for encoding/decoding messages over the wire this exists so that we use networking through easy-to-use interfaces, and that when this file changes |
Click to show internal directories.
Click to hide internal directories.