-
Notifications
You must be signed in to change notification settings - Fork 0
/
gift.go
51 lines (43 loc) · 906 Bytes
/
gift.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
package main
import (
"github.com/go-gl/gl/v2.1/gl"
)
type NutGift struct {
texture uint32
coords Rect
height float32
width float32
}
func NewNutGift(point Point) Entity {
texture, bounds := NewTexture("assets/nut.png")
h, w := bounds.Right.Y, bounds.Right.X
return &NutGift{
texture: texture,
coords: Rect{
Left: Point{point.X - w/2, point.Y + h/2},
Right: Point{point.X + w/2, point.Y - h/2},
},
height: bounds.Right.Y,
width: bounds.Right.X,
}
}
func (e *NutGift) Update() {
}
func (e *NutGift) GetCoords() Rect {
return e.coords
}
func (e *NutGift) Render() {
gl.PushMatrix()
{
gl.Translatef(e.coords.Left.X+e.width, e.coords.Right.Y+e.height, 0)
rect := Rect{
Left: Point{e.width, -e.height},
Right: Point{-e.width, e.height},
}
DrawTexture(e.texture, rect)
}
gl.PopMatrix()
}
func (e *NutGift) Unload() {
gl.DeleteTextures(1, &e.texture)
}