go4game

package module
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: 7 Imported by: 0

README

go4game

updated project https://github.com/kasworld/gowasm3dgame

game server framework using golang

web client screenshot

GameService : server.go : main service entry
    World : world.go : game world or zone, terrain
        Team : team.go : AI or user controlled object
            GameObject : gameobject.go : component of team
            ConnInfo : common.go : tcp connection to channel
                PacketStat : packet statistics
requirement for websocket, web client

for 3d web

  • threejs from threejs.org

  • ( included in www/js folder )

for websocket

execute

execute server

go run server/main.go -rundur 60

execute client

go run client/main.go -client 1000 -rundur 60 -connectTo localhost:6666

see server info and index page

http://localhost:8080/

exec web client or click from index page

http://localhost:8080/www/client3d.html
korean discription

http://kasw.blogspot.kr/2014/04/go4game.html

http://kasw.blogspot.kr/2014/04/go4game-go.html

http://kasw.blogspot.kr/2014/04/go4game.html

http://kasw.blogspot.kr/2014/05/go4game-ai.html

http://kasw.blogspot.kr/2014/05/go4game.html

http://kasw.blogspot.kr/2014/05/go4game_29.html

Documentation

Index

Constants

View Source
const (
	MaxOctreeData = 8
)

Variables

View Source
var IdGenCh chan int64
View Source
var V3DUnitX = Vector3D{1, 0, 0}
View Source
var V3DUnitY = Vector3D{0, 1, 0}
View Source
var V3DUnitZ = Vector3D{0, 0, 1}
View Source
var V3DZero = Vector3D{0, 0, 0}

Functions

func IntDurToStr

func IntDurToStr(count int64, dur time.Duration) string

Types

type ActionPoint

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

func NewActionPoint

func NewActionPoint(typecount int) *ActionPoint

func (*ActionPoint) Add

func (ap *ActionPoint) Add(val int)

func (*ActionPoint) CanUse

func (ap *ActionPoint) CanUse(value int) bool

func (*ActionPoint) Use

func (ap *ActionPoint) Use(apt ActionType, value int) bool

type ActionStat

type ActionStat struct {
	Total ActionStatElement
	Laps  []ActionStatElement
}

func NewActionStat

func NewActionStat() *ActionStat

func (*ActionStat) Add

func (a *ActionStat) Add(n int64)

func (*ActionStat) Inc

func (a *ActionStat) Inc()

func (*ActionStat) NewLap

func (a *ActionStat) NewLap()

func (ActionStat) String

func (a ActionStat) String() string

func (*ActionStat) UpdateLap

func (a *ActionStat) UpdateLap()

type ActionStatElement

type ActionStatElement struct {
	Count int64
	Time  time.Time
}

type ActionType

type ActionType int

type GoCmd

type GoCmd struct {
	Cmd  string
	Args interface{}
	Rsp  chan<- interface{}
}

type HyperRect

type HyperRect struct {
	Min, Max Vector3D
}

func NewHyperRect

func NewHyperRect(v1 Vector3D, v2 Vector3D) *HyperRect

make normalized hyperrect , if not need use HyperRect{Min: , Max:}

func NewHyperRectByCR

func NewHyperRectByCR(c Vector3D, r float64) *HyperRect

func (*HyperRect) Center

func (h *HyperRect) Center() Vector3D

func (*HyperRect) DiagLen

func (h *HyperRect) DiagLen() float64

func (*HyperRect) IMul

func (h *HyperRect) IMul(i float64) *HyperRect

func (*HyperRect) IsContact

func (h *HyperRect) IsContact(c Vector3D, r float64) bool

func (*HyperRect) IsIn

func (h1 *HyperRect) IsIn(h2 *HyperRect) bool

func (*HyperRect) IsOverlap

func (h1 *HyperRect) IsOverlap(h2 *HyperRect) bool

func (*HyperRect) MakeCubeBy8Driect

func (h *HyperRect) MakeCubeBy8Driect(center Vector3D, direct8 int) *HyperRect

func (*HyperRect) Move

func (h *HyperRect) Move(v Vector3D) *HyperRect

func (*HyperRect) RandVector

