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


Golang vu.Eng类代码示例

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


在下文中一共展示了Eng类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: Create

// Create is the startup asset creation.
func (kc *kctag) Create(eng vu.Eng, s *vu.State) {
	top := eng.Root().NewPov()
	view := top.NewView()
	view.SetUI()
	kc.ui = view.Cam()
	kc.positions = kc.keyPositions()

	// Create the keyboard image.
	kc.kb = top.NewPov().SetScale(900, 255, 0).SetLocation(450, 100+85, 0)
	kc.kb.NewModel("uv").LoadMesh("icon").AddTex("keyboard")

	// Pressed key focus
	kc.focus = top.NewPov().SetScale(50, 50, 0)
	kc.focus.NewModel("uv").LoadMesh("icon").AddTex("particle")

	// Place the key symbols over the keys.
	font := "lucidiaSu18"
	fontColour := "lucidiaSu18Black"
	for code, key := range kc.positions { // map key is key code, map value is key struct
		if char := vu.Keysym(code); char > 0 {
			cx, cy := key.location()
			letter := top.NewPov().SetLocation(cx, cy, 0)
			model := letter.NewModel("uv")
			model.AddTex(fontColour).LoadFont(font).SetPhrase(string(char))
		}
	}

	// Have a lighter default background.
	eng.SetColor(0.45, 0.45, 0.45, 1)
	kc.resize(s.W, s.H)
}
开发者ID:toophy,项目名称:vu,代码行数:32,代码来源:kc.go

示例2: Create

// Create is the engine callback for initial asset creation.
func (sg *sgtag) Create(eng vu.Eng, s *vu.State) {
	sg.run = 10   // move so many cubes worth in one second.
	sg.spin = 270 // spin so many degrees in one second.
	sg.cam = eng.Root().NewCam()
	sg.cam.SetPerspective(60, float64(800)/float64(600), 0.1, 50)
	sg.cam.SetLocation(0, 0, 6)
	sg.tr = newTrooper(eng, 1)

	// initialize the reactions
	sg.reacts = map[int]inputHandler{
		vu.K_W:     sg.forward,
		vu.K_A:     sg.left,
		vu.K_S:     sg.back,
		vu.K_D:     sg.right,
		vu.K_Equal: sg.attach,
		vu.K_Minus: sg.detach,
		vu.K_0:     func(i *vu.Input, down int) { sg.setTr(down, 0) },
		vu.K_1:     func(i *vu.Input, down int) { sg.setTr(down, 1) },
		vu.K_2:     func(i *vu.Input, down int) { sg.setTr(down, 2) },
		vu.K_3:     func(i *vu.Input, down int) { sg.setTr(down, 3) },
		vu.K_4:     func(i *vu.Input, down int) { sg.setTr(down, 4) },
		vu.K_5:     func(i *vu.Input, down int) { sg.setTr(down, 5) },
		vu.K_P:     sg.stats,
	}
	eng.SetColor(0.1, 0.1, 0.1, 1.0)
}
开发者ID:skyview059,项目名称:vu,代码行数:27,代码来源:sg.go

示例3: Create

// Create is the engine callback for initial asset creation.
func (rl *rltag) Create(eng vu.Eng, s *vu.State) {
	rl.ww, rl.wh = 800, 600
	rl.floors = make(map[int]*floor)
	rl.setLevel(eng, vu.K_1)
	eng.SetColor(0.15, 0.15, 0.15, 1)
	return
}
开发者ID:skyview059,项目名称:vu,代码行数:8,代码来源:rl.go

示例4: Create

// Create is the startup asset creation.
func (sm *smtag) Create(eng vu.Eng, s *vu.State) {
	scene := eng.Root().NewPov()
	sm.cam = scene.NewCam()

	// need a light for shadows.
	sm.sun = scene.NewPov().SetLocation(0, 0, 0)
	sm.sun.NewLight().SetColour(0.8, 0.8, 0.8)

	// create a scene that will render a shadow map.
	sm.cam = scene.NewCam()
	sm.cam.SetLocation(0, 0, 10)
	sm.cam.SetPerspective(60, float64(s.W)/float64(s.H), 0.1, 50)

	// create a few objects that cast shadows.
	sm.cube = scene.NewPov().SetLocation(-1, -1, -4)
	sm.cube.NewModel("gouraud").LoadMesh("box").LoadMat("gray").CastShadow()
	sm.cube.Spin(45, 45, 0)
	sm.sphere = scene.NewPov().SetLocation(1, 1, -4)
	sm.sphere.NewModel("gouraud").LoadMesh("sphere").LoadMat("red").CastShadow()

	// create a ground block to show shadows.
	ground := scene.NewPov().SetLocation(0, 0, -20).SetScale(50, 50, 5)
	model := ground.NewModel("shadow").LoadMesh("box").LoadMat("gray").HasShadows()
	model.AddTex("tile")
}
开发者ID:skyview059,项目名称:vu,代码行数:26,代码来源:sm.go

