/
drawen.go
78 lines (58 loc) · 1.14 KB
/
drawen.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
package pathfinding
import (
// "fmt"
"github.com/go-gl/gl"
//"math"
)
type Entity struct{
Rot, Xpos, Ypos, Size float64
Colour string
IsAlive bool
}
func Hello() string{
return "drawengine"
}
func DrawEntity(en Entity){
x := en.Xpos
y := en.Ypos
r := en.Rot
s := en.Size
col := en.Colour
switch col{
case "grey":
gl.Color3d(0.5,0.5,0.5)
case "red":
gl.Color3d(1, 0, 0)
case "green":
gl.Color3d(0, 1, 0)
case "blue":
gl.Color3d(0, 0, 1)
case "lblue":
gl.Color3d(0.3, 0.3, 1)
case "orange":
gl.Color3d(1, 0.5, 0)
case "yellow":
gl.Color3d(1, 1, 0)
case "purple":
gl.Color3d(1, 0, 1)
case "white":
gl.Color3d(1,1,1)
default:
gl.Color3d(1, 1, 1)
}
gl.PushMatrix()
gl.Translated(x, y, 0)
gl.Scaled(s, s, s)
//gl.Rotated(r*180/math.Pi, 0, 0, 1)
gl.Rotated(r, 0, 0, 1)
enx := [3]float64{-0.7, 0.7, 0}
eny := [3]float64{1, 1, -1}
//in OpenGL 3.2, the vertices below would be stored on the GPU
//so all you would need to do is say DrawShape(A) or something
gl.Begin(gl.TRIANGLES)
gl.Vertex3d(enx[0], eny[0], 0)
gl.Vertex3d(enx[1], eny[1], 0)
gl.Vertex3d(enx[2], eny[2], 0)
gl.End()
gl.PopMatrix()
}