本文整理匯總了Golang中github.com/paked/engi.Entity類的典型用法代碼示例。如果您正苦於以下問題:Golang Entity類的具體用法?Golang Entity怎麽用?Golang Entity使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了Entity類的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Update
func (fs *FallingSystem) Update(entity *engi.Entity, dt float32) {
var space *engi.SpaceComponent
if !entity.Component(&space) {
return
}
space.Position.Y += 200 * dt
}
示例2: Update
func (c *ControlSystem) Update(entity *engi.Entity, dt float32) {
//Check scheme
// -Move entity based on that
var control *ControlComponent
var space *engi.SpaceComponent
if !entity.Component(&space) || !entity.Component(&control) {
return
}
up := false
down := false
if control.Scheme == "WASD" {
up = engi.Keys.Get(engi.W).Down()
down = engi.Keys.Get(engi.S).Down()
} else {
up = engi.Keys.Get(engi.ArrowUp).Down()
down = engi.Keys.Get(engi.ArrowDown).Down()
}
if up {
space.Position.Y -= 800 * dt
}
if down {
space.Position.Y += 800 * dt
}
}
示例3: Update
func (c *HideSystem) Update(e *engi.Entity, dt float32) {
var render *engi.RenderComponent
if !e.Component(&render) {
return
}
if rand.Int()%10 == 0 {
render.SetPriority(engi.Hidden)
} else {
render.SetPriority(engi.MiddleGround)
}
}
示例4: Update
func (c *ControlSystem) Update(entity *engi.Entity, dt float32) {
var a *engi.AnimationComponent
if !entity.Component(&a) {
return
}
if engi.Keys.Get(engi.ArrowRight).Down() {
a.SelectAnimationByAction(WalkAction)
} else if engi.Keys.Get(engi.Space).Down() {
a.SelectAnimationByAction(SkillAction)
} else {
a.SelectAnimationByAction(StopAction)
}
}
示例5: Update
func (c *ScaleSystem) Update(e *engi.Entity, dt float32) {
var render *engi.RenderComponent
if !e.Component(&render) {
return
}
var mod float32
if rand.Int()%2 == 0 {
mod = 0.1
} else {
mod = -0.1
}
if render.Scale.X+mod >= 15 || render.Scale.X+mod <= 1 {
mod *= -1
}
render.Scale.AddScalar(mod)
}