func (h *HyperRect) RandVector() Vector3D

func (*HyperRect) SizeVector

func (h *HyperRect) SizeVector() Vector3D

type IDList

type IDList []int64

func (IDList) FindIndex

func (s IDList) FindIndex(id int64) int

func (IDList) Len

func (s IDList) Len() int

func (IDList) Less

func (s IDList) Less(i, j int) bool

func (IDList) Swap

func (s IDList) Swap(i, j int)

type Octree

type Octree struct {
	BoundCube *HyperRect
	Center    Vector3D
	DataList  OctreeObjList
	Children  [8]*Octree
}

func NewOctree

func NewOctree(cube *HyperRect) *Octree

func (*Octree) Insert

func (ot *Octree) Insert(o OctreeObjI) bool

func (*Octree) QueryByHyperRect

func (ot *Octree) QueryByHyperRect(fn func(OctreeObjI) bool, hr *HyperRect) bool

func (*Octree) Split

func (ot *Octree) Split()

type OctreeObjI

type OctreeObjI interface {
	Pos() Vector3D
}

type OctreeObjList

type OctreeObjList []OctreeObjI

type Vector3D

type Vector3D [3]float64

func FromInt32Vector

func FromInt32Vector(s [3]int32) Vector3D

func RandVector

func RandVector(st, end Vector3D) Vector3D

func RandVector3D

func RandVector3D(st, end float64) Vector3D

func (Vector3D) Abs

func (p Vector3D) Abs() float64

func (Vector3D) Add

func (p Vector3D) Add(other Vector3D) Vector3D

func (Vector3D) Angle

func (p Vector3D) Angle(other Vector3D) float64

func (Vector3D) CalcAimAheadDur

func (srcpos Vector3D) CalcAimAheadDur(dstpos Vector3D, dstmv Vector3D, bulletspeed float64) float64

for aim ahead target with projectile return time dur

func (Vector3D) Cross

func (p Vector3D) Cross(other Vector3D) Vector3D

func (Vector3D) Dot

func (p Vector3D) Dot(other Vector3D) float64

func (Vector3D) Eq

func (p Vector3D) Eq(other Vector3D) bool
func (p Vector3D) Copy() Vector3D {
	return Vector3D{p[0], p[1], p[2]}
}

func (Vector3D) Idiv

func (p Vector3D) Idiv(other float64) Vector3D

func (Vector3D) Imul

func (p Vector3D) Imul(other float64) Vector3D

func (Vector3D) IsIn

func (p Vector3D) IsIn(hr *HyperRect) bool

func (Vector3D) IsZero

func (p Vector3D) IsZero() bool

func (Vector3D) LenTo

func (p Vector3D) LenTo(other Vector3D) float64

func (*Vector3D) MakeIn

func (p *Vector3D) MakeIn(hr *HyperRect) int

func (Vector3D) Mul

func (p Vector3D) Mul(other Vector3D) Vector3D

func (Vector3D) Ne

func (p Vector3D) Ne(other Vector3D) bool

func (Vector3D) Neg

func (p Vector3D) Neg() Vector3D

func (Vector3D) NewInt32Vector

func (v Vector3D) NewInt32Vector() [3]int32

for serialize

func (*Vector3D) Normalize

func (p *Vector3D) Normalize()

func (Vector3D) Normalized

func (p Vector3D) Normalized() Vector3D

func (Vector3D) NormalizedTo

func (p Vector3D) NormalizedTo(l float64) Vector3D

func (Vector3D) Project

func (p Vector3D) Project(other Vector3D) Vector3D

func (Vector3D) Reflect

func (p Vector3D) Reflect(normal Vector3D) Vector3D

reflect plane( == normal vector )

func (Vector3D) RotateAround

func (p Vector3D) RotateAround(axis Vector3D, theta float64) Vector3D

func (Vector3D) Sqd

func (p Vector3D) Sqd(q Vector3D) float64

func (Vector3D) String

func (v Vector3D) String() string

func (Vector3D) Sub

func (p Vector3D) Sub(other Vector3D) Vector3D

func (Vector3D) To8Direct

func (center Vector3D) To8Direct(v2 Vector3D) int

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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