-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
59 lines (44 loc) · 1.39 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
package main
import (
"fmt"
rl "github.com/gen2brain/raylib-go/raylib"
"os"
)
var Version = "v0.1"
func main() {
// Setup
//----------------------------------------------------------------------------------
screenWidth := int32(800)
screenHeight := int32(450)
rl.InitWindow(screenWidth, screenHeight, "/r/roguelikedev 2019")
rl.SetTargetFPS(60)
// NOTE: Textures and Sounds MUST be loaded after Window/Audio initialization
game := newEngine()
// Main Loop
//----------------------------------------------------------------------------------
for !rl.WindowShouldClose() {
frameTime := rl.GetFrameTime()
state := game.PeekState()
// Update
//----------------------------------------------------------------------------------
//if rl.IsKeyPressed(rl.KeyF) {
// rl.ToggleFullscreen()
//}
state.Update(frameTime)
// Draw
//----------------------------------------------------------------------------------
rl.BeginDrawing()
state.Draw(frameTime)
//rl.DrawText(fmt.Sprintf("State: %s | FPS %f | Frame Time: %f", state.GetName(), rl.GetFPS(), frameTime), 20, 20, 10, PlayerColour)
rl.DrawText(fmt.Sprintf("Delta: %f", frameTime), 20, 20, 10, PlayerColour)
rl.EndDrawing()
if state.ShouldQuit() {
break
}
}
// Free resources & Exit
//----------------------------------------------------------------------------------
game.Unload()
rl.CloseWindow()
os.Exit(0)
}