-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
39 lines (31 loc) · 850 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
package main
import (
"github.com/BigJk/ramen/console"
"github.com/BigJk/ramen/font"
"github.com/hajimehoshi/ebiten/v2"
)
const (
ScreenW = 80
ScreenH = 50
)
func main() {
InitTileAtlas()
rootConsole, err := console.New(ScreenW, ScreenH, font.DefaultFont, "Yet Another Roguelike Tutorial")
if err != nil {
panic(err)
}
engine := NewEngine()
// Update loop, executed 60 times a second, unaffected by FPS
rootConsole.SetTickHook(func(timeElapsed float64) error {
engine.HandlePlayerTurn(EventHandler())
return nil
})
// Draw loop, executed before each frame is drawn to the screen
rootConsole.SetPreRenderHook(func(screen *ebiten.Image, timeDelta float64) error {
rootConsole.ClearAll() // Clear console
engine.Render(rootConsole)
return nil
})
// Start the console with a scale factor of 2
rootConsole.Start(2)
}