コード例 #1
0
ファイル: thunder_menu.go プロジェクト: runningwild/jota
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
	}
}
コード例 #2
0
ファイル: ability_graphics.go プロジェクト: runningwild/jota
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("")
}
コード例 #3
0
ファイル: game_graphics.go プロジェクト: runningwild/jota
func (g *Game) RenderLosMask() {
	ent := g.Ents[g.local.Gid]
	if ent == nil {
		return
	}
	walls := g.local.temp.VisibleWallCache.GetWalls(int(ent.Pos().X), int(ent.Pos().Y))
	gl.Disable(gl.TEXTURE_2D)
	gl.Color4ub(0, 0, 0, 255)
	gl.Begin(gl.TRIANGLES)
	for _, wall := range walls {
		if wall.Right(ent.Pos()) {
			continue
		}
		a := wall.P
		b := ent.Pos().Sub(wall.P).Norm().Scale(-10000.0).Add(wall.P)
		mid := wall.P.Add(wall.Q).Scale(0.5)
		c := ent.Pos().Sub(mid).Norm().Scale(-10000.0).Add(mid)
		d := ent.Pos().Sub(wall.Q).Norm().Scale(-10000.0).Add(wall.Q)
		e := wall.Q
		gl.Vertex2d(gl.Double(a.X), gl.Double(a.Y))
		gl.Vertex2d(gl.Double(b.X), gl.Double(b.Y))
		gl.Vertex2d(gl.Double(c.X), gl.Double(c.Y))

		gl.Vertex2d(gl.Double(a.X), gl.Double(a.Y))
		gl.Vertex2d(gl.Double(c.X), gl.Double(c.Y))
		gl.Vertex2d(gl.Double(d.X), gl.Double(d.Y))

		gl.Vertex2d(gl.Double(a.X), gl.Double(a.Y))
		gl.Vertex2d(gl.Double(d.X), gl.Double(d.Y))
		gl.Vertex2d(gl.Double(e.X), gl.Double(e.Y))
	}
	gl.End()
	base.EnableShader("horizon")
	base.SetUniformV2("horizon", "center", ent.Pos())
	base.SetUniformF("horizon", "horizon", float32(ent.Stats().Vision()))
	gl.Begin(gl.QUADS)
	dx := gl.Int(g.Level.Room.Dx)
	dy := gl.Int(g.Level.Room.Dy)
	gl.Vertex2i(0, 0)
	gl.Vertex2i(dx, 0)
	gl.Vertex2i(dx, dy)
	gl.Vertex2i(0, dy)
	gl.End()
	base.EnableShader("")
}