本文整理匯總了Golang中github.com/gazed/vu.Eng.Modelled方法的典型用法代碼示例。如果您正苦於以下問題:Golang Eng.Modelled方法的具體用法?Golang Eng.Modelled怎麽用?Golang Eng.Modelled使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/gazed/vu.Eng
的用法示例。
在下文中一共展示了Eng.Modelled方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Update
// Update is the regular engine callback.
func (rl *rltag) Update(eng vu.Eng, in *vu.Input, s *vu.State) {
run := 5.0 // move so many cubes worth in one second.
spin := 270.0 // spin so many degrees in one second.
if in.Resized {
rl.resize(s.W, s.H)
}
// pre-process user presses.
// reduce individual move amounts for multiple move requests.
dt := in.Dt
moveDelta := dt * 2
for press, _ := range in.Down {
switch press {
case vu.K_W, vu.K_S, vu.K_Q, vu.K_E:
moveDelta *= 0.5
}
}
// process user presses.
for press, down := range in.Down {
switch press {
case vu.K_W:
rl.flr.cam.Move(0, 0, moveDelta*-run, rl.flr.cam.Lookxz())
rl.arrow.SetLocation(rl.flr.cam.Location())
case vu.K_S:
rl.flr.cam.Move(0, 0, moveDelta*run, rl.flr.cam.Lookxz())
rl.arrow.SetLocation(rl.flr.cam.Location())
case vu.K_Q:
rl.flr.cam.Move(moveDelta*-run, 0, 0, rl.flr.cam.Lookxz())
rl.arrow.SetLocation(rl.flr.cam.Location())
case vu.K_E:
rl.flr.cam.Move(moveDelta*run, 0, 0, rl.flr.cam.Lookxz())
rl.arrow.SetLocation(rl.flr.cam.Location())
case vu.K_A:
rl.flr.cam.AdjustYaw(dt * spin)
rl.arrow.SetRotation(rl.flr.cam.Lookxz())
case vu.K_D:
rl.flr.cam.AdjustYaw(dt * -spin)
rl.arrow.SetRotation(rl.flr.cam.Lookxz())
case vu.K_1, vu.K_2, vu.K_3, vu.K_4, vu.K_5, vu.K_6, vu.K_7, vu.K_8, vu.K_9, vu.K_0:
if down == 1 {
rl.setLevel(eng, press)
}
}
}
// show some stats to see the effectiveness of culling.
allModels, allVerts := eng.Modelled()
renModels, renVerts := eng.Rendered()
modelStats := fmt.Sprintf("%d models culled to %d", allModels, renModels)
vertexStats := fmt.Sprintf("%d verticies culled to %d", allVerts, renVerts)
rl.flr.modelStats.SetPhrase(modelStats)
rl.flr.vertexStats.SetPhrase(vertexStats)
// http://stackoverflow.com/questions/87304/calculating-frames-per-second-in-a-game
t := eng.Usage()
rl.elapsed += t.Elapsed
rl.update += t.Update
rl.renders += t.Renders
if in.Ut%50 == 0 { // average over 50 updates.
fps := float64(rl.renders) / rl.elapsed.Seconds()
update := rl.update.Seconds() / 50.0 * 1000
timings := fmt.Sprintf("FPS %2.2f Update %3.2fms", fps, update)
rl.flr.times.SetPhrase(timings)
rl.renders = 0
rl.elapsed = 0
rl.update = 0
}
}