-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
66 lines (52 loc) · 1.45 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
package main
import (
"flag"
"log"
"log/slog"
"github.com/hajimehoshi/ebiten/v2"
"github.com/kensonjohnson/roguelike-game-go/assets"
"github.com/kensonjohnson/roguelike-game-go/internal/config"
"github.com/kensonjohnson/roguelike-game-go/internal/engine"
"github.com/kensonjohnson/roguelike-game-go/system/scene"
)
type Game struct {
sceneManager *scene.SceneManagerData
}
func (g *Game) configure() {
g.sceneManager = scene.SceneManager
g.sceneManager.Setup()
g.sceneManager.GoTo(&scene.TitleScene{
ImageBackground: assets.Floor,
PixelWidth: config.ScreenWidth * config.TileWidth,
PixelHeight: config.ScreenHeight * config.TileHeight,
})
}
func (g *Game) Update() error {
g.sceneManager.Update()
return nil
}
func (g *Game) Draw(screen *ebiten.Image) {
g.sceneManager.Draw(screen)
}
// Returns the screen dimensions.
func (g *Game) Layout(w, h int) (int, int) {
return config.TileWidth * config.ScreenWidth, config.TileHeight * config.ScreenHeight
}
func main() {
DebugOn := flag.Bool("debug", false, "Enable debug screens and prints")
flag.Parse()
ebiten.SetWindowResizingMode(ebiten.WindowResizingModeEnabled)
ebiten.SetWindowTitle("Roguelike")
if DebugOn != nil && *DebugOn {
ebiten.SetVsyncEnabled(false)
engine.Debug.TurnOn()
slog.SetLogLoggerLevel(slog.LevelDebug)
}
log.SetFlags(log.Lshortfile)
g := &Game{}
g.configure()
slog.Debug("Starting Game")
if err := ebiten.RunGame(g); err != nil {
log.Panic(err)
}
}