diff --git a/assets/images/objects/.keep b/assets/images/objects/.keep deleted file mode 100644 index e69de29..0000000 diff --git a/assets/images/objects/test_object.ase b/assets/images/objects/test_object.ase new file mode 100644 index 0000000..3afc815 Binary files /dev/null and b/assets/images/objects/test_object.ase differ diff --git a/assets/images/objects/test_object.png b/assets/images/objects/test_object.png new file mode 100644 index 0000000..539c799 Binary files /dev/null and b/assets/images/objects/test_object.png differ diff --git a/assets/images/playgrounds/.keep b/assets/images/playgrounds/.keep deleted file mode 100644 index e69de29..0000000 diff --git a/assets/images/playgrounds/level_1_playground_1.ase b/assets/images/playgrounds/level_1_playground_1.ase new file mode 100644 index 0000000..81816ba Binary files /dev/null and b/assets/images/playgrounds/level_1_playground_1.ase differ diff --git a/assets/images/playgrounds/level_1_playground_1.png b/assets/images/playgrounds/level_1_playground_1.png new file mode 100644 index 0000000..15c431f Binary files /dev/null and b/assets/images/playgrounds/level_1_playground_1.png differ diff --git a/domain/level.go b/domain/level.go index 150fb30..d434acf 100644 --- a/domain/level.go +++ b/domain/level.go @@ -29,6 +29,22 @@ func (d *Domain) InitLevel() { }, }, }, + { + ID: "test_object2", + Position: entity.Position{ + X: 50, + Y: 50, + Z: 0, + }, + Type: entity.ObjectType{ + ID: "test_object_type", + Render: entity.Render{ + Image: "assets/images/objects/test_object.png", + Width: 30, + Height: 30, + }, + }, + }, }, }, }, diff --git a/konstructor/engine/screen.playground.go b/konstructor/engine/screen.playground.go index de3dbe0..a7bebca 100644 --- a/konstructor/engine/screen.playground.go +++ b/konstructor/engine/screen.playground.go @@ -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] } diff --git a/konstructor/entity/entity.kcontext.go b/konstructor/entity/entity.kcontext.go index 7e967b5..40c8d4f 100644 --- a/konstructor/entity/entity.kcontext.go +++ b/konstructor/entity/entity.kcontext.go @@ -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 { diff --git a/konstructor/entity/entity.settings.go b/konstructor/entity/entity.settings.go index 78a4bab..2676885 100644 --- a/konstructor/entity/entity.settings.go +++ b/konstructor/entity/entity.settings.go @@ -14,6 +14,7 @@ type KeyMap struct { type ScreenSettings struct { Width int Height int + Scale int } type Settings struct { diff --git a/main.go b/main.go index abe4034..0257976 100644 --- a/main.go +++ b/main.go @@ -12,26 +12,19 @@ import ( func main() { k := konstructor.Konstructor{ EngineWrapper: &engine.EngineWrapper{}, - Domain: &domain.Domain{ - Context: domain.Context{ - PlayerState: domain.PlayerState{ - Name: "Player One", - }, - User: domain.User{ - Name: "John Doe", - }, - }, - }, + Domain: &domain.Domain{}, KContext: &entity.KContext{ - ScreenType: entity.MenuScreenType, - ScreenValue: "MainMenu", - CurrentLevel: 0, + ScreenType: entity.PlaygroundScreenType, + ScreenValue: "MainMenu", + CurrentLevel: 0, + CurrentPlayground: 0, }, Settings: &entity.Settings{ Name: "Game", Screen: &entity.ScreenSettings{ - Width: 640, - Height: 480, + Width: 320, + Height: 240, + Scale: 2, }, KeyMap: entity.KeyMap{ Up: ebiten.KeyUp,