-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
67 lines (51 loc) · 1.13 KB
/
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
package main
import (
rl "github.com/gen2brain/raylib-go/raylib"
components "github.com/tim-the-arcane/go_of_life/components"
"time"
)
var (
showDevPanel bool = false
game components.Game
currentFrame int
lastUpdateTime time.Time
)
func main() {
initialize()
defer rl.CloseWindow()
lastUpdateTime = time.Now()
for !rl.WindowShouldClose() {
currentTime := time.Now()
elapsed := currentTime.Sub(lastUpdateTime).Seconds()
if elapsed >= 1.0 {
update()
draw()
}
}
}
func initialize() {
// Initialize Raylib window
rl.InitWindow(800, 800, "Go of Life")
rl.SetTargetFPS(60)
screenWidth := rl.GetMonitorWidth(rl.GetCurrentMonitor())
screenHeight := rl.GetMonitorHeight(rl.GetCurrentMonitor())
rl.SetWindowSize(screenWidth, screenHeight)
rl.ToggleFullscreen()
// Initialize game
game = components.NewGame(int(screenHeight/2), int(screenWidth/2), 2)
}
func update() {
game.Update()
if rl.IsKeyPressed(rl.KeyD) {
showDevPanel = !showDevPanel
}
}
func draw() {
rl.BeginDrawing()
rl.ClearBackground(rl.Black)
game.Draw()
if showDevPanel {
components.DrawDevOverlay()
}
rl.EndDrawing()
}