structure tweaks

This commit is contained in:
2023-07-02 19:58:41 +02:00
parent 293c8f407e
commit d55c080243
4 changed files with 12 additions and 21 deletions

View File

@@ -8,19 +8,7 @@ type Player struct {
Name string
}
type GameField struct {
Level Level
LevelSection LevelSection
}
type Position struct {
X int
Y int
}
type Context struct {
Player Player
User User
CurrentGameField GameField
CurrentPosition Position
}

View File

@@ -10,16 +10,16 @@ type Engine struct {
}
func (g *Engine) Layout(outsideWidth, outsideHeight int) (int, int) {
return g.Konstructor.Settings.Screen.Width, g.Konstructor.Settings.Screen.Height
return g.Logic.Settings.Screen.Width, g.Logic.Settings.Screen.Height
}
func (g *Engine) Update(screen *ebiten.Image) error {
g.Konstructor.Controller.Watch()
g.Logic.Controller.Watch()
g.Logic.Update(screen)
return nil
}
func (g *Engine) Draw(screen *ebiten.Image) {
g.Logic.Draw(screen)
g.Konstructor.Controller.Clear()
g.Logic.Controller.Clear()
}

View File

@@ -34,9 +34,10 @@ func (k Konstructor) Init() {
ebiten.SetWindowSize(k.Settings.Screen.Width, k.Settings.Screen.Height)
ebiten.SetWindowTitle(k.Settings.Name)
if err := ebiten.RunGame(&Engine{
Konstructor: &k,
Logic: &Logic{
Konstructor: &k,
Domain: k.Domain,
Controller: k.Controller,
Settings: k.Settings,
},
}); err != nil {
log.Fatal(err)

View File

@@ -7,14 +7,16 @@ import (
)
type Logic struct {
Konstructor *Konstructor
Domain DomainInterface
Controller *Controller
Settings *Settings
}
func (l *Logic) Update(screen *ebiten.Image) {
}
func (l *Logic) Draw(screen *ebiten.Image) {
if l.Konstructor.Controller.UpPressed() {
if l.Controller.UpPressed() {
screen.Fill(color.White)
}
}