snakebase

package
v0.0.0-...-fb1ba6c Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2019 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxOctreeVolData = 8
)
View Source
const WorldSize = 500
View Source
const WorldSizeY = 500

Variables

Functions

func BoxIntersectsSphere

func BoxIntersectsSphere(cube go4game.HyperRect, c go4game.Vector3D, r float64) bool

func CollCube2Sphere

func CollCube2Sphere(cc *Cube, sp *Sphere) bool

Types

type Apple

type Apple struct {
	GameObjBase
	Sphere
}

func NewApple

func NewApple(og ObjGroupI) *Apple

func (*Apple) ActByTime

func (o *Apple) ActByTime(w WorldI, t time.Time)

func (*Apple) ID

func (o *Apple) ID() int64

func (Apple) String

func (o Apple) String() string

func (*Apple) ToOctreeVolObj

func (o *Apple) ToOctreeVolObj() OctreeVolObjI

func (*Apple) Vol

func (o *Apple) Vol() *go4game.HyperRect

type CmdReceiver

type CmdReceiver interface {
	SendGoCmd(Cmd string, Args interface{}, Rsp chan<- interface{})
	Loop()
}

type Collider

type Collider interface {
	CollideTo(Collider) bool
	Center() go4game.Vector3D
	Vol() *go4game.HyperRect
}

type Cube

type Cube struct {
	go4game.HyperRect
}

func (*Cube) Center

func (c *Cube) Center() go4game.Vector3D

func (*Cube) CollideTo

func (c *Cube) CollideTo(d Collider) bool

func (*Cube) Vol

func (o *Cube) Vol() *go4game.HyperRect

type GameObjBase

type GameObjBase struct {
	GroupID int64
	Color   uint32
	// contains filtered or unexported fields
}

func MakeGameObjBase

func MakeGameObjBase(og ObjGroupI, color uint32) GameObjBase

type GameObjI

type GameObjI interface {
	ID() int64
	OctreeVolObjI
	ToOctreeVolObj() OctreeVolObjI
	ActByTime(w WorldI, t time.Time)
}

type InteractType

type InteractType int
const (
	NoInteract InteractType = iota
	InteractRemove
	InteractBlock
)

type NearInfo

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

type OGActor

type OGActor interface {
	FrameAction() go4game.Vector3D
}

type ObjGroupBase

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

func NewObjGroup

func NewObjGroup(w *World) *ObjGroupBase

func (*ObjGroupBase) AddGameObj

func (og *ObjGroupBase) AddGameObj(o GameObjI)

func (*ObjGroupBase) AddInitMembers

func (og *ObjGroupBase) AddInitMembers()

func (*ObjGroupBase) AddToOctreeVol

func (og *ObjGroupBase) AddToOctreeVol(ot *OctreeVol)

func (*ObjGroupBase) FrameActionResult

func (og *ObjGroupBase) FrameActionResult() interface{}

func (*ObjGroupBase) GameObjI

func (og *ObjGroupBase) GameObjI() map[int64]GameObjI

func (*ObjGroupBase) ID

func (og *ObjGroupBase) ID() int64

func (*ObjGroupBase) RemoveGameObj

func (og *ObjGroupBase) RemoveGameObj(id int64)

func (*ObjGroupBase) StartFrameAction

func (og *ObjGroupBase) StartFrameAction(world WorldI, ftime time.Time)

type ObjGroupI

type ObjGroupI interface {
	ID() int64
	AddGameObj(GameObjI)
	RemoveGameObj(id int64)
	StartFrameAction(w WorldI, ftime time.Time)
	FrameActionResult() interface{}
	AddInitMembers()
	GameObjI() map[int64]GameObjI
	AddToOctreeVol(ot *OctreeVol)
}

type OctreeVol

type OctreeVol struct {
	BoundCube *go4game.HyperRect
	Center    go4game.Vector3D
	DataList  []OctreeVolObjI
	Children  [8]*OctreeVol
}

func NewOctreeVol

func NewOctreeVol(cube *go4game.HyperRect) *OctreeVol

func (*OctreeVol) Insert

func (ot *OctreeVol) Insert(o OctreeVolObjI) bool

func (*OctreeVol) InsertChild

func (ot *OctreeVol) InsertChild(o OctreeVolObjI) bool

func (*OctreeVol) QueryByHyperRect

func (ot *OctreeVol) QueryByHyperRect(fn func(OctreeVolObjI) bool, hr *go4game.HyperRect) bool

func (*OctreeVol) Split

func (ot *OctreeVol) Split()

func (OctreeVol) String

func (ot OctreeVol) String() string

type OctreeVolObjI

type OctreeVolObjI interface {
	Vol() *go4game.HyperRect
}

