-
Notifications
You must be signed in to change notification settings - Fork 0
/
game.go
47 lines (37 loc) · 753 Bytes
/
game.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
package main
import (
_ "image/png"
"time"
"github.com/zerofelx/GameP/window"
"github.com/faiface/pixel"
"github.com/faiface/pixel/pixelgl"
"github.com/zerofelx/GameP/sprites"
)
func run() {
cfg := pixelgl.WindowConfig{
Title: "Pixel Game",
Bounds: pixel.R(0, 0, 720, 480),
// VSync: true,
}
win, err := pixelgl.NewWindow(cfg)
if err != nil {
panic(err)
}
Player := sprites.PlayerSprite()
window.Window(win)
last := time.Now()
angle := 0.0
for !win.Closed() {
dt := time.Since(last).Seconds()
last = time.Now()
angle += 3 * dt
window.Window(win)
mat := sprites.PlayerMatrix(win)
mat = mat.Rotated(win.Bounds().Center(), angle)
Player.Draw(win, mat)
win.Update()
}
}
func main() {
pixelgl.Run(run)
}