-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
49 lines (37 loc) · 894 Bytes
/
main.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
package main
import (
"snake-go/game"
rl "github.com/gen2brain/raylib-go/raylib"
)
const (
WIDTH = 800
HEIGHT = 450
)
func main() {
rl.InitWindow(WIDTH, HEIGHT, "snake go")
rl.SetTargetFPS(60)
game := game.NewGame(WIDTH, HEIGHT)
for !rl.WindowShouldClose() {
rl.BeginDrawing()
rl.ClearBackground(rl.SkyBlue)
rl.DrawText("This is the base canvas!", WIDTH/3, HEIGHT/2.25, 20, rl.White)
drawGameUI(game)
game.UpdateGameState()
rl.EndDrawing()
}
rl.CloseWindow()
}
func drawGameUI(game *game.Game) {
// Draw canvas
for i := range game.Canvas {
for j := range game.Canvas[i] {
rl.DrawRectangle(int32(j)*10, int32(i)*10, 10, 10, rl.RayWhite)
}
}
// Draw snake
for _, point := range game.Snake.Body {
rl.DrawRectangle(point.X*10, point.Y*10, 10, 10, rl.SkyBlue)
}
// Draw mochi
rl.DrawRectangle(game.Mochi.X*10, game.Mochi.Y*10, 10, 10, rl.Orange)
}