type Plum

type Plum struct {
	GameObjBase
	MoveVector go4game.Vector3D
	Sphere
}

func NewPlum

func NewPlum(og ObjGroupI) *Plum

func (*Plum) ActByTime

func (o *Plum) ActByTime(w WorldI, t time.Time)

func (*Plum) ID

func (o *Plum) ID() int64

func (Plum) String

func (o Plum) String() string

func (*Plum) ToOctreeVolObj

func (o *Plum) ToOctreeVolObj() OctreeVolObjI

func (*Plum) Vol

func (o *Plum) Vol() *go4game.HyperRect

type Snake

type Snake struct {
	ObjGroupBase
	Color  uint32
	HeadID int64
}

func NewSnake

func NewSnake(w *World) *Snake

func (*Snake) AddGameObj

func (og *Snake) AddGameObj(o GameObjI)

func (*Snake) AddInitMembers

func (og *Snake) AddInitMembers()

func (*Snake) AddToOctreeVol

func (og *Snake) AddToOctreeVol(ot *OctreeVol)

func (*Snake) FrameActionResult

func (og *Snake) FrameActionResult() interface{}

func (*Snake) GameObjI

func (og *Snake) GameObjI() map[int64]GameObjI

func (*Snake) ID

func (og *Snake) ID() int64

func (*Snake) RemoveGameObj

func (og *Snake) RemoveGameObj(id int64)

func (*Snake) StartFrameAction

func (og *Snake) StartFrameAction(world WorldI, ftime time.Time)

type SnakeConfig

type SnakeConfig struct {
	WorldCube   *go4game.HyperRect
	WorldDiag   float64
	WorldCube2  *go4game.HyperRect // for octree
	WorldDiag2  float64
	FramePerSec float64
}

func (*SnakeConfig) Load

func (config *SnakeConfig) Load(filename string) bool

func (*SnakeConfig) Save

func (config *SnakeConfig) Save(filename string) bool

func (*SnakeConfig) SaveLoad

func (config *SnakeConfig) SaveLoad(filename string)

func (*SnakeConfig) Validate

func (config *SnakeConfig) Validate()

type SnakeHead

type SnakeHead struct {
	GameObjBase
	MoveVector go4game.Vector3D
	Sphere
}

func NewSnakeHead

func NewSnakeHead(og ObjGroupI) *SnakeHead

func (*SnakeHead) ActByTime

func (o *SnakeHead) ActByTime(w WorldI, t time.Time)

func (*SnakeHead) ID

func (o *SnakeHead) ID() int64

func (SnakeHead) String

func (o SnakeHead) String() string

func (*SnakeHead) ToOctreeVolObj

func (o *SnakeHead) ToOctreeVolObj() OctreeVolObjI

func (*SnakeHead) Vol

func (o *SnakeHead) Vol() *go4game.HyperRect

type SnakeService

type SnakeService struct {
	Worlds map[int64]WorldI
	// contains filtered or unexported fields
}

func NewService

func NewService() *SnakeService

func (*SnakeService) AddWorld

func (s *SnakeService) AddWorld(w WorldI)

func (*SnakeService) ID

func (s *SnakeService) ID() int64

func (*SnakeService) Loop

func (s *SnakeService) Loop()

func (*SnakeService) RemoveWorld

func (s *SnakeService) RemoveWorld(id int64)

func (*SnakeService) SendGoCmd

func (s *SnakeService) SendGoCmd(Cmd string, Args interface{}, Rsp chan<- interface{})

func (SnakeService) String

func (s SnakeService) String() string

type SnakeTail

type SnakeTail struct {
	GameObjBase
	Sphere
	// contains filtered or unexported fields
}

func NewSnakeTail

func NewSnakeTail(og ObjGroupI, pos go4game.Vector3D) *SnakeTail

func (*SnakeTail) ActByTime

func (o *SnakeTail) ActByTime(w WorldI, t time.Time)

func (*SnakeTail) ID

func (o *SnakeTail) ID() int64

func (SnakeTail) String

func (o SnakeTail) String() string

func (*SnakeTail) ToOctreeVolObj

func (o *SnakeTail) ToOctreeVolObj() OctreeVolObjI

func (*SnakeTail) Vol

func (o *SnakeTail) Vol() *go4game.HyperRect

type Sphere

type Sphere struct {
	Radius float64
	// contains filtered or unexported fields
}

func (*Sphere) Center

func (c *Sphere) Center() go4game.Vector3D

func (*Sphere) CollideTo

func (c *Sphere) CollideTo(d Collider) bool

func (*Sphere) Vol

func (o *Sphere) Vol() *go4game.HyperRect

type StageApples

type StageApples struct {
	ObjGroupBase
	Color int
}

