add test code

This commit is contained in:
2024-06-10 13:02:32 +02:00
parent b8496d0ae2
commit 63d8d09fc0
7 changed files with 143 additions and 7 deletions

View File

@@ -27,6 +27,7 @@ func NewGame(config *Config, startscene SceneName) *Game {
game.Scenes[Menu] = NewMenuScene(game, config)
game.Scenes[Options] = NewOptionsScene(game, config)
game.Scenes[Keybindings] = NewKeybindingsScene(game, config)
game.Scenes[Toolbar] = NewToolbarScene(game, config)
// setup environment
ebiten.SetWindowSize(game.ScreenWidth, game.ScreenHeight)
@@ -67,6 +68,7 @@ func (game *Game) Update() error {
func (game *Game) Draw(screen *ebiten.Image) {
// first draw primary scene[s], although there are only 1
skip := false
for current, scene := range game.Scenes {
if scene.IsPrimary() {
// primary scenes always draw
@@ -74,11 +76,15 @@ func (game *Game) Draw(screen *ebiten.Image) {
if current == game.CurrentScene {
// avoid to redraw it in the next step
return
skip = true
}
}
}
if skip {
return
}
scene := game.GetCurrentScene()
scene.Draw(screen)
}