当前位置: 首页>>代码示例>>Golang>>正文


Golang Eng.Rendered方法代码示例

本文整理汇总了Golang中github.com/gazed/vu.Eng.Rendered方法的典型用法代码示例。如果您正苦于以下问题:Golang Eng.Rendered方法的具体用法?Golang Eng.Rendered怎么用?Golang Eng.Rendered使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/gazed/vu.Eng的用法示例。


在下文中一共展示了Eng.Rendered方法的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
	}
}
开发者ID:skyview059,项目名称:vu,代码行数:70,代码来源:rl.go


注:本文中的github.com/gazed/vu.Eng.Rendered方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。