func NewStageApples

func NewStageApples(w *World) *StageApples

func (*StageApples) AddGameObj

func (og *StageApples) AddGameObj(o GameObjI)

func (*StageApples) AddInitMembers

func (og *StageApples) AddInitMembers()

func (*StageApples) AddToOctreeVol

func (og *StageApples) AddToOctreeVol(ot *OctreeVol)

func (*StageApples) FrameActionResult

func (og *StageApples) FrameActionResult() interface{}

func (*StageApples) GameObjI

func (og *StageApples) GameObjI() map[int64]GameObjI

func (*StageApples) ID

func (og *StageApples) ID() int64

func (*StageApples) RemoveGameObj

func (og *StageApples) RemoveGameObj(id int64)

func (*StageApples) StartFrameAction

func (og *StageApples) StartFrameAction(world WorldI, ftime time.Time)

type StagePlums

type StagePlums struct {
	ObjGroupBase
	Color int
}

func NewStagePlums

func NewStagePlums(w *World) *StagePlums

func (*StagePlums) AddGameObj

func (og *StagePlums) AddGameObj(o GameObjI)

func (*StagePlums) AddInitMembers

func (og *StagePlums) AddInitMembers()

func (*StagePlums) AddToOctreeVol

func (og *StagePlums) AddToOctreeVol(ot *OctreeVol)

func (*StagePlums) FrameActionResult

func (og *StagePlums) FrameActionResult() interface{}

func (*StagePlums) GameObjI

func (og *StagePlums) GameObjI() map[int64]GameObjI

func (*StagePlums) ID

func (og *StagePlums) ID() int64

func (*StagePlums) RemoveGameObj

func (og *StagePlums) RemoveGameObj(id int64)

func (*StagePlums) StartFrameAction

func (og *StagePlums) StartFrameAction(world WorldI, ftime time.Time)

type StageWalls

type StageWalls struct {
	ObjGroupBase
	ExitPos go4game.Vector3D
	Color   int
}

func NewStageWalls

func NewStageWalls(w *World) *StageWalls

func (*StageWalls) AddGameObj

func (og *StageWalls) AddGameObj(o GameObjI)

func (*StageWalls) AddInitMembers

func (og *StageWalls) AddInitMembers()

func (*StageWalls) AddToOctreeVol

func (og *StageWalls) AddToOctreeVol(ot *OctreeVol)

func (*StageWalls) FrameActionResult

func (og *StageWalls) FrameActionResult() interface{}

func (*StageWalls) GameObjI

func (og *StageWalls) GameObjI() map[int64]GameObjI

func (*StageWalls) ID

func (og *StageWalls) ID() int64

func (*StageWalls) RemoveGameObj

func (og *StageWalls) RemoveGameObj(id int64)

func (*StageWalls) StartFrameAction

func (og *StageWalls) StartFrameAction(world WorldI, ftime time.Time)

type Wall

type Wall struct {
	GameObjBase
	Cube
}

func NewWall

func NewWall(og ObjGroupI) *Wall

func (*Wall) ActByTime

func (o *Wall) ActByTime(w WorldI, t time.Time)

func (*Wall) ID

func (o *Wall) ID() int64

func (Wall) String

func (o Wall) String() string

func (*Wall) ToOctreeVolObj

func (o *Wall) ToOctreeVolObj() OctreeVolObjI

func (*Wall) Vol

func (o *Wall) Vol() *go4game.HyperRect

type World

type World struct {
	ObjGroups map[int64]ObjGroupI
	// contains filtered or unexported fields
}

func NewWorld

func NewWorld(s *SnakeService) *World

func (*World) AddObjGroup

func (w *World) AddObjGroup(og ObjGroupI)

func (*World) CollideList

func (w *World) CollideList(o GameObjI) []GameObjI

func (*World) Do1Frame

func (w *World) Do1Frame(ftime time.Time) bool

func (*World) ID

func (w *World) ID() int64

func (*World) ListNearObj

func (w *World) ListNearObj(hr *go4game.HyperRect) []GameObjI

func (*World) Loop

func (w *World) Loop()

func (*World) MakeOctreeVol

func (w *World) MakeOctreeVol() *OctreeVol

func (*World) RemoveObjGroup

func (w *World) RemoveObjGroup(id int64)

func (*World) SendGoCmd

func (w *World) SendGoCmd(Cmd string, Args interface{}, Rsp chan<- interface{})

func (World) String

func (w World) String() string

type WorldI

type WorldI interface {
	CmdReceiver
	ID() int64
	AddObjGroup(ObjGroupI)
	RemoveObjGroup(id int64)
	CollideList(o GameObjI) []GameObjI
}

Jump to

Keyboard shortcuts

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