示例5: Update

// 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)
	}
}
开发者ID:skyview059,项目名称:vu,代码行数:35,代码来源:bb.go

示例6: Create

// Create is the engine callback for initial asset creation.
func (rl *rltag) Create(eng vu.Eng, s *vu.State) {
	rl.run = 5    // move so many cubes worth in one second.
	rl.spin = 270 // spin so many degrees in one second.
	rl.ww, rl.wh = 800, 600
	rl.floors = make(map[int]*floor)
	rl.setLevel(eng, vu.K_1)
	eng.SetColor(0.15, 0.15, 0.15, 1)
	return
}
开发者ID:toophy,项目名称:vu,代码行数:10,代码来源:rl.go

示例7: Create

// Create is the engine callback for initial asset creation.
func (tm *tmtag) Create(eng vu.Eng, s *vu.State) {
	tm.ww, tm.wh = s.W, s.H
	view := eng.Root().NewView()
	tm.cam = view.Cam()
	tm.cam.SetOrthographic(0, float64(tm.ww), 0, float64(tm.wh), 0, 50)
	sun := eng.Root().NewPov().SetLocation(0, 5, 0)
	sun.NewLight().SetColour(0.4, 0.7, 0.9)

	// create the world surface.
	seed := int64(123)
	patchSize := 128
	tm.world = land.New(1, patchSize, seed)
	worldTile := tm.world.NewTile(1, 0, 0)
	textureRatio := 256.0 / 1024.0
	tm.surface = vu.NewSurface(patchSize, patchSize, 16, float32(textureRatio), 10)

	// create a separate surface for generating initial land textures.
	emap := land.New(1, patchSize, seed-1)
	etile := emap.NewTile(1, 0, 0)
	etopo := etile.Topo()

	// merge the land height and land texture information into a single surface.
	tm.evo = make([][]float64, patchSize)
	for x := range tm.evo {
		tm.evo[x] = make([]float64, patchSize)
	}
	numTextures := 3.0
	pts := tm.surface.Pts()
	topo := worldTile.Topo()
	for x := range topo {
		for y := range topo[x] {
			pts[x][y].Height = float32(topo[x][y])
			evolution := (etopo[x][y] + 1) * 0.5 * numTextures // (-1,1 map to 0-2), map to 0-3
			pts[x][y].Tindex = int(evolution)
			pts[x][y].Blend = float32(evolution) - float32(int(evolution))
			tm.evo[x][y] = evolution // remember for later.
		}
	}

	// Add a rendering component for the surface data.
	scale := 10.0
	tm.ground = eng.Root().NewPov().SetLocation(0, -300, -10).SetScale(scale, scale, 1)
	tm.gm = tm.ground.NewModel("land").AddTex("land")
	tm.gm.LoadMat("land").SetUniform("ratio", textureRatio)
	tm.gm.NewMesh("land")
	tm.surface.Update(tm.gm, 0, 0)

	// Add water planes.
	tm.ocean = eng.Root().NewPov()
	tm.ocean.SetLocation(256, 0, -10.5)
	tm.ocean.SetScale(float64(tm.ww), float64(tm.wh), 1)
	tm.ocean.NewModel("alpha").LoadMesh("plane").LoadMat("blue2")
	tm.coast = eng.Root().NewPov().SetLocation(256, 0, -10)
	tm.coast.SetScale(float64(tm.ww), float64(tm.wh), 1)
	tm.coast.NewModel("alpha").LoadMesh("plane").LoadMat("blue")
	return
}
开发者ID:toophy,项目名称:vu,代码行数:58,代码来源:tm.go

示例8: Create

