game

package
v0.0.0-...-e1c21c9 Latest Latest
Warning

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

Go to latest
Published: May 10, 2019 License: Zlib Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxScriptSize = 1024

	MaxSpriteSize    = 64 << 10
	MaxTransformSize = 64 << 10
	MaxTextSize      = 64 << 10
	MaxMeshSize      = 64 << 10

	MaxParticleSize = 1024
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AsyncHandler

type AsyncHandler chan bool

type DB

type DB struct {
	EntityM *engi.EntityManager
	Tables  []interface{}
}

type DebugDrawComp

type DebugDrawComp struct {
}

type FPS

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

func (*FPS) Pause

func (fps *FPS) Pause()

func (*FPS) Resume

func (fps *FPS) Resume()

func (*FPS) SetScale

func (fps *FPS) SetScale(factor float32)

func (*FPS) Smooth

func (fps *FPS) Smooth() float32

func (*FPS) Step

func (fps *FPS) Step() float32

type Game

type Game struct {
	Options
	FPS
	DB

	// scene manager
	SceneManager

	// system
	*gfx.RenderSystem
	*input.InputSystem
	*effect.ParticleSimulateSystem
	*ScriptSystem
	*anim.AnimationSystem
	// contains filtered or unexported fields
}
var G *Game

统一管理游戏各个子系统的创建和销毁的地方

func (*Game) Camera

func (g *Game) Camera() *gfx.Camera

func (*Game) Create

func (g *Game) Create(w, h float32, ratio float32)

init subsystem

func (*Game) Destroy

func (g *Game) Destroy()

destroy subsystem

func (*Game) Draw

func (g *Game) Draw(dt float32)

func (*Game) DrawProfile

func (g *Game) DrawProfile()

func (*Game) Init

func (g *Game) Init()

func (*Game) Input

func (g *Game) Input(dt float32)

func (*Game) OnCreate

func (g *Game) OnCreate(w, h float32, ratio float32)

/ window callback

func (*Game) OnDestroy

func (g *Game) OnDestroy()

func (*Game) OnFocusChanged

func (g *Game) OnFocusChanged(focused bool)

func (*Game) OnKeyEvent

func (g *Game) OnKeyEvent(key int, pressed bool)

/ input callback

func (*Game) OnLoop

func (g *Game) OnLoop()

func (*Game) OnPause

func (g *Game) OnPause()

func (*Game) OnPointEvent

func (g *Game) OnPointEvent(key int, pressed bool, x, y float32)

func (*Game) OnResize

func (g *Game) OnResize(w, h int32)

func (*Game) OnResume

func (g *Game) OnResume()

func (*Game) Update

func (g *Game) Update()

type Loader

type Loader interface {
	Load()
}

Loader

type LoaderState

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

type Options

type Options struct {
	W, H int
}

type Scene

type Scene interface {
	OnEnter(g *Game)
	Update(dt float32)
	OnExit()
}

Scene has lifecycle callback. OnEnter is called when the scene is shown. Update is called each frame. OnExit is called when the scene is hided.

type SceneManager

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

SceneManager manages scenes.

func (*SceneManager) Clear

func (sm *SceneManager) Clear()

func (*SceneManager) Load

func (*SceneManager) Load(sn Scene)

设计合理的异步加载方案:TODO

func (*SceneManager) Peek

func (sm *SceneManager) Peek() (sn Scene, ok bool)

func (*SceneManager) Pop

func (sm *SceneManager) Pop() (sn Scene, ok bool)

func (*SceneManager) Push

func (sm *SceneManager) Push(sn Scene)

func (*SceneManager) SetDefault

func (sm *SceneManager) SetDefault(sn Scene)

SetDefault sets the default Scene before the Game start. It's designed for internal usage. You should not use it.

func (*SceneManager) Setup

func (sm *SceneManager) Setup(g *Game)

func (*SceneManager) UnLoad

func (*SceneManager) UnLoad(sn Scene)

func (*SceneManager) Update

func (sm *SceneManager) Update(dt float32)

type Script

type Script interface {
	Init()

	Update(dt float32)

	Destroy()
}

type ScriptComp

type ScriptComp struct {
	engi.Entity
	Script
}

func (*ScriptComp) SetScript

func (sc *ScriptComp) SetScript(script Script)

type ScriptSystem

type ScriptSystem struct {
	*ScriptTable
}

func NewScriptSystem

func NewScriptSystem() *ScriptSystem

func (*ScriptSystem) RequireTable

func (ss *ScriptSystem) RequireTable(tables []interface{})

func (*ScriptSystem) Update

func (ss *ScriptSystem) Update(dt float32)

type ScriptTable

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

func NewScriptTable

func NewScriptTable(cap int) *ScriptTable

func (*ScriptTable) Alive

func (st *ScriptTable) Alive(entity engi.Entity) bool

func (*ScriptTable) Comp

func (st *ScriptTable) Comp(entity engi.Entity) (sc *ScriptComp)

func (*ScriptTable) Delete

func (st *ScriptTable) Delete(entity engi.Entity)

func (*ScriptTable) NewComp

func (st *ScriptTable) NewComp(entity engi.Entity, script Script) (sc *ScriptComp)

func (*ScriptTable) Size

func (st *ScriptTable) Size() (size, cap int)

type Table

type Table interface{}

type TagComp

type TagComp struct {
	engi.Entity
	Name, Label string
}

* 标记并分类游戏对象, 在 Tag (Name) 的基础上再加一个 Label,作为二级分类, 在游戏中,很多时候是需要这样的二级分类的。比如: enemy {bullet, ship}

http://bitsquid.blogspot.se/2015/06/allocation-adventures-1-datacomponent.html http://bitsquid.blogspot.com/2015/06/allocation-adventures-2-arrays-of-arrays.html

关于 string 比较的问题,还需要研究:https://stackoverflow.com/questions/20232976/how-does-go-do-string-comparison

关于 Tag 系统的设计,可以学下一下

type TagTable

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

TODO 如何高效的存储和查找tag数据?

func NewTagTable

func NewTagTable(cap int) *TagTable

func (*TagTable) Alive

func (tt *TagTable) Alive(entity engi.Entity) bool

func (*TagTable) Comp

func (tt *TagTable) Comp(entity engi.Entity) (tc *TagComp)

func (*TagTable) Delete

func (tt *TagTable) Delete(entity engi.Entity) (tc *TagComp)

func (*TagTable) DeleteTag

func (tt *TagTable) DeleteTag(entity engi.Entity)

删除所有属于该标签的元素..

func (*TagTable) Group

func (tt *TagTable) Group(tag string) []engi.Entity

这个效率非常低,因为Group一次要对所有的Entity做一次线性的 查找..

func (*TagTable) NewComp

func (tt *TagTable) NewComp(entity engi.Entity) (tc *TagComp)

func (*TagTable) Size

func (tt *TagTable) Size() (size, cap int)

type UnLoader

type UnLoader interface {
	Unload()
}

Jump to

Keyboard shortcuts

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