-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
58 lines (47 loc) · 1.67 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
package main
import (
"log"
)
// EngineInstance is a global variable that holds the instance of the Engine (Singlerton)
var InputInstance *Input = &Input{}
var CameraInstance *Camera = &Camera{}
var EngineInstance *Engine = &Engine{}
var TimeInstance *Time = &Time{}
var SoundManagerInstance *SoundManager = &SoundManager{}
var TextureManagerInstance *TextureManager = &TextureManager{}
var LevelManagerInsatance *LevelManager = &LevelManager{}
var CollisionHandlerInstance *CollisionHandler = &CollisionHandler{}
var DamageHandlerInstance *DamageHandler = &DamageHandler{}
var CoinHandlerInstance *CoinHandler = &CoinHandler{}
var TextureParserInstance *TextureParser = &TextureParser{}
var MapParserInstance *MapParser = &MapParser{}
var ObjectParserInstance *ObjectParser = &ObjectParser{}
var SoundParserInstance *SoundParser = &SoundParser{}
func Core() {
err := EngineInstance.GetInstance().Load()
if err != nil {
log.Fatalf("Failed to load EngineInstance: %v", err)
}
defer Destroy()
for EngineInstance.GetInstance().IsRunning {
TimeInstance.GetInstance().Start()
dt := TimeInstance.GetInstance().GetDeltaTime()
EngineInstance.GetInstance().Events()
EngineInstance.GetInstance().Update(dt)
EngineInstance.GetInstance().Draw()
TimeInstance.GetInstance().Tick()
}
}
func Destroy() {
EngineInstance.GetInstance().Destroy()
TextureManagerInstance.GetInstance().Destroy()
TextureParserInstance.GetInstance().Destroy()
MapParserInstance.GetInstance().Destroy()
ObjectParserInstance.GetInstance().Destroy()
SoundParserInstance.GetInstance().Destroy()
SoundManagerInstance.GetInstance().Destroy()
LevelManagerInsatance.GetInstance().Destroy()
}
func main() {
Core()
}