playground and object drawer skeleton
This commit is contained in:
BIN
assets/images/objects/test_object.ase
Normal file
BIN
assets/images/objects/test_object.ase
Normal file
Binary file not shown.
BIN
assets/images/objects/test_object.png
Normal file
BIN
assets/images/objects/test_object.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 226 B |
BIN
assets/images/playgrounds/level_1_playground_1.ase
Normal file
BIN
assets/images/playgrounds/level_1_playground_1.ase
Normal file
Binary file not shown.
BIN
assets/images/playgrounds/level_1_playground_1.png
Normal file
BIN
assets/images/playgrounds/level_1_playground_1.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.0 KiB |
@@ -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,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
@@ -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]
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ type KContext struct {
|
||||
ScreenType ScreenType
|
||||
ScreenValue string
|
||||
CurrentLevel int
|
||||
CurrentPlayground int
|
||||
Players []Player
|
||||
}
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@ type KeyMap struct {
|
||||
type ScreenSettings struct {
|
||||
Width int
|
||||
Height int
|
||||
Scale int
|
||||
}
|
||||
|
||||
type Settings struct {
|
||||
|
||||
19
main.go
19
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,
|
||||
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,
|
||||
|
||||
Reference in New Issue
Block a user