// Create is the engine callback for initial asset creation.
func (cr *crtag) Create(eng vu.Eng, s *vu.State) {
	cr.run = 10   // move so many cubes worth in one second.
	cr.spin = 270 // spin so many degrees in one second.
	cr.top = eng.Root().NewPov()
	sun := cr.top.NewPov().SetLocation(0, 10, 10)
	sun.NewLight().SetColour(0.8, 0.8, 0.8)
	cr.view = cr.top.NewView()
	cr.cam = cr.view.Cam()
	cr.cam.SetPerspective(60, float64(800)/float64(600), 0.1, 500)
	cr.cam.SetLocation(0, 10, 25)

	// load the static slab.
	slab := cr.top.NewPov().SetScale(50, 50, 50).SetLocation(0, -25, 0)
	slab.NewBody(vu.NewBox(25, 25, 25))
	slab.SetSolid(0, 0.4)
	slab.NewModel("gouraud").LoadMesh("cube").LoadMat("floor")

	// create a single moving body.
	useBalls := true // Flip to use boxes instead of spheres.
	cr.striker = cr.top.NewPov()
	cr.striker.SetLocation(15, 15, 0) // -5, 15, -3
	if useBalls {
		cr.getBall(cr.striker)
	} else {
		cr.getBox(cr.striker)
		cr.striker.SetRotation(&lin.Q{X: 0.1825742, Y: 0.3651484, Z: 0.5477226, W: 0.7302967})
	}
	cr.striker.Model().SetColour(rand.Float64(), rand.Float64(), rand.Float64())

	// create a block of physics bodies.
	cubeSize := 3
	startX := -5 - cubeSize/2
	startY := -5
	startZ := -3 - cubeSize/2
	for k := 0; k < cubeSize; k++ {
		for i := 0; i < cubeSize; i++ {
			for j := 0; j < cubeSize; j++ {
				bod := cr.top.NewPov()
				lx := float64(2*i + startX)
				ly := float64(20 + 2*k + startY)
				lz := float64(2*j + startZ)
				bod.SetLocation(lx, ly, lz)
				if useBalls {
					cr.getBall(bod)
				} else {
					cr.getBox(bod)
				}
			}
		}
	}

	// set non default engine state.
	eng.SetColor(0.15, 0.15, 0.15, 1)
	rand.Seed(time.Now().UTC().UnixNano())
}
开发者ID:toophy,项目名称:vu,代码行数:56,代码来源:cr.go

示例9: Create

// create the game screens before the main action/update loop is started.
func (mp *bampf) Create(eng vu.Eng, s *vu.State) {
	rand.Seed(time.Now().UnixNano())
	mp.eng = eng
	mp.ani = &animator{}
	mp.setMute(mp.mute)
	mp.eventq = list.New()
	mp.createScreens(s.W, s.H)
	mp.state = mp.choosing
	mp.active = mp.launch
	mp.active.activate(screenActive)
	eng.SetColor(1, 1, 1, 1) // White as default background.
}
开发者ID:kissthink,项目名称:bampf,代码行数:13,代码来源:bampf.go

示例10: Create

// Create is the engine callback for initial asset creation.
func (fm *fmtag) Create(eng vu.Eng, s *vu.State) {
	fm.view = eng.Root().NewView()
	fm.view.SetUI()
	eng.SetColor(0.95, 0.95, 0.95, 1)

	// create the panel layout examples.
	fm.layouts = append(fm.layouts, fm.simpleLayout(eng, s.W, s.H))
	fm.layouts = append(fm.layouts, fm.spanLayout(eng, s.W, s.H))
	fm.layouts = append(fm.layouts, fm.grabLayout(eng))
	fm.layouts = append(fm.layouts, fm.largeLayout(eng, s.W, s.H))
	fm.layouts = append(fm.layouts, fm.doubleLayout(eng))
	fm.layouts[fm.example].setVisible(true)

	// set non default engine state.
	fm.resize(s.W, s.H)
}
开发者ID:toophy,项目名称:vu,代码行数:17,代码来源:fm.go

示例11: newHud

// newHud creates all the various parts of the heads up display.
func newHud(eng vu.Eng, sentryCount, wx, wy, ww, wh int) *hud {
	hd := &hud{}
	hd.root = eng.Root().NewPov()
	hd.view = hd.root.NewView()
	hd.view.SetUI()
	hd.cam = hd.view.Cam()
	hd.setSize(wx, wy, ww, wh)

	// create the HUD parts.
	hd.pl = newPlayer(hd.root, hd.w, hd.h)
	hd.xp = newXpbar(hd.root, hd.w, hd.h)
	hd.mm = newMinimap(eng.Root().NewPov(), sentryCount)
	hd.ce = hd.cloakingEffect(hd.root)
	hd.te = hd.teleportEffect(hd.root)
	hd.ee = hd.energyLossEffect(hd.root)
	hd.resize(hd.w, hd.h)
	return hd
}
开发者ID:kissthink,项目名称:bampf,代码行数:19,代码来源:hud.go

示例12: Create

// Create is the startup asset creation.
func (bb *bbtag) Create(eng vu.Eng, s *vu.State) {
	bb.run = 10   // move so many cubes worth in one second.
	bb.spin = 270 // spin so many degrees in one second.
	top := eng.Root().NewPov()
	view := top.NewView()
	bb.cam = view.Cam()
	bb.cam.SetLocation(0.5, 2, 2.5)
	sun := top.NewPov().SetLocation(0, 3, -3)
	sun.NewLight().SetColour(0.4, 0.7, 0.9)

	// Load the floor model.
	floor := top.NewPov()
	floor.NewModel("gouraud").LoadMesh("floor").LoadMat("floor")

	// Create a single image from multiple textures using a shader.
	c4 := top.NewPov().SetLocation(0.5, 2, -1).SetScale(0.25, 0.25, 0.25)
	model := c4.NewModel("spinball").LoadMesh("billboard")
	model.AddTex("core").AddTex("core").AddTex("halo").AddTex("halo")
	model.SetAlpha(0.4)

	// Try banner text with the 3D scene perspective camera.
	font := "lucidiaSu22"
	banner := top.NewPov().SetScale(0.1, 0.1, 0.1).SetLocation(-10, 3, -15)
	banner.NewModel("uv").AddTex(font + "White").LoadFont(font).SetPhrase("Floating Text")

	// Try billboard banner text with the 3D scene perspective camera.
	banner = top.NewPov().SetScale(0.025, 0.025, 0.025).SetLocation(-10, 2, -15)
	banner.NewModel("bb").AddTex(font + "White").LoadFont(font).SetPhrase("Billboard Text")

	// Banner text with an ortho overlay.
	v2D := eng.Root().NewPov()
	view2D := v2D.NewView()
	view2D.SetUI()
	bb.ui = view2D.Cam()

	// 2D static location.
	banner = v2D.NewPov().SetLocation(100, 100, 0)
	banner.NewModel("uv").AddTex(font + "White").LoadFont(font).SetPhrase("Overlay Text")

	// 3D world to 2D screen location.
	bb.screenText = v2D.NewPov()
	bb.screenText.NewModel("uv").AddTex(font + "White").LoadFont(font).SetPhrase("Screen Text")
	bb.resize(s.W, s.H)
}
开发者ID:toophy,项目名称:vu,代码行数:45,代码来源:bb.go

示例13: Create

// Create is the engine callback for initial asset creation.
func (ff *fftag) Create(eng vu.Eng, s *vu.State) {
	rand.Seed(time.Now().UTC().UnixNano())

	// create the overlay
	ff.top = eng.Root().NewPov()
	view := ff.top.NewView()
	view.SetUI()
	ff.cam = view.Cam()
	ff.mmap = ff.top.NewPov().SetScale(10, 10, 0)
	ff.mmap.SetLocation(30, 30, 0)

	// populate the map
	ff.msize = 69
	ff.plan = grid.New(grid.ROOMS_SKIRMISH)
	ff.plan.Generate(ff.msize, ff.msize)
	width, height := ff.plan.Size()
	for x := 0; x < width; x++ {
		for y := 0; y < height; y++ {
			if ff.plan.IsOpen(x, y) {
				block := ff.mmap.NewPov()
				block.SetLocation(float64(x), float64(y), 0)
				block.NewModel("uv").LoadMesh("icon").AddTex("wall")
				ff.spots = append(ff.spots, ff.id(x, y))
			}
		}
	}

	// populate chasers and a goal.
	numChasers := 30
	for cnt := 0; cnt < numChasers; cnt++ {
		chaser := ff.mmap.NewPov()
		chaser.NewModel("uv").LoadMesh("icon").AddTex("token")
		ff.chasers = append(ff.chasers, chaser)
	}
	ff.goal = ff.mmap.NewPov()
	ff.goal.NewModel("uv").LoadMesh("icon").AddTex("goal")
	ff.flow = grid.NewFlow(ff.plan) // flow field for the given plan.
	ff.resetLocations()

	// set non default engine state.
	eng.SetColor(0.15, 0.15, 0.15, 1)
	ff.resize(s.W, s.H)
}
开发者ID:toophy,项目名称:vu,代码行数:44,代码来源:ff.go

示例14: visualize

// Called once to create the visual parts of a panel.
func (lo *layout) visualize(eng vu.Eng) {
	lo.top = eng.Root().NewPov()
	lo.setVisible(false)
	lo.sects = make([]vu.Pov, len(lo.form.Sections()))
	lo.labels = make([]vu.Pov, len(lo.form.Sections()))
	for cnt, sect := range lo.form.Sections() {

		// place a box at the section location.
		lo.sects[cnt] = lo.top.NewPov()
		lo.sects[cnt].NewModel("uv").LoadMesh("icon").AddTex("cell")

		// place the cell name in the middle of the cell.
		lo.labels[cnt] = lo.top.NewPov()
		model := lo.labels[cnt].NewModel("uv").AddTex("lucidiaSu16Black")
		if sect.Label() == "" {
			model.LoadFont("lucidiaSu16").SetPhrase("-")
		} else {
			model.LoadFont("lucidiaSu16").SetPhrase(sect.Label())
		}
	}
}
开发者ID:toophy,项目名称:vu,代码行数:22,代码来源:fm.go

示例15: Update

// 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()
		}
	}
}
开发者ID:skyview059,项目名称:vu,代码行数:22,代码来源:tt.go


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