playground and object drawer skeleton

This commit is contained in:
2023-07-06 16:35:14 +02:00
parent 701205ac82
commit 2fcf6f4fdc
11 changed files with 56 additions and 20 deletions

View File

@@ -15,5 +15,30 @@ func (e *Engine) PlaygroundUpdate() {
}
func (e *Engine) PlaygroundDraw(screen *ebiten.Image) {
e.Domain.GetLevel(e.KContext.CurrentLevel)
e.PlaygroundBackgroundDraw(screen)
e.PlaygroundObjectsDraw(screen)
}
func (e *Engine) PlaygroundBackgroundDraw(screen *ebiten.Image) {
playground := e.GetPlayground()
render := playground.Render
screen.DrawImage(e.GetImage(render), &ebiten.DrawImageOptions{})
}
func (e *Engine) PlaygroundObjectsDraw(screen *ebiten.Image) {
playground := e.GetPlayground()
geoM := ebiten.GeoM{}
for _, object := range playground.Objects {
render := object.Type.Render
geoM.Reset()
geoM.Translate(float64(object.Position.X), float64(object.Position.Y))
screen.DrawImage(e.GetImage(render), &ebiten.DrawImageOptions{
GeoM: geoM,
})
}
}
func (e *Engine) GetPlayground() entity.Playground {
level := e.Domain.GetLevel(e.KContext.CurrentLevel)
return level.Playgrounds[e.KContext.CurrentPlayground]
}

View File

@@ -1,10 +1,11 @@
package entity
type KContext struct {
ScreenType ScreenType
ScreenValue string
CurrentLevel int
Players []Player
ScreenType ScreenType
ScreenValue string
CurrentLevel int
CurrentPlayground int
Players []Player
}
func (c *KContext) getPrimaryPlayer() Player {

View File

@@ -14,6 +14,7 @@ type KeyMap struct {
type ScreenSettings struct {
Width int
Height int
Scale int
}
type Settings struct {