logic layer

This commit is contained in:
2023-07-01 00:50:12 +02:00
parent d5482dd9e7
commit 884df7c406
7 changed files with 126 additions and 102 deletions

View File

@@ -1,26 +1,25 @@
package konstructor
import (
"image/color"
"github.com/hajimehoshi/ebiten"
)
type GameEngine struct {
Konstructor Konstructor
type Engine struct {
Konstructor *Konstructor
Logic *Logic
}
func (g *GameEngine) Update(screen *ebiten.Image) error {
func (g *Engine) Layout(outsideWidth, outsideHeight int) (int, int) {
return g.Konstructor.Settings.Screen.Width, g.Konstructor.Settings.Screen.Height
}
func (g *Engine) Update(screen *ebiten.Image) error {
g.Konstructor.Controller.Watch()
g.Logic.Update(screen)
return nil
}
func (g *GameEngine) Draw(screen *ebiten.Image) {
if g.Konstructor.Controller.UpPressed() {
screen.Fill(color.White)
}
}
func (g *GameEngine) Layout(outsideWidth, outsideHeight int) (int, int) {
return g.Konstructor.Settings.Screen.Width, g.Konstructor.Settings.Screen.Height
func (g *Engine) Draw(screen *ebiten.Image) {
g.Logic.Draw(screen)
g.Konstructor.Controller.Clear()
}