entity layer

This commit is contained in:
2023-07-04 22:58:23 +02:00
parent 93b2725c8a
commit e9c35f01ab
19 changed files with 364 additions and 353 deletions

View File

@@ -1,22 +1,22 @@
package domain
import (
"game/konstructor"
"game/konstructor/entity"
"image/color"
)
func (d *Domain) InitDialog() {
d.DialogMap = konstructor.DialogMap{
d.DialogMap = entity.DialogMap{
"TestDialog": {
Layout: konstructor.DialogLayout{
ChoiceFont: konstructor.FontLayout{
Layout: entity.DialogLayout{
ChoiceFont: entity.FontLayout{
DPI: 72,
Size: 24,
Color: color.White,
SelectedColor: color.RGBA{R: 0, G: 255, B: 0, A: 100},
},
},
Choices: []konstructor.DialogChoice{
Choices: []entity.DialogChoice{
{
ID: "one",
Label: "One",
@@ -30,11 +30,11 @@ func (d *Domain) InitDialog() {
}
}
func (d *Domain) GetDialog(name string) konstructor.Dialog {
func (d *Domain) GetDialog(name string) entity.Dialog {
value, _ := d.DialogMap[name]
return value
}
func (d *Domain) SetDialog(name string, dialog konstructor.Dialog) {
func (d *Domain) SetDialog(name string, dialog entity.Dialog) {
d.DialogMap[name] = dialog
}

View File

@@ -1,14 +1,14 @@
package domain
import (
"game/konstructor"
"game/konstructor/entity"
)
type Domain struct {
Context Context
MenuMap konstructor.MenuMap
DialogMap konstructor.DialogMap
Levels []konstructor.Level
MenuMap entity.MenuMap
DialogMap entity.DialogMap
Levels []entity.Level
}
func (d *Domain) Init() {

View File

@@ -1,28 +1,26 @@
package domain
import (
"game/konstructor"
)
import "game/konstructor/entity"
func (d *Domain) InitLevel() {
d.Levels = []konstructor.Level{
d.Levels = []entity.Level{
{
ID: "level_1",
Name: "Level I.",
Playgrounds: []konstructor.Playground{
Playgrounds: []entity.Playground{
{
Background: "level_1_playground_1.png",
Objects: []konstructor.Object{
Objects: []entity.Object{
{
ID: "test_object",
Position: konstructor.Position{
Position: entity.Position{
X: 10,
Y: 10,
Z: 0,
},
Type: konstructor.ObjectType{
Type: entity.ObjectType{
ID: "test_object_type",
RenderOptions: konstructor.RenderOptions{
RenderOptions: entity.RenderOptions{
Image: "test_object.png",
Width: 30,
Height: 30,
@@ -36,6 +34,6 @@ func (d *Domain) InitLevel() {
}
}
func (d *Domain) GetLevel(index int) konstructor.Level {
func (d *Domain) GetLevel(index int) entity.Level {
return d.Levels[index]
}

View File

@@ -2,24 +2,24 @@ package domain
import (
"fmt"
"game/konstructor"
"game/konstructor/entity"
"image/color"
"os"
)
func (d *Domain) InitMenu() {
d.MenuMap = konstructor.MenuMap{
d.MenuMap = entity.MenuMap{
"MainMenu": {
CurrentSelected: 0,
Layout: konstructor.MenuLayout{
MenuItemFont: konstructor.FontLayout{
Layout: entity.MenuLayout{
MenuItemFont: entity.FontLayout{
DPI: 72,
Size: 24,
Color: color.White,
SelectedColor: color.RGBA{R: 0, G: 255, B: 0, A: 100},
},
},
MenuItems: []konstructor.MenuItem{
MenuItems: []entity.MenuItem{
{
ID: "start",
Label: "Start Game",
@@ -39,15 +39,15 @@ func (d *Domain) InitMenu() {
},
"GameMenu": {
CurrentSelected: 0,
Layout: konstructor.MenuLayout{
MenuItemFont: konstructor.FontLayout{
Layout: entity.MenuLayout{
MenuItemFont: entity.FontLayout{
DPI: 72,
Size: 24,
Color: color.White,
SelectedColor: color.RGBA{R: 0, G: 255, B: 0, A: 100},
},
},
MenuItems: []konstructor.MenuItem{
MenuItems: []entity.MenuItem{
{
ID: "save",
Label: "Save Game",
@@ -63,12 +63,12 @@ func (d *Domain) InitMenu() {
}
}
func (d *Domain) GetMenu(name string) konstructor.Menu {
func (d *Domain) GetMenu(name string) entity.Menu {
value, _ := d.MenuMap[name]
return value
}
func (d *Domain) SetMenu(name string, menu konstructor.Menu) {
func (d *Domain) SetMenu(name string, menu entity.Menu) {
d.MenuMap[name] = menu
}