コード例 #1
0
ファイル: ability_graphics.go プロジェクト: runningwild/jota
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("")
}
コード例 #2
0
ファイル: game_graphics.go プロジェクト: runningwild/jota
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("")
}
コード例 #3
0
ファイル: game_graphics.go プロジェクト: runningwild/jota
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("")
}
コード例 #4
0
ファイル: creep_graphics.go プロジェクト: runningwild/jota
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("")
}
コード例 #5
0
ファイル: game_graphics.go プロジェクト: runningwild/jota
func (m *Mine) 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)
	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("")
}
コード例 #6
0
ファイル: ability_graphics.go プロジェクト: runningwild/jota
func (p *shieldProc) Draw(src, obs game.Gid, game *game.Game) {
	if src != obs {
		return
	}
	ent := game.Ents[src]
	if ent == nil {
		return
	}
	gl.Color4ub(0, 255, 0, 255)
	frac := float32(p.Shield / p.MaxShield)
	base.EnableShader("status_bar")
	base.SetUniformF("status_bar", "frac", frac)
	base.SetUniformF("status_bar", "inner", 0.2)
	base.SetUniformF("status_bar", "outer", 0.23)
	base.SetUniformF("status_bar", "buffer", 0.01)
	texture.Render(ent.Pos().X-100, ent.Pos().Y-100, 200, 200)
	base.EnableShader("")
}
コード例 #7
0
ファイル: game_graphics.go プロジェクト: runningwild/jota
func (cp *ControlPoint) Draw(g *Game) {
	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, 50)
	texture.Render(
		cp.Position.X-cp.Radius,
		cp.Position.Y-cp.Radius,
		2*cp.Radius,
		2*cp.Radius)

	enemyColor := []gl.Ubyte{255, 0, 0, 100}
	allyColor := []gl.Ubyte{0, 255, 0, 100}
	neutralColor := []gl.Ubyte{100, 100, 100, 100}
	var rgba []gl.Ubyte
	if cp.Controlled {
		if g.local.Side == cp.Controller {
			rgba = allyColor
		} else {
			rgba = enemyColor
		}
	} else {
		rgba = neutralColor
	}

	// 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.
	gl.Color4ub(rgba[0], rgba[1], rgba[2], rgba[3])
	base.SetUniformF("status_bar", "frac", float32(cp.Control))
	texture.RenderAdvanced(
		cp.Position.X-cp.Radius,
		cp.Position.Y-cp.Radius,
		2*cp.Radius,
		2*cp.Radius,
		0,
		g.local.Side == cp.Controller)

	base.SetUniformF("status_bar", "inner", 0.45)
	base.SetUniformF("status_bar", "outer", 0.5)
	base.SetUniformF("status_bar", "frac", 1)
	gl.Color4ub(rgba[0], rgba[1], rgba[2], 255)
	texture.RenderAdvanced(
		cp.Position.X-cp.Radius,
		cp.Position.Y-cp.Radius,
		2*cp.Radius,
		2*cp.Radius,
		0,
		g.local.Side == cp.Controller)

	if !cp.Controlled {
		base.SetUniformF("status_bar", "frac", float32(cp.Control))
		if g.local.Side == cp.Controller {
			gl.Color4ub(allyColor[0], allyColor[1], allyColor[2], 255)
		} else {
			gl.Color4ub(enemyColor[0], enemyColor[1], enemyColor[2], 255)
		}
		texture.RenderAdvanced(
			cp.Position.X-cp.Radius,
			cp.Position.Y-cp.Radius,
			2*cp.Radius,
			2*cp.Radius,
			0,
			g.local.Side == cp.Controller)
	}

	base.EnableShader("")
}