Exemplo n.º 1
0
func (cpap *controlPointAttackProcess) Draw(id Gid, g *Game, side int) {
	base.EnableShader("circle")
	base.SetUniformF("circle", "edge", 0.9)

	// For people on the controlling side this will draw a circle around the area
	// that is being targeted by the control point.
	if cpap.Side == side && cpap.Timer >= cpap.LockTime {
		gl.Color4ub(200, 200, 200, 80)
		texture.Render(
			cpap.LockPos.X-50,
			cpap.LockPos.Y-50,
			2*50,
			2*50)
	}

	// This draws the projectile itself.
	if cpap.Timer >= cpap.FireTime {
		gl.Color4ub(255, 50, 50, 240)
		texture.Render(
			cpap.ProjPos.X-5,
			cpap.ProjPos.Y-5,
			2*5,
			2*5)
	}
	base.EnableShader("")
}
Exemplo n.º 2
0
// TODO: This function really needs to take not just the side, but the player
// that this is being drawn for.
func (p *placeMineCastProcess) Draw(gid game.Gid, g *game.Game, side int) {
	player, _ := g.Ents[p.PlayerGid].(*game.PlayerEnt)
	if player == nil {
		return
	}
	if side != player.Side() {
		return
	}
	ready := int(p.Stored[game.ColorBlue] / p.Cost)
	base.EnableShader("status_bar")
	if ready == 0 {
		gl.Color4ub(255, 0, 0, 255)
	} else {
		gl.Color4ub(0, 255, 0, 255)
	}
	var outer float32 = 0.2
	var increase float32 = 0.01
	frac := p.Stored[game.ColorBlue] / p.Cost
	base.SetUniformF("status_bar", "frac", float32(frac-float64(ready)))
	base.SetUniformF("status_bar", "inner", outer-increase*float32(ready+1))
	base.SetUniformF("status_bar", "outer", outer)
	base.SetUniformF("status_bar", "buffer", 0.01)
	texture.Render(player.Pos().X-100, player.Pos().Y-100, 200, 200)
	if ready > 0 {
		base.SetUniformF("status_bar", "frac", 1.0)
		base.SetUniformF("status_bar", "inner", outer-float32(ready)*increase)
		base.SetUniformF("status_bar", "outer", outer)
		texture.Render(player.Pos().X-100, player.Pos().Y-100, 200, 200)
	}
	base.EnableShader("")
}
Exemplo n.º 3
0
func (p *multiDrain) Draw(src, obs game.Gid, game *game.Game) {
	if src != obs {
		return
	}
	ent := game.Ents[src]
	if ent == nil {
		return
	}
	base.EnableShader("status_bar")
	frac := p.Stored
	ready := math.Floor(frac)
	if ready == 0 {
		gl.Color4ub(255, 0, 0, 255)
	} else {
		gl.Color4ub(0, 255, 0, 255)
	}
	outer := 0.2
	increase := 0.01
	base.SetUniformF("status_bar", "frac", float32(frac-ready))
	base.SetUniformF("status_bar", "inner", float32(outer-increase*(ready+1)))
	base.SetUniformF("status_bar", "outer", float32(outer))
	base.SetUniformF("status_bar", "buffer", 0.01)
	texture.Render(ent.Pos().X-100, ent.Pos().Y-100, 200, 200)
	if ready > 0 {
		base.SetUniformF("status_bar", "frac", 1.0)
		base.SetUniformF("status_bar", "inner", float32(outer-ready*increase))
		base.SetUniformF("status_bar", "outer", float32(outer))
		texture.Render(ent.Pos().X-100, ent.Pos().Y-100, 200, 200)
	}
	base.EnableShader("")
}
Exemplo n.º 4
0
func setColorForIndex(index int) {
	switch index {
	case 0:
		gl.Color4ub(255, 0, 0, 200)
	case 1:
		gl.Color4ub(0, 255, 0, 200)
	case 2:
		gl.Color4ub(0, 0, 255, 200)
	default:
		gl.Color4ub(255, 0, 255, 200)
	}
}
Exemplo n.º 5
0
func (fe fireExplosion) Draw(test bool) {
	base.EnableShader("circle")
	base.SetUniformF("circle", "edge", 0.7)
	if test {
		gl.Color4ub(200, 200, 200, gl.Ubyte(150*fe.Alpha()))
	} else {
		gl.Color4ub(255, 50, 10, gl.Ubyte(150*fe.Alpha()))
	}
	texture.Render(
		fe.Pos.X-fe.Size(),
		fe.Pos.Y-fe.Size(),
		2*fe.Size(),
		2*fe.Size())
	base.EnableShader("")
}
Exemplo n.º 6
0
func (p *PlayerEnt) Draw(game *Game) {
	var t *texture.Data
	var alpha gl.Ubyte
	if game.local.Side == p.Side() {
		alpha = gl.Ubyte(255.0 * (1.0 - p.Stats().Cloaking()/2))
	} else {
		alpha = gl.Ubyte(255.0 * (1.0 - p.Stats().Cloaking()))
	}
	gl.Color4ub(255, 255, 255, alpha)
	// if p.Id() == 1 {
	t = texture.LoadFromPath(filepath.Join(base.GetDataDir(), "ships/ship.png"))
	// } else if p.Id() == 2 {
	// 	t = texture.LoadFromPath(filepath.Join(base.GetDataDir(), "ships/ship3.png"))
	// } else {
	// 	t = texture.LoadFromPath(filepath.Join(base.GetDataDir(), "ships/ship2.png"))
	// }
	t.RenderAdvanced(
		p.Position.X-float64(t.Dx())/2,
		p.Position.Y-float64(t.Dy())/2,
		float64(t.Dx()),
		float64(t.Dy()),
		p.Angle_,
		false)

	for _, proc := range p.Processes {
		proc.Draw(p.Id(), game.local.Gid, game)
	}
	base.EnableShader("status_bar")
	base.SetUniformF("status_bar", "inner", 0.08)
	base.SetUniformF("status_bar", "outer", 0.09)
	base.SetUniformF("status_bar", "buffer", 0.01)

	base.SetUniformF("status_bar", "frac", 1.0)
	gl.Color4ub(125, 125, 125, alpha/2)
	texture.Render(p.Position.X-100, p.Position.Y-100, 200, 200)

	health_frac := float32(p.Stats().HealthCur() / p.Stats().HealthMax())
	if health_frac > 0.5 {
		color_frac := 1.0 - (health_frac-0.5)*2.0
		gl.Color4ub(gl.Ubyte(255.0*color_frac), 255, 0, alpha)
	} else {
		color_frac := health_frac * 2.0
		gl.Color4ub(255, gl.Ubyte(255.0*color_frac), 0, alpha)
	}
	base.SetUniformF("status_bar", "frac", health_frac)
	texture.Render(p.Position.X-100, p.Position.Y-100, 200, 200)
	base.EnableShader("")
}
Exemplo n.º 7
0
func (gw *GameWindow) Draw(region g2.Region, style g2.StyleStack) {
	defer base.StackCatcher()
	defer func() {
		// gl.Translated(gl.Double(gw.region.X), gl.Double(gw.region.Y), 0)
		gl.Disable(gl.TEXTURE_2D)
		gl.Color4ub(255, 255, 255, 255)
		gl.LineWidth(3)
		gl.Begin(gl.LINES)
		bx, by := gl.Int(region.X), gl.Int(region.Y)
		bdx, bdy := gl.Int(region.Dx), gl.Int(region.Dy)
		gl.Vertex2i(bx, by)
		gl.Vertex2i(bx, by+bdy)
		gl.Vertex2i(bx, by+bdy)
		gl.Vertex2i(bx+bdx, by+bdy)
		gl.Vertex2i(bx+bdx, by+bdy)
		gl.Vertex2i(bx+bdx, by)
		gl.Vertex2i(bx+bdx, by)
		gl.Vertex2i(bx, by)
		gl.End()
		gl.LineWidth(1)
	}()

	gw.Engine.Pause()
	game := gw.Engine.GetState().(*Game)
	// Note that since we do a READER lock on game.local we cannot do any writes
	// to local data while rendering.
	game.local.RLock()
	game.RenderLocal(region)
	game.local.RUnlock()
	gw.Engine.Unpause()
}
Exemplo n.º 8
0
func (tsm *ThunderSubMenu) Draw(region Region, style StyleStack) {
	gl.Disable(gl.TEXTURE_2D)
	gl.BlendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA)
	gl.Enable(gl.BLEND)
	base.EnableShader("marble")
	offset, ok := style.Get("offset").(linear.Vec2)
	if ok {
		base.SetUniformV2("marble", "offset", offset)
	} else {
		base.SetUniformV2("marble", "offset", linear.Vec2{})
	}
	gl.Color4ub(255, 255, 255, 255)
	gl.Begin(gl.QUADS)
	x := gl.Int(region.X)
	y := gl.Int(region.Y)
	dx := gl.Int(region.Dx)
	dy := gl.Int(region.Dy)
	gl.Vertex2i(x, y)
	gl.Vertex2i(x, y+dy)
	gl.Vertex2i(x+dx, y+dy)
	gl.Vertex2i(x+dx, y)
	gl.End()
	base.EnableShader("")
	for i, option := range tsm.Options {
		region.Dy = tsm.requests[option].Dy
		if i == tsm.selected {
			style.PushStyle(map[string]interface{}{"selected": true})
		} else {
			style.PushStyle(map[string]interface{}{"selected": false})
		}
		option.Draw(region, style)
		style.Pop()
		region.Y += tsm.requests[option].Dy
	}
}
Exemplo n.º 9
0
func (gw *GameWindow) Draw(region gui.Region, style gui.StyleStack) {
	defer base.StackCatcher()
	defer func() {
		// gl.Translated(gl.Double(gw.region.X), gl.Double(gw.region.Y), 0)
		gl.Disable(gl.TEXTURE_2D)
		gl.Color4ub(255, 255, 255, 255)
		gl.LineWidth(3)
		gl.Begin(gl.LINES)
		bx, by := gl.Int(region.X), gl.Int(region.Y)
		bdx, bdy := gl.Int(region.Dx), gl.Int(region.Dy)
		gl.Vertex2i(bx, by)
		gl.Vertex2i(bx, by+bdy)
		gl.Vertex2i(bx, by+bdy)
		gl.Vertex2i(bx+bdx, by+bdy)
		gl.Vertex2i(bx+bdx, by+bdy)
		gl.Vertex2i(bx+bdx, by)
		gl.Vertex2i(bx+bdx, by)
		gl.Vertex2i(bx, by)
		gl.End()
		gl.LineWidth(1)
	}()

	gw.Engine.Pause()
	game := gw.Engine.GetState().(*Game)
	game.RenderLocal(region, gw.Local)
	gw.Engine.Unpause()
}
Exemplo n.º 10
0
func drawScene() {
	gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)

	gl.MatrixMode(gl.MODELVIEW)
	gl.LoadIdentity()
	gl.Rotated(-90, 1, 0, 0)
	//gl.Rotated(90, 0, 0, 1)
	gl.Rotated(gl.Double(-viewAngles[2]), 1, 0, 0)
	gl.Rotated(gl.Double(-viewAngles[0]), 0, 1, 0)
	gl.Rotated(gl.Double(-viewAngles[1]), 0, 0, 1)
	gl.Translated(gl.Double(viewOrg[0]), gl.Double(viewOrg[1]), gl.Double(viewOrg[2]))

	var r, g, b gl.Ubyte

	for i, face := range model.Faces {
		r = gl.Ubyte(i) + 100
		g = gl.Ubyte(i>>1) + 100
		b = gl.Ubyte(i>>2) + 100

		if model.Triangle {
			gl.Begin(gl.TRIANGLES)
		} else {
			gl.Begin(gl.LINES)
		}

		gl.Color4ub(r, g, b, 0xff)
		for _, v := range face.Verts {
			gl.Vertex3d(gl.Double(v.Pos[0]), gl.Double(v.Pos[1]), gl.Double(v.Pos[2]))
		}

		gl.End()
	}
}
Exemplo n.º 11
0
func (wp *waypoint) RenderOnFloor() {
	if !wp.active {
		return
	}
	wp.drawn = true
	gl.Color4ub(200, 0, 0, 128)
	base.EnableShader("waypoint")
	base.SetUniformF("waypoint", "radius", float32(wp.Radius))

	t := float32(time.Now().UnixNano()%1e15) / 1.0e9
	base.SetUniformF("waypoint", "time", t)
	gl.Begin(gl.QUADS)
	gl.TexCoord2i(0, 1)
	gl.Vertex2i(int32(wp.X-wp.Radius), int32(wp.Y-wp.Radius))
	gl.TexCoord2i(0, 0)
	gl.Vertex2i(int32(wp.X-wp.Radius), int32(wp.Y+wp.Radius))
	gl.TexCoord2i(1, 0)
	gl.Vertex2i(int32(wp.X+wp.Radius), int32(wp.Y+wp.Radius))
	gl.TexCoord2i(1, 1)
	gl.Vertex2i(int32(wp.X+wp.Radius), int32(wp.Y-wp.Radius))
	gl.End()

	base.EnableShader("")

	// base.EnableShader("")
}
Exemplo n.º 12
0
func (ob *OptionBasic) DrawInfo(x, y, dx, dy int) {
	gl.Color4ub(255, 255, 255, 255)
	tx := x + (dx-ob.Large.Data().Dx())/2
	ty := y + dy - ob.Large.Data().Dy()
	ob.Large.Data().RenderNatural(tx, ty)
	d := base.GetDictionary(ob.Size)
	d.RenderParagraph(ob.Text, float64(x), float64(y+dy-ob.Large.Data().Dy())-d.MaxHeight(), 0, float64(dx), d.MaxHeight(), gui.Left, gui.Top)
}
Exemplo n.º 13
0
func (cp *ControlPoint) Draw(g *Game, side int) {
	base.EnableShader("circle")
	base.SetUniformF("circle", "edge", 0.95)
	gl.Color4ub(50, 50, 100, 150)
	texture.Render(
		cp.Position.X-cp.Stats().Size()*2,
		cp.Position.Y-cp.Stats().Size()*2,
		2*cp.Stats().Size()*2,
		2*cp.Stats().Size()*2)

	base.EnableShader("status_bar")
	base.SetUniformF("status_bar", "inner", 0.0)
	base.SetUniformF("status_bar", "outer", 0.5)
	base.SetUniformF("status_bar", "buffer", 0.01)
	base.SetUniformF("status_bar", "frac", 1.0)
	gl.Color4ub(50, 50, 50, 200)
	texture.Render(
		cp.Position.X-cp.Stats().Size(),
		cp.Position.Y-cp.Stats().Size(),
		2*cp.Stats().Size(),
		2*cp.Stats().Size())

	base.SetUniformF("status_bar", "frac", float32(cp.Control))
	if cp.Controlled {
		if side == cp.Controller {
			gl.Color4ub(0, 255, 0, 255)
		} else {
			gl.Color4ub(255, 0, 0, 255)
		}
	} else {
		gl.Color4ub(100, 100, 100, 255)
	}

	// The texture is flipped if this is being drawn for the controlling side.
	// This makes it look a little nicer when someone neutralizes a control point
	// because it makes the angle of the pie slice thingy continue going in the
	// same direction as it passes the neutralization point.
	texture.RenderAdvanced(
		cp.Position.X-cp.Stats().Size(),
		cp.Position.Y-cp.Stats().Size(),
		2*cp.Stats().Size(),
		2*cp.Stats().Size(),
		0,
		side == cp.Controller)
	base.EnableShader("")
}
Exemplo n.º 14
0
func (p *PosWidget) Draw(region Region, style StyleStack) {
	gl.Disable(gl.TEXTURE_2D)
	gl.Color4ub(0, 255, 0, 255)
	gl.Begin(gl.QUADS)
	x := gl.Int(region.X)
	y := gl.Int(region.Y)
	dx := gl.Int(base.GetDictionary("luxisr").StringWidth(p.text, float64(p.Size)))
	dy := gl.Int(p.Size)
	gl.Vertex2i(x, y)
	gl.Vertex2i(x, y+dy)
	gl.Vertex2i(x+dx, y+dy)
	gl.Vertex2i(x+dx, y)
	gl.End()
	base.Log().Printf("%v %v %v %v", x, y, dx, dy)
	gl.Color4ub(255, 0, 255, 255)
	base.GetDictionary("luxisr").RenderString(p.text, float64(region.X), float64(region.Y), 0, float64(p.Size), gui.Left)
}
Exemplo n.º 15
0
func (p *riftWalkProcess) Draw(gid game.Gid, g *game.Game, side int) {
	player, ok := g.Ents[p.PlayerGid].(*game.PlayerEnt)
	if !ok {
		return
	}
	if side != player.Side() {
		return
	}
	frac := p.Stored.Magnitude() / p.Threshold
	if frac < 1 {
		gl.Color4ub(255, 0, 0, 255)
	} else {
		gl.Color4ub(0, 255, 0, 255)
	}
	base.EnableShader("status_bar")
	var outer float32 = 0.2
	var increase float32 = 0.01
	if frac > 1 {
		frac = 1
	}
	base.SetUniformF("status_bar", "frac", float32(frac))
	base.SetUniformF("status_bar", "inner", outer-increase)
	base.SetUniformF("status_bar", "outer", outer)
	base.SetUniformF("status_bar", "buffer", 0.01)
	texture.Render(player.Pos().X-100, player.Pos().Y-100, 200, 200)
	base.EnableShader("")

	dist, radius := p.GetVals()
	dest := player.Pos().Add((linear.Vec2{dist, 0}).Rotate(player.Angle))
	gl.Disable(gl.TEXTURE_2D)
	gl.Color4d(1, 1, 1, 1)
	gl.Begin(gl.LINES)
	gl.Vertex2d(gl.Double(player.Pos().X), gl.Double(player.Pos().Y))
	gl.Vertex2d(gl.Double(dest.X), gl.Double(dest.Y))
	gl.End()
	n := 20
	gl.Begin(gl.LINES)
	for i := 0; i < n; i++ {
		v1 := dest.Add((linear.Vec2{radius, 0}).Rotate(float64(i) / float64(n) * 2 * math.Pi))
		v2 := dest.Add((linear.Vec2{radius, 0}).Rotate(float64(i+1) / float64(n) * 2 * math.Pi))
		gl.Vertex2d(gl.Double(v1.X), gl.Double(v1.Y))
		gl.Vertex2d(gl.Double(v2.X), gl.Double(v2.Y))
	}
	gl.End()
}
Exemplo n.º 16
0
func (co *colorOption) DrawInfo(x, y, dx, dy int) {
	gl.Disable(gl.TEXTURE_2D)
	gl.Color4ub(co.r, co.g, co.b, co.a)
	gl.Begin(gl.QUADS)
	gl.Vertex2i(int32(x), int32(y))
	gl.Vertex2i(int32(x), int32(y+dy))
	gl.Vertex2i(int32(x+dx), int32(y+dy))
	gl.Vertex2i(int32(x+dx), int32(y))
	gl.End()
}
Exemplo n.º 17
0
func (c *CreepEnt) Draw(g *Game) {
	base.EnableShader("status_bar")
	base.SetUniformF("status_bar", "inner", 0.01)
	base.SetUniformF("status_bar", "outer", 0.03)
	base.SetUniformF("status_bar", "buffer", 0.01)
	base.SetUniformF("status_bar", "frac", 1.0)
	if c.Side() == g.local.Side {
		gl.Color4ub(100, 255, 100, 255)
	} else {
		gl.Color4ub(255, 100, 100, 255)
	}
	texture.Render(c.Position.X-100, c.Position.Y-100, 200, 200)
	base.SetUniformF("status_bar", "inner", 0.04)
	base.SetUniformF("status_bar", "outer", 0.045)
	base.SetUniformF("status_bar", "buffer", 0.01)
	base.SetUniformF("status_bar", "frac", 1.0)
	texture.Render(c.Position.X-100, c.Position.Y-100, 200, 200)
	base.EnableShader("")
}
Exemplo n.º 18
0
func (g *Game) renderEdges() {
	// Draw edges between nodes
	for _, ent := range g.Ents {
		cp0, ok := ent.(*ControlPoint)
		if !ok {
			continue
		}
		for _, target := range cp0.Targets {
			cp1, ok := g.Ents[target].(*ControlPoint)
			if !ok {
				continue
			}
			ally := 0
			enemy := 0
			if cp0.Side() == g.local.Side {
				ally++
			} else if cp0.Side() == -1 {
				enemy++
			}
			if cp1.Side() == g.local.Side {
				ally++
			} else if cp1.Side() == -1 {
				enemy++
			}
			if ally == 2 {
				gl.Color4ub(0, 255, 0, 255)
			} else if enemy == 2 {
				gl.Color4ub(255, 0, 0, 255)
			} else if ally == 1 {
				gl.Color4ub(255, 255, 0, 255)
			} else if enemy == 1 {
				gl.Color4ub(255, 0, 0, 255)
			} else {
				gl.Color4ub(200, 200, 200, 255)
			}
			gl.Begin(gl.LINES)
			gl.Vertex2d(gl.Double(cp0.Pos().X), gl.Double(cp0.Pos().Y))
			gl.Vertex2d(gl.Double(cp1.Pos().X), gl.Double(cp1.Pos().Y))
			gl.End()
		}
	}
}
Exemplo n.º 19
0
func (p *asplosionProc) Draw(src, obs game.Gid, game *game.Game) {
	base.EnableShader("circle")
	base.SetUniformF("circle", "edge", 0.7)
	gl.Color4ub(255, 50, 10, gl.Ubyte(150))
	texture.Render(
		p.Pos.X-p.CurrentRadius,
		p.Pos.Y-p.CurrentRadius,
		2*p.CurrentRadius,
		2*p.CurrentRadius)
	base.EnableShader("")
}
Exemplo n.º 20
0
func (ep *EntityPlacer) Draw(region gui.Region) {
	ep.region = region
	gl.Color4ub(255, 255, 255, 255)
	ep.layout.Texture.Data().RenderNatural(region.X, region.Y)
	for _, button := range ep.buttons {
		button.RenderAt(ep.region.X, ep.region.Y)
	}
	d := base.GetDictionary(ep.layout.Roster.Points.Size)
	x_off := ep.layout.Roster.Points.X_off
	y_off := ep.layout.Roster.Points.Y_off
	for i, button := range ep.ent_buttons {
		cost := ep.roster[ep.roster_names[i]]
		x := float64(button.X + x_off)
		y := float64(button.Y + y_off)
		d.RenderString(fmt.Sprintf("%d", cost), x, y, 0, d.MaxHeight(), gui.Right)
	}
	gl.Color4ub(255, 255, 255, 255)
	var ent *Entity
	if !pointInsideRect(ep.mx, ep.my, region.X, region.Y, region.Dx, region.Dy) {
		ent = ep.game.new_ent
	}
	if ep.hovered != nil {
		ent = ep.hovered
	}
	if ent != nil {
		ent.Still.Data().RenderNatural(ep.layout.Face.X, ep.layout.Face.Y)
		ep.layout.Name.RenderString(ent.Name)
		ep.layout.Ap.RenderString(fmt.Sprintf("Ap:%d", ent.Stats.ApCur()))
		ep.layout.Hp.RenderString(fmt.Sprintf("Hp:%d", ent.Stats.HpCur()))
		ep.layout.Corpus.RenderString(fmt.Sprintf("Corpus:%d", ent.Stats.Corpus()))
		ep.layout.Ego.RenderString(fmt.Sprintf("Ego:%d", ent.Stats.Ego()))
	}
	if ep.show_points {
		d := base.GetDictionary(ep.layout.Points_remaining.Size)
		x := float64(ep.layout.Points_remaining.X)
		y := float64(ep.layout.Points_remaining.Y)
		d.RenderString(ep.layout.Points_remaining.String, x, y, 0, d.MaxHeight(), gui.Left)
		w := d.StringWidth(ep.layout.Points_remaining.String)
		d.RenderString(fmt.Sprintf("%d", ep.points), x+w, y, 0, d.MaxHeight(), gui.Right)
	}
}
Exemplo n.º 21
0
func (b *Box) Draw(region Region, style StyleStack) {
	b.Last = region
	gl.Enable(gl.BLEND)
	gl.BlendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA)
	gl.Disable(gl.TEXTURE_2D)
	if b.Hover {
		gl.Color4ub(gl.Ubyte(b.Color[0]), gl.Ubyte(b.Color[1]), gl.Ubyte(b.Color[2]), gl.Ubyte(b.Color[3]))
	} else {
		gl.Color4ub(gl.Ubyte(b.Color[0]), gl.Ubyte(b.Color[1]), gl.Ubyte(b.Color[2]), gl.Ubyte(b.Color[3])/2)
	}
	gl.Begin(gl.QUADS)
	x := gl.Int(region.X)
	y := gl.Int(region.Y)
	dx := gl.Int(region.Dx)
	dy := gl.Int(region.Dy)
	gl.Vertex2i(x, y)
	gl.Vertex2i(x+dx, y)
	gl.Vertex2i(x+dx, y+dy)
	gl.Vertex2i(x, y+dy)
	gl.End()
}
Exemplo n.º 22
0
func (mo *MapOption) Draw(hovered, selected, selectable bool, region gui.Region) {
	var s byte
	switch {
	case selected:
		s = 255
	case hovered && selectable:
		s = 205
	case selectable:
		s = 127
	default:
		s = 75
	}
	gl.Color4ub(s, s, s, 255)
	icon := mo.house_def.Icon.Data()
	if icon.Dx() == 0 {
		icon = mo.layout.Default_icon.Data()
	}
	icon.RenderNatural(region.X, region.Y)
	gl.Color4ub(0, 0, 0, 255)
	d := base.GetDictionary(15)
	d.RenderString(mo.house_def.Name, float64(region.X), float64(region.Y), 0, d.MaxHeight(), gui.Left)
}
Exemplo n.º 23
0
func (p *lightningBoltProc) Draw(src, obs game.Gid, game *game.Game) {
	if p.NumThinks < p.BuildThinks {
		return
	}
	base.EnableShader("lightning")
	base.SetUniformV2("lightning", "dir", p.Seg.Ray().Norm())
	base.SetUniformV2("lightning", "bolt_root", p.Seg.P.Add(p.Seg.Q).Scale(0.5))

	base.SetUniformF("lightning", "bolt_thickness", 1.1)
	gl.Disable(gl.TEXTURE_2D)
	displayWidth := p.Width * 10
	perp := p.Seg.Ray().Cross().Norm().Scale(displayWidth / 2)
	move := float32(p.NumThinks) / float32(60) / 10.0
	for i := 0; i < 3; i++ {
		base.SetUniformF("lightning", "rand_offset", float32(i)+move)
		if i == 2 {
			base.SetUniformF("lightning", "bolt_thickness", 1.3)
		}
		switch i {
		case 0:
			gl.Color4ub(255, 200, 200, 200)
		case 1:
			gl.Color4ub(255, 255, 200, 200)
		case 2:
			gl.Color4ub(255, 255, 230, 225)
		}
		gl.Begin(gl.QUADS)
		v := p.Seg.P.Add(perp)
		gl.Vertex2d(gl.Double(v.X), gl.Double(v.Y))
		v = p.Seg.Q.Add(perp)
		gl.Vertex2d(gl.Double(v.X), gl.Double(v.Y))
		v = p.Seg.Q.Sub(perp)
		gl.Vertex2d(gl.Double(v.X), gl.Double(v.Y))
		v = p.Seg.P.Sub(perp)
		gl.Vertex2d(gl.Double(v.X), gl.Double(v.Y))
		gl.End()
	}
	base.EnableShader("")
}
Exemplo n.º 24
0
func (p *burstProcess) Draw(player_id int, g *game.Game) {
	player := g.GetEnt(player_id).(*game.Player)
	base.EnableShader("circle")
	prog := p.Remaining_initial.Magnitude() / p.Initial.Magnitude()
	base.SetUniformF("circle", "progress", 1-float32(prog))
	gl.Color4ub(255, 255, 255, 255)
	radius := 40.0
	texture.Render(
		player.X-radius,
		player.Y-radius,
		2*radius,
		2*radius)
	base.EnableShader("")
}
Exemplo n.º 25
0
func (f *Furniture) Render(pos mathgl.Vec2, width float32) {
	var rgba [4]float64
	gl.GetDoublev(gl.CURRENT_COLOR, &rgba[0])
	gl.PushAttrib(gl.CURRENT_BIT)
	if !f.Blocks_los || !f.alpha_enabled {
		f.alpha = 1
	}
	gl.Color4ub(byte(255*rgba[0]), byte(255*rgba[1]), byte(255*rgba[2]), byte(255*rgba[3]*f.alpha))
	orientation := f.Orientations[f.Rotation]
	dy := width * float32(orientation.Texture.Data().Dy()) / float32(orientation.Texture.Data().Dx())
	// orientation.Texture.Data().Render(float64(pos.X), float64(pos.Y), float64(width), float64(dy))
	orientation.Texture.Data().RenderAdvanced(float64(pos.X), float64(pos.Y), float64(width), float64(dy), 0, !f.Flip)
	gl.PopAttrib()
}
Exemplo n.º 26
0
func (f *lightning) Draw(ent game.Ent, g *game.Game) {
	if !f.draw {
		return
	}
	gl.Disable(gl.TEXTURE_2D)
	gl.Color4ub(255, 255, 255, 255)
	forward := (linear.Vec2{1, 0}).Rotate(ent.Angle()).Scale(100000.0)
	gl.Begin(gl.LINES)
	v := ent.Pos().Add(forward)
	gl.Vertex2d(gl.Double(v.X), gl.Double(v.Y))
	v = ent.Pos().Sub(forward)
	gl.Vertex2d(gl.Double(v.X), gl.Double(v.Y))
	gl.End()
}
Exemplo n.º 27
0
func (e *Entity) drawReticle(pos mathgl.Vec2, rgba [4]float64) {
	if !e.hovered && !e.selected && !e.controlled {
		return
	}
	gl.PushAttrib(gl.CURRENT_BIT)
	r := byte(rgba[0] * 255)
	g := byte(rgba[1] * 255)
	b := byte(rgba[2] * 255)
	a := byte(rgba[3] * 255)
	switch {
	case e.controlled:
		gl.Color4ub(0, 0, r, a)
	case e.selected:
		gl.Color4ub(r, g, b, a)
	default:
		gl.Color4ub(r, g, b, byte((int(a)*200)>>8))
	}
	glow := texture.LoadFromPath(filepath.Join(base.GetDataDir(), "ui", "glow.png"))
	dx := float64(e.last_render_width + 0.5)
	dy := float64(e.last_render_width * 150 / 100)
	glow.Render(float64(pos.X), float64(pos.Y), dx, dy)
	gl.PopAttrib()
}
Exemplo n.º 28
0
func (m *HeatSeeker) Draw(g *Game, side int) {
	base.EnableShader("status_bar")
	base.SetUniformF("status_bar", "inner", 0.01)
	base.SetUniformF("status_bar", "outer", 0.03)
	base.SetUniformF("status_bar", "buffer", 0.01)
	base.SetUniformF("status_bar", "frac", 1.0)
	gl.Color4ub(255, 255, 255, 255)
	texture.Render(m.Position.X-100, m.Position.Y-100, 200, 200)
	base.SetUniformF("status_bar", "inner", 0.04)
	base.SetUniformF("status_bar", "outer", 0.045)
	base.SetUniformF("status_bar", "buffer", 0.01)
	health_frac := float32(m.Stats().HealthCur() / m.Stats().HealthMax())
	if health_frac > 0.5 {
		color_frac := 1.0 - (health_frac-0.5)*2.0
		gl.Color4ub(gl.Ubyte(255.0*color_frac), 255, 0, 255)
	} else {
		color_frac := health_frac * 2.0
		gl.Color4ub(255, gl.Ubyte(255.0*color_frac), 0, 255)
	}
	base.SetUniformF("status_bar", "frac", health_frac)
	texture.Render(m.Position.X-100, m.Position.Y-100, 200, 200)
	base.EnableShader("")
}
Exemplo n.º 29
0
func renderBoard(g *game.Game, x, y, dx, dy int) {
	tx := dx / len(g.Level.Tiles)
	ty := dy / len(g.Level.Tiles[0])
	gl.Enable(gl.TEXTURE_2D)
	gl.Color4ub(255, 255, 255, 255)
	for i := range g.Level.Tiles {
		for j := range g.Level.Tiles[i] {
			if g.Level.Tiles[i][j].Type == game.TileEmpty {
				tilePath := filepath.Join(base.GetDataDir(), fmt.Sprintf("textures/tile%d.png", (i+j)%4+1))
				tile := texture.LoadFromPath(tilePath)
				tile.Render(float64(x+i*tx), float64(y+j*ty), float64(tx), float64(ty))
			}
		}
	}
}
Exemplo n.º 30
0
func (o *Overlay) Draw(region gui.Region) {
	o.region = region
	switch o.game.Side {
	case SideHaunt:
		if o.game.los.denizens.mode == LosModeBlind {
			return
		}
	case SideExplorers:
		if o.game.los.intruders.mode == LosModeBlind {
			return
		}
	default:
		return
	}
	for _, wp := range o.game.Waypoints {
		if !wp.active || wp.drawn {
			continue
		}

		cx := float32(wp.X)
		cy := float32(wp.Y)
		r := float32(wp.Radius)
		cx1, cy1 := o.game.viewer.BoardToWindow(cx-r, cy-r)
		cx2, cy2 := o.game.viewer.BoardToWindow(cx-r, cy+r)
		cx3, cy3 := o.game.viewer.BoardToWindow(cx+r, cy+r)
		cx4, cy4 := o.game.viewer.BoardToWindow(cx+r, cy-r)
		gl.Color4ub(200, 0, 0, 128)

		base.EnableShader("waypoint")
		base.SetUniformF("waypoint", "radius", float32(wp.Radius))

		t := float32(time.Now().UnixNano()%1e15) / 1.0e9
		base.SetUniformF("waypoint", "time", t)

		gl.Begin(gl.QUADS)
		gl.TexCoord2i(0, 1)
		gl.Vertex2i(int32(cx1), int32(cy1))
		gl.TexCoord2i(0, 0)
		gl.Vertex2i(int32(cx2), int32(cy2))
		gl.TexCoord2i(1, 0)
		gl.Vertex2i(int32(cx3), int32(cy3))
		gl.TexCoord2i(1, 1)
		gl.Vertex2i(int32(cx4), int32(cy4))
		gl.End()

		base.EnableShader("")
	}
}