Exemple #1
0
// newCube's are often started with 1 corner, 2 edges, or 4 bottom side pieces.
func newCube(tr vu.Pov, x, y, z, cubeSize float64) *cube {
	c := &cube{}
	c.part = tr.NewPov()
	c.cells = []vu.Pov{}
	c.cx, c.cy, c.cz, c.csize = x, y, z, cubeSize
	c.ccnt, c.cmax = 0, 8
	c.mergec = func() { c.merge() }
	c.trashc = func() { c.trash() }
	c.addc = func() { c.addCell() }
	c.remc = func() { c.removeCell() }

	// calculate the cell center locations (unsorted)
	qs := c.csize * 0.25
	c.centers = csort{
		&lin.V3{X: x - qs, Y: y - qs, Z: z - qs},
		&lin.V3{X: x - qs, Y: y - qs, Z: z + qs},
		&lin.V3{X: x - qs, Y: y + qs, Z: z - qs},
		&lin.V3{X: x - qs, Y: y + qs, Z: z + qs},
		&lin.V3{X: x + qs, Y: y - qs, Z: z - qs},
		&lin.V3{X: x + qs, Y: y - qs, Z: z + qs},
		&lin.V3{X: x + qs, Y: y + qs, Z: z - qs},
		&lin.V3{X: x + qs, Y: y + qs, Z: z + qs},
	}
	return c
}
Exemple #2
0
// newPlayer sets the player hud location and creates the white background.
func newPlayer(root vu.Pov, screenWidth, screenHeight int) *player {
	pl := &player{}
	pl.cx, pl.cy = 100, 100
	pl.bg = root.NewPov().SetScale(110, 110, 1).SetLocation(pl.cx, pl.cy, 0)
	pl.bg.NewModel("uv").LoadMesh("icon").AddTex("hudbg")
	return pl
}
Exemple #3
0
// newMinimap initializes the minimap. It still needs to be populated.
func newMinimap(root vu.Pov, numTroops int) *minimap {
	mm := &minimap{}
	mm.radius = 120
	mm.scale = 5.0
	mm.cores = []vu.Pov{}
	mm.view = root.NewView()
	mm.view.SetUI()
	mm.view.SetCull(vu.NewRadiusCull(float64(mm.radius)))
	mm.cam = mm.view.Cam()
	mm.cam.SetTransform(vu.XZ_XY)

	// create the parent for all the visible minimap pieces.
	mm.part = root.NewPov().SetLocation(float64(mm.x), 0, float64(-mm.y))

	// add the white background.
	mm.bg = mm.part.NewPov().SetScale(110, 1, 110)
	mm.bg.NewModel("uv").LoadMesh("icon_xz").AddTex("hudbg")

	// create the sentinel position markers
	mm.spms = []vu.Pov{}
	for cnt := 0; cnt < numTroops; cnt++ {
		tpm := mm.part.NewPov().SetScale(mm.scale, mm.scale, mm.scale)
		tpm.NewModel("alpha").LoadMesh("square_xz").LoadMat("tred")
		mm.spms = append(mm.spms, tpm)
	}

	// create the player marker and center map marker.
	mm.cpm = mm.part.NewPov().SetScale(mm.scale, mm.scale, mm.scale)
	mm.cpm.NewModel("alpha").LoadMesh("square_xz").LoadMat("blue")
	mm.ppm = mm.part.NewPov().SetScale(mm.scale, mm.scale, mm.scale)
	mm.ppm.NewModel("alpha").LoadMesh("tri_xz").LoadMat("tblack")
	return mm
}
Exemple #4
0
func (rl *rltag) newText(parent vu.Pov, gap int) vu.Model {
	text := parent.NewPov().SetLocation(10, 0, float64(-rl.wh+40+gap*24))
	text.Spin(-90, 0, 0) // orient to the X-Z plane.
	m := text.NewModel("uv").AddTex("lucidiaSu16White").LoadFont("lucidiaSu16")
	m.SetPhrase(" ")
	return m
}
Exemple #5
0
// makePlayer: the player is the camera... the player-trooper is used by the hud
// to show player status and as such this trooper is part of the hud scene.
func (lvl *level) makePlayer(root vu.Pov, levelNum int) *trooper {
	player := newTrooper(root.NewPov(), levelNum)
	player.part.Spin(15, 0, 0)
	player.part.Spin(0, 15, 0)
	player.setScale(100)
	player.part.SetListener()
	return player
}
Exemple #6
0
// createCore makes the new core model.
// Create a core image using a single multi-texture shader.
func (cc *coreControl) createCore(root vu.Pov, fade float64) vu.Pov {
	core := root.NewPov().SetScale(0.25, 0.25, 0.25)
	model := core.NewModel("spinball").LoadMesh("billboard")
	model.AddTex("ele").AddTex("ele").AddTex("halo").AddTex("halo")
	model.SetAlpha(0.6)
	model.SetUniform("fd", fade)
	return core
}
Exemple #7
0
// energyLossEffect creates the model shown when the player gets hit
// by a sentinel.
func (hd *hud) energyLossEffect(root vu.Pov) vu.Pov {
	ee := root.NewPov()
	ee.SetVisible(false)
	m := ee.NewModel("uvra").LoadMesh("icon").AddTex("loss")
	m.SetAlpha(0.5)
	m.SetUniform("fd", 1000)
	m.SetUniform("spin", 2.0)
	return ee
}
Exemple #8
0
// teleportEffect creates the model shown when the user teleports.
func (hd *hud) teleportEffect(root vu.Pov) vu.Pov {
	te := root.NewPov()
	te.SetVisible(false)
	m := te.NewModel("uvra").LoadMesh("icon").AddTex("smoke")
	m.SetAlpha(0.5)
	m.SetUniform("spin", 10.0)
	m.SetUniform("fd", 1000)
	return te
}
Exemple #9
0
Fichier : rc.go Projet : toophy/vu
// makeSphere creates a sphere at the given x, y, z location and with
// the given r, g, b colour.
func (rc *rctag) makeSphere(parent vu.Pov, x, y, z float64, r, g, b float32) vu.Pov {
	sz := 0.5
	sp := parent.NewPov()
	sp.NewBody(vu.NewSphere(sz))
	sp.SetLocation(x, y, z)
	sp.SetScale(sz, sz, sz)
	model := sp.NewModel("solid").LoadMesh("sphere")
	model.SetUniform("kd", r, g, b)
	return sp
}
Exemple #10
0
// makeSentries creates some AI sentinels.
func (lvl *level) makeSentries(root vu.Pov, levelNum int) {
	sentinels := []*sentinel{}
	numSentinels := gameMuster[levelNum]
	for cnt := 0; cnt < numSentinels; cnt++ {
		sentry := newSentinel(root.NewPov(), levelNum, lvl.units, lvl.fade)
		sentry.setScale(0.25)
		sentinels = append(sentinels, sentry)
	}
	lvl.sentries = sentinels
}
Exemple #11
0
// newStartAnimation creates the start screen animation.
func newStartAnimation(mp *bampf, parent vu.Pov, screenWidth, screenHeight int) *startAnimation {
	sa := &startAnimation{}
	sa.parent = parent
	sa.scale = 200
	sa.hilite = parent.NewPov()
	sa.hilite.NewModel("alpha").LoadMesh("square").LoadMat("white")
	sa.hilite.SetVisible(false)
	sa.resize(screenWidth, screenHeight)
	sa.showLevel(0)
	return sa
}
Exemple #12
0
// label adds a banner to a button or updates the banner if there is
// an existing banner.
func (b *button) label(part vu.Pov, keyCode int) {
	if keysym := vu.Keysym(keyCode); keysym > 0 {
		texture := "lucidiaSu22Black"
		if b.banner == nil {
			b.banner = part.NewPov().SetLocation(float64(b.x), float64(b.y), 0)
			b.banner.NewModel("uv").AddTex(texture).LoadFont("lucidiaSu22")
		}
		if keyCode == 0 {
			keyCode = vu.K_Space
		}
		b.banner.Model().SetPhrase(string(keysym))
	}
}
Exemple #13
0
// newBlock creates a panel with no cubes.  The cubes are added later using
// panel.addCube().
func newBlock(part vu.Pov, x, y, z float64, level int) *block {
	b := &block{}
	b.part = part.NewPov()
	b.lvl = level
	b.cubes = []*cube{}
	b.cx, b.cy, b.cz = x, y, z
	b.ccnt, b.cmax = 0, (level-1)*(level-1)*8
	b.mergec = func() { b.merge() }
	b.trashc = func() { b.trash() }
	b.addc = func() { b.addCell() }
	b.remc = func() { b.removeCell() }
	return b
}
Exemple #14
0
// newElectron creates a new electron model.
func newElectron(root vu.Pov, band int, angle float64) *electron {
	ele := &electron{}
	ele.band = band
	x, y := ele.initialLocation(angle)
	ele.core = root.NewPov().SetLocation(x, y, 0)

	// rotating image.
	cimg := ele.core.NewPov().SetScale(0.25, 0.25, 0.25)
	model := cimg.NewModel("spinball").LoadMesh("billboard")
	model.AddTex("ele").AddTex("ele").AddTex("halo").AddTex("halo")
	model.SetAlpha(0.6)
	return ele
}
Exemple #15
0
// newPanel creates a panel with no cubes. The cubes are added later using
// panel.addCube().
func newPanel(part vu.Pov, x, y, z float64, level int) *panel {
	p := &panel{}
	p.part = part.NewPov()
	p.lvl = level
	p.cubes = []*cube{}
	p.cx, p.cy, p.cz = x, y, z
	p.ccnt, p.cmax = 0, (level-1)*(level-1)*8
	p.mergec = func() { p.merge() }
	p.trashc = func() { p.trash() }
	p.addc = func() { p.addCell() }
	p.remc = func() { p.removeCell() }
	return p
}
Exemple #16
0
// newSentinel creates a player enemy.
func newSentinel(part vu.Pov, level, units int, fade float64) *sentinel {
	s := &sentinel{}
	s.part = part
	s.units = float64(units)
	s.part.SetLocation(0, 0.5, 0)
	if level > 0 {
		s.center = s.part.NewPov().SetScale(0.125, 0.125, 0.125)
		m := s.center.NewModel("flata").LoadMesh("cube").LoadMat("tred")
		m.SetUniform("fd", fade)
	}
	s.model = part.NewPov()
	m := s.model.NewModel("flata").LoadMesh("cube").LoadMat("tblue")
	m.SetUniform("fd", fade)
	return s
}
Exemple #17
0
// newButton creates a button. Buttons are initialized with a size and repositioned later.
//   root   is the parent transform.
//   size   is both the width and height.
//   icon   is the (already loaded) texture image.
//   action is the action to perform when the button is pressed.
func newButton(root vu.Pov, size int, icon string, eventId int, eventData interface{}) *button {
	btn := &button{}
	btn.model = root.NewPov()
	btn.eventId = eventId
	btn.eventData = eventData
	btn.w, btn.h = size, size

	// create the button icon.
	btn.id = icon
	btn.icon = btn.model.NewPov().SetScale(float64(btn.w/2), float64(btn.h/2), 1)
	btn.icon.NewModel("uv").LoadMesh("icon").AddTex(icon).SetAlpha(0.5)

	// create a hilite that is only shown on mouse over.
	btn.hilite = btn.model.NewPov().SetScale(float64(btn.w/2.0), float64(btn.h/2.0), 1)
	btn.hilite.SetVisible(false)
	btn.hilite.NewModel("alpha").LoadMesh("square").LoadMat("tblue")
	return btn
}
Exemple #18
0
// buildFloorPlan creates the level layout.
func (lvl *level) buildFloorPlan(root vu.Pov, hd *hud, plan grid.Grid) {
	width, height := plan.Size()
	for x := 0; x < width; x++ {
		for y := 0; y < height; y++ {
			xc := float64(x * lvl.units)
			yc := float64(-y * lvl.units)
			band := plan.Band(x, y) / 3
			if x == width/2 && y == height/2 {
				lvl.gcx, lvl.gcy = x, y // remember the maze center location
				lvl.center = root.NewPov().SetLocation(xc, 0, yc)
				m := lvl.center.NewModel("uvra").LoadMesh("tile").AddTex("drop1")
				m.SetAlpha(0.7)
				m.SetUniform("spin", 1.0)
				m.SetUniform("fd", lvl.fade)
			} else if plan.IsOpen(x, y) {

				// the floor tiles.
				tileLabel := lvl.tileLabel(band)
				tile := root.NewPov().SetLocation(xc, 0, yc)
				m := tile.NewModel("uva").LoadMesh("tile").AddTex(tileLabel)
				m.SetAlpha(0.7)
				m.SetUniform("fd", lvl.fade)

				// remember the tile locations for drop spots inside the maze.
				lvl.cc.addDropLocation(x, y)
			} else {

				// draw flat on the y plane with the maze extending into the screen.
				wm := lvl.wallMeshLabel(band)
				wt := lvl.wallTextureLabel(band)
				wall := root.NewPov().SetLocation(xc, 0, yc)
				m := wall.NewModel("uva").LoadMesh(wm).AddTex(wt)
				m.SetUniform("fd", lvl.fade)
				lvl.walls = append(lvl.walls, wall)

				// add the wall to the minimap
				hd.addWall(xc, yc)
			}
		}
	}

	// add core drop locations around the outside of the maze.
	for x := -1; x < width+1; x++ {
		lvl.cc.addDropLocation(x, -1)
		lvl.cc.addDropLocation(x, height)
	}
	for y := 0; y < height; y++ {
		lvl.cc.addDropLocation(-1, y)
		lvl.cc.addDropLocation(width, y)
	}
}
Exemple #19
0
// cloakingEffect creates the model shown when the user cloaks.
func (hd *hud) cloakingEffect(root vu.Pov) vu.Pov {
	ce := root.NewPov()
	ce.SetVisible(false)
	ce.NewModel("uv").LoadMesh("icon").AddTex("cloakon").SetAlpha(0.5)
	return ce
}
Exemple #20
0
// chaser moves towards a goal.
func newChaser(parent vu.Pov) *chaser {
	c := &chaser{}
	c.pov = parent.NewPov()
	c.pov.NewModel("uv").LoadMesh("icon").AddTex("token")
	return c
}
Exemple #21
0
// newXpbar creates all three status bars.
func newXpbar(root vu.Pov, screenWidth, screenHeight int) *xpbar {
	xp := &xpbar{}
	xp.border = 5
	xp.linew = 2
	xp.setSize(screenWidth, screenHeight)

	// add the xp background and foreground bars.
	xp.bg = root.NewPov()
	xp.bg.NewModel("alpha").LoadMesh("square").LoadMat("tblack")
	xp.fg = root.NewPov()
	xp.fg.NewModel("uv").LoadMesh("icon").AddTex("xpgreen")

	// add the xp bar text.
	xp.hb = root.NewPov()
	m := xp.hb.NewModel("uv").AddTex("lucidiaSu22White").LoadFont("lucidiaSu22")
	xp.hbw = m.SetPhrase("0").PhraseWidth()

	// teleport energy background and foreground bars.
	xp.tbg = root.NewPov()
	xp.tbg.NewModel("alpha").LoadMesh("square").LoadMat("tblack")
	xp.tfg = root.NewPov()
	xp.tfg.NewModel("uv").LoadMesh("icon").AddTex("xpblue")

	// the teleport bar text.
	xp.tk = root.NewPov()
	m = xp.tk.NewModel("uv").AddTex("lucidiaSu18White").LoadFont("lucidiaSu18")
	xp.tkw = m.SetPhrase("0").PhraseWidth()

	// cloak energy background and foreground bars.
	xp.cbg = root.NewPov()
	xp.cbg.NewModel("alpha").LoadMesh("square").LoadMat("tblack")
	xp.cfg = root.NewPov()
	xp.cfg.NewModel("uv").LoadMesh("icon").AddTex("xpblue")

	// the cloak bar text.
	xp.ck = root.NewPov()
	m = xp.ck.NewModel("uv").AddTex("lucidiaSu18White").LoadFont("lucidiaSu18")
	xp.ckw = m.SetPhrase("0").PhraseWidth()
	xp.resize(screenWidth, screenHeight)
	return xp
}