示例#1
0
文件: bb.go 项目: skyview059/vu
// Update is the regular engine callback.
func (bb *bbtag) Update(eng vu.Eng, in *vu.Input, s *vu.State) {
	run := 10.0   // move so many cubes worth in one second.
	spin := 270.0 // spin so many degrees in one second.
	if in.Resized {
		bb.resize(s.W, s.H)
	}
	dt := in.Dt
	for press, _ := range in.Down {
		switch press {
		case vu.K_W:
			bb.cam.Move(0, 0, dt*-run, bb.cam.Lookxz())
		case vu.K_S:
			bb.cam.Move(0, 0, dt*run, bb.cam.Lookxz())
		case vu.K_Q:
			bb.cam.Move(dt*-run, 0, 0, bb.cam.Lookxz())
		case vu.K_E:
			bb.cam.Move(dt*run, 0, 0, bb.cam.Lookxz())
		case vu.K_A:
			bb.cam.AdjustYaw(dt * spin)
		case vu.K_D:
			bb.cam.AdjustYaw(dt * -spin)
		case vu.K_T:
			eng.Shutdown()
		}
	}

	// Use screen coordinates from world coordinates.
	if sx, sy := bb.cam.Screen(5, 2, -15, s.W, s.H); sx == -1 {
		bb.screenText.SetVisible(false)
	} else {
		bb.screenText.SetVisible(true)
		bb.screenText.SetLocation(float64(sx), float64(sy), 0)
	}
}
示例#2
0
文件: tt.go 项目: skyview059/vu
// Update is the regular engine callback.
func (tt *totex) Update(eng vu.Eng, in *vu.Input, s *vu.State) {
	spin := 270.0 // spin so many degrees in one second.
	if in.Resized {
		tt.resize(s.W, s.H)
	}
	dt := in.Dt
	for press, _ := range in.Down {
		switch press {
		case vu.K_Q:
			tt.frame.Spin(0, dt*-spin, 0)
		case vu.K_E:
			tt.frame.Spin(0, dt*+spin, 0)
		case vu.K_A:
			tt.monkey.Spin(0, dt*-spin, 0)
		case vu.K_D:
			tt.monkey.Spin(0, dt*+spin, 0)
		case vu.K_T:
			eng.Shutdown()
		}
	}
}