merge entity package to konstructor
This commit is contained in:
@@ -1,16 +1,16 @@
|
||||
package domain
|
||||
|
||||
import (
|
||||
"game/konstructor/entity"
|
||||
"game/konstructor"
|
||||
)
|
||||
|
||||
func (d *Domain) InitDialog() {
|
||||
d.DialogMap = entity.DialogMap{
|
||||
d.DialogMap = konstructor.DialogMap{
|
||||
"TestDialog": {
|
||||
Layout: entity.DialogLayout{
|
||||
Layout: konstructor.DialogLayout{
|
||||
ChoiceFont: GetDefaultFontLayout(),
|
||||
},
|
||||
Choices: []entity.DialogChoice{
|
||||
Choices: []konstructor.DialogChoice{
|
||||
{
|
||||
ID: "one",
|
||||
Label: "One",
|
||||
@@ -24,15 +24,15 @@ func (d *Domain) InitDialog() {
|
||||
}
|
||||
}
|
||||
|
||||
func (d *Domain) GetDialogMap() entity.DialogMap {
|
||||
func (d *Domain) GetDialogMap() konstructor.DialogMap {
|
||||
return d.DialogMap
|
||||
}
|
||||
|
||||
func (d *Domain) GetDialog(name string) entity.Dialog {
|
||||
func (d *Domain) GetDialog(name string) konstructor.Dialog {
|
||||
value, _ := d.DialogMap[name]
|
||||
return value
|
||||
}
|
||||
|
||||
func (d *Domain) SetDialog(name string, dialog entity.Dialog) {
|
||||
func (d *Domain) SetDialog(name string, dialog konstructor.Dialog) {
|
||||
d.DialogMap[name] = dialog
|
||||
}
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
package domain
|
||||
|
||||
import (
|
||||
"game/konstructor/entity"
|
||||
"game/konstructor"
|
||||
)
|
||||
|
||||
type Domain struct {
|
||||
Context Context
|
||||
MenuMap entity.MenuMap
|
||||
DialogMap entity.DialogMap
|
||||
Levels []entity.Level
|
||||
MenuMap konstructor.MenuMap
|
||||
DialogMap konstructor.DialogMap
|
||||
Levels []konstructor.Level
|
||||
}
|
||||
|
||||
func (d *Domain) Init() {
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
package domain
|
||||
|
||||
import (
|
||||
"game/konstructor/entity"
|
||||
"game/konstructor"
|
||||
"image/color"
|
||||
)
|
||||
|
||||
func GetDefaultFontLayout() entity.FontLayout {
|
||||
return entity.FontLayout{
|
||||
func GetDefaultFontLayout() konstructor.FontLayout {
|
||||
return konstructor.FontLayout{
|
||||
Path: "assets/fonts/ArcadeClassic.ttf",
|
||||
DPI: 72,
|
||||
Size: 24,
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
package domain
|
||||
|
||||
import "game/konstructor/entity"
|
||||
import "game/konstructor"
|
||||
|
||||
func (d *Domain) AddToInventory(item *entity.Item) bool {
|
||||
func (d *Domain) AddToInventory(item *konstructor.Item) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func (d *Domain) RemoveFromInventory(item *entity.Item) bool {
|
||||
func (d *Domain) RemoveFromInventory(item *konstructor.Item) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func (d *Domain) UseInventoryItem(item *entity.Item) bool {
|
||||
func (d *Domain) UseInventoryItem(item *konstructor.Item) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -1,28 +1,28 @@
|
||||
package domain
|
||||
|
||||
import "game/konstructor/entity"
|
||||
import "game/konstructor"
|
||||
|
||||
func (d *Domain) InitLevel() {
|
||||
d.Levels = []entity.Level{
|
||||
d.Levels = []konstructor.Level{
|
||||
{
|
||||
ID: "level_1",
|
||||
Name: "Level I.",
|
||||
Playgrounds: []entity.Playground{
|
||||
Playgrounds: []konstructor.Playground{
|
||||
{
|
||||
Render: entity.Render{
|
||||
Render: konstructor.Render{
|
||||
Image: "assets/images/playgrounds/level_1_playground_1.png",
|
||||
},
|
||||
Objects: []entity.Object{
|
||||
Objects: []konstructor.Object{
|
||||
{
|
||||
ID: "test_object",
|
||||
Position: entity.Position{
|
||||
Position: konstructor.Position{
|
||||
X: 10,
|
||||
Y: 10,
|
||||
Z: 0,
|
||||
},
|
||||
Type: entity.ObjectType{
|
||||
Type: konstructor.ObjectType{
|
||||
ID: "test_object_type",
|
||||
Render: entity.Render{
|
||||
Render: konstructor.Render{
|
||||
Image: "assets/images/objects/test_object.png",
|
||||
Width: 30,
|
||||
Height: 30,
|
||||
@@ -31,14 +31,14 @@ func (d *Domain) InitLevel() {
|
||||
},
|
||||
{
|
||||
ID: "test_object2",
|
||||
Position: entity.Position{
|
||||
Position: konstructor.Position{
|
||||
X: 50,
|
||||
Y: 50,
|
||||
Z: 0,
|
||||
},
|
||||
Type: entity.ObjectType{
|
||||
Type: konstructor.ObjectType{
|
||||
ID: "test_object_type",
|
||||
Render: entity.Render{
|
||||
Render: konstructor.Render{
|
||||
Image: "assets/images/objects/test_object.png",
|
||||
Width: 30,
|
||||
Height: 30,
|
||||
@@ -52,10 +52,10 @@ func (d *Domain) InitLevel() {
|
||||
}
|
||||
}
|
||||
|
||||
func (d *Domain) GetLevels() []entity.Level {
|
||||
func (d *Domain) GetLevels() []konstructor.Level {
|
||||
return d.Levels
|
||||
}
|
||||
|
||||
func (d *Domain) GetLevel(index int) entity.Level {
|
||||
func (d *Domain) GetLevel(index int) konstructor.Level {
|
||||
return d.Levels[index]
|
||||
}
|
||||
|
||||
@@ -2,18 +2,18 @@ package domain
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"game/konstructor/entity"
|
||||
"game/konstructor"
|
||||
"os"
|
||||
)
|
||||
|
||||
func (d *Domain) InitMenu() {
|
||||
d.MenuMap = entity.MenuMap{
|
||||
d.MenuMap = konstructor.MenuMap{
|
||||
"MainMenu": {
|
||||
CurrentSelected: 0,
|
||||
Layout: entity.MenuLayout{
|
||||
Layout: konstructor.MenuLayout{
|
||||
MenuItemFont: GetDefaultFontLayout(),
|
||||
},
|
||||
MenuItems: []entity.MenuItem{
|
||||
MenuItems: []konstructor.MenuItem{
|
||||
{
|
||||
ID: "start",
|
||||
Label: "Start Game",
|
||||
@@ -33,10 +33,10 @@ func (d *Domain) InitMenu() {
|
||||
},
|
||||
"GameMenu": {
|
||||
CurrentSelected: 0,
|
||||
Layout: entity.MenuLayout{
|
||||
Layout: konstructor.MenuLayout{
|
||||
MenuItemFont: GetDefaultFontLayout(),
|
||||
},
|
||||
MenuItems: []entity.MenuItem{
|
||||
MenuItems: []konstructor.MenuItem{
|
||||
{
|
||||
ID: "save",
|
||||
Label: "Save Game",
|
||||
@@ -52,16 +52,16 @@ func (d *Domain) InitMenu() {
|
||||
}
|
||||
}
|
||||
|
||||
func (d *Domain) GetMenuMap() entity.MenuMap {
|
||||
func (d *Domain) GetMenuMap() konstructor.MenuMap {
|
||||
return d.MenuMap
|
||||
}
|
||||
|
||||
func (d *Domain) GetMenu(name string) entity.Menu {
|
||||
func (d *Domain) GetMenu(name string) konstructor.Menu {
|
||||
value, _ := d.MenuMap[name]
|
||||
return value
|
||||
}
|
||||
|
||||
func (d *Domain) SetMenu(name string, menu entity.Menu) {
|
||||
func (d *Domain) SetMenu(name string, menu konstructor.Menu) {
|
||||
d.MenuMap[name] = menu
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package domain
|
||||
|
||||
import "game/konstructor/entity"
|
||||
import "game/konstructor"
|
||||
|
||||
func (d *Domain) Process(options entity.DomainProcessArgs) {
|
||||
func (d *Domain) Process(options konstructor.DomainProcessArgs) {
|
||||
|
||||
}
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
package engine
|
||||
|
||||
import (
|
||||
"game/konstructor/entity"
|
||||
"game/konstructor"
|
||||
"os"
|
||||
|
||||
"github.com/hajimehoshi/ebiten"
|
||||
)
|
||||
|
||||
type Engine struct {
|
||||
Domain entity.DomainInterface
|
||||
Settings *entity.Settings
|
||||
KContext *entity.KContext
|
||||
Domain konstructor.DomainInterface
|
||||
Settings *konstructor.Settings
|
||||
KContext *konstructor.KContext
|
||||
PressedKey ebiten.Key
|
||||
}
|
||||
|
||||
@@ -20,32 +20,32 @@ func (e *Engine) Layout(outsideWidth, outsideHeight int) (int, int) {
|
||||
|
||||
func (e *Engine) Update(screen *ebiten.Image) error {
|
||||
e.WatchKeyPress()
|
||||
if e.KContext.ScreenTypeIs(entity.MenuScreenType) {
|
||||
if e.KContext.ScreenTypeIs(konstructor.MenuScreenType) {
|
||||
e.MenuUpdate()
|
||||
}
|
||||
if e.KContext.ScreenTypeIs(entity.DialogScreenType) {
|
||||
if e.KContext.ScreenTypeIs(konstructor.DialogScreenType) {
|
||||
e.DialogUpdate()
|
||||
}
|
||||
if e.KContext.ScreenTypeIs(entity.PlaygroundScreenType) {
|
||||
if e.KContext.ScreenTypeIs(konstructor.PlaygroundScreenType) {
|
||||
e.PlaygroundUpdate()
|
||||
}
|
||||
if e.KContext.ScreenTypeIs(entity.InventoryScreenType) {
|
||||
if e.KContext.ScreenTypeIs(konstructor.InventoryScreenType) {
|
||||
e.InventoryUpdate()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (e *Engine) Draw(screen *ebiten.Image) {
|
||||
if e.KContext.ScreenTypeIs(entity.MenuScreenType) {
|
||||
if e.KContext.ScreenTypeIs(konstructor.MenuScreenType) {
|
||||
e.MenuDraw(screen)
|
||||
}
|
||||
if e.KContext.ScreenTypeIs(entity.DialogScreenType) {
|
||||
if e.KContext.ScreenTypeIs(konstructor.DialogScreenType) {
|
||||
e.DialogDraw(screen)
|
||||
}
|
||||
if e.KContext.ScreenTypeIs(entity.PlaygroundScreenType) {
|
||||
if e.KContext.ScreenTypeIs(konstructor.PlaygroundScreenType) {
|
||||
e.PlaygroundDraw(screen)
|
||||
}
|
||||
if e.KContext.ScreenTypeIs(entity.InventoryScreenType) {
|
||||
if e.KContext.ScreenTypeIs(konstructor.InventoryScreenType) {
|
||||
e.InventoryDraw(screen)
|
||||
}
|
||||
if e.Action3Pressed() {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package engine
|
||||
|
||||
import (
|
||||
"game/konstructor/entity"
|
||||
"game/konstructor"
|
||||
"log"
|
||||
|
||||
_ "image/png"
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
"github.com/hajimehoshi/ebiten"
|
||||
)
|
||||
|
||||
func (e *Engine) GetImage(render_options entity.Render) *ebiten.Image {
|
||||
func (e *Engine) GetImage(render_options konstructor.Render) *ebiten.Image {
|
||||
img := render_options.GetImage()
|
||||
out, err := ebiten.NewImageFromImage(img, 0)
|
||||
if err != nil {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package engine
|
||||
|
||||
import (
|
||||
"game/konstructor/entity"
|
||||
"game/konstructor"
|
||||
|
||||
"github.com/hajimehoshi/ebiten"
|
||||
)
|
||||
@@ -10,7 +10,7 @@ type EngineWrapper struct {
|
||||
Engine Engine
|
||||
}
|
||||
|
||||
func (ew *EngineWrapper) Init(options entity.EngineArgs) {
|
||||
func (ew *EngineWrapper) Init(options konstructor.EngineArgs) {
|
||||
ew.Engine = Engine{
|
||||
KContext: options.KContext,
|
||||
Domain: options.Domain,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package engine
|
||||
|
||||
import (
|
||||
"game/konstructor/entity"
|
||||
"game/konstructor"
|
||||
|
||||
"github.com/hajimehoshi/ebiten"
|
||||
)
|
||||
@@ -12,14 +12,14 @@ func (e *Engine) InventoryUpdate() {
|
||||
func (e *Engine) InventoryDraw(screen *ebiten.Image) {
|
||||
}
|
||||
|
||||
func (e *Engine) AddToInventory(item *entity.Item) {
|
||||
func (e *Engine) AddToInventory(item *konstructor.Item) {
|
||||
e.Domain.AddToInventory(item)
|
||||
}
|
||||
|
||||
func (e *Engine) RemoveFromInventory(item *entity.Item) {
|
||||
func (e *Engine) RemoveFromInventory(item *konstructor.Item) {
|
||||
e.Domain.RemoveFromInventory(item)
|
||||
}
|
||||
|
||||
func (e *Engine) UseInventoryItem(item *entity.Item) {
|
||||
func (e *Engine) UseInventoryItem(item *konstructor.Item) {
|
||||
e.Domain.UseInventoryItem(item)
|
||||
}
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
package engine
|
||||
|
||||
import (
|
||||
"game/konstructor/entity"
|
||||
"game/konstructor"
|
||||
|
||||
"github.com/hajimehoshi/ebiten"
|
||||
)
|
||||
|
||||
func (e *Engine) PlaygroundUpdate() {
|
||||
level := e.Domain.GetLevel(e.KContext.CurrentLevel)
|
||||
e.Domain.Process(entity.DomainProcessArgs{
|
||||
e.Domain.Process(konstructor.DomainProcessArgs{
|
||||
Level: &level,
|
||||
KContext: e.KContext,
|
||||
})
|
||||
@@ -38,7 +38,7 @@ func (e *Engine) PlaygroundObjectsDraw(screen *ebiten.Image) {
|
||||
}
|
||||
}
|
||||
|
||||
func (e *Engine) GetPlayground() entity.Playground {
|
||||
func (e *Engine) GetPlayground() konstructor.Playground {
|
||||
level := e.Domain.GetLevel(e.KContext.CurrentLevel)
|
||||
return level.Playgrounds[e.KContext.CurrentPlayground]
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package entity
|
||||
package konstructor
|
||||
|
||||
import "image/color"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package entity
|
||||
package konstructor
|
||||
|
||||
type DomainInterface interface {
|
||||
Init()
|
||||
@@ -1,4 +1,4 @@
|
||||
package entity
|
||||
package konstructor
|
||||
|
||||
type EngineArgs struct {
|
||||
Domain DomainInterface
|
||||
@@ -1,4 +1,4 @@
|
||||
package entity
|
||||
package konstructor
|
||||
|
||||
import (
|
||||
"image/color"
|
||||
@@ -1,4 +1,4 @@
|
||||
package entity
|
||||
package konstructor
|
||||
|
||||
type ItemType struct {
|
||||
ID string
|
||||
@@ -1,4 +1,4 @@
|
||||
package entity
|
||||
package konstructor
|
||||
|
||||
type KContext struct {
|
||||
ScreenType ScreenType
|
||||
@@ -1,4 +1,4 @@
|
||||
package entity
|
||||
package konstructor
|
||||
|
||||
import "image/color"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package entity
|
||||
package konstructor
|
||||
|
||||
type NPCType struct {
|
||||
ID string
|
||||
@@ -1,4 +1,4 @@
|
||||
package entity
|
||||
package konstructor
|
||||
|
||||
type ObjectType struct {
|
||||
ID string
|
||||
@@ -1,4 +1,4 @@
|
||||
package entity
|
||||
package konstructor
|
||||
|
||||
type InventoryItem struct {
|
||||
Item Item
|
||||
@@ -1,4 +1,4 @@
|
||||
package entity
|
||||
package konstructor
|
||||
|
||||
type Position struct {
|
||||
X int
|
||||
@@ -1,4 +1,4 @@
|
||||
package entity
|
||||
package konstructor
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
@@ -1,4 +1,4 @@
|
||||
package entity
|
||||
package konstructor
|
||||
|
||||
type ScreenType string
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package entity
|
||||
package konstructor
|
||||
|
||||
type KeyMap struct {
|
||||
Up any
|
||||
@@ -1,19 +1,15 @@
|
||||
package konstructor
|
||||
|
||||
import (
|
||||
"game/konstructor/entity"
|
||||
)
|
||||
|
||||
type Konstructor struct {
|
||||
Domain entity.DomainInterface
|
||||
KContext *entity.KContext
|
||||
Settings *entity.Settings
|
||||
EngineWrapper entity.EngineWrapperInterface
|
||||
Domain DomainInterface
|
||||
KContext *KContext
|
||||
Settings *Settings
|
||||
EngineWrapper EngineWrapperInterface
|
||||
}
|
||||
|
||||
func (k Konstructor) Init() {
|
||||
k.Domain.Init()
|
||||
k.EngineWrapper.Init(entity.EngineArgs{
|
||||
k.EngineWrapper.Init(EngineArgs{
|
||||
Domain: k.Domain,
|
||||
KContext: k.KContext,
|
||||
Settings: k.Settings,
|
||||
|
||||
11
main.go
11
main.go
@@ -4,7 +4,6 @@ import (
|
||||
"game/domain"
|
||||
"game/konstructor"
|
||||
"game/konstructor/engine"
|
||||
"game/konstructor/entity"
|
||||
|
||||
"github.com/hajimehoshi/ebiten"
|
||||
)
|
||||
@@ -13,20 +12,20 @@ func main() {
|
||||
k := konstructor.Konstructor{
|
||||
EngineWrapper: &engine.EngineWrapper{},
|
||||
Domain: &domain.Domain{},
|
||||
KContext: &entity.KContext{
|
||||
ScreenType: entity.PlaygroundScreenType,
|
||||
KContext: &konstructor.KContext{
|
||||
ScreenType: konstructor.PlaygroundScreenType,
|
||||
ScreenValue: "MainMenu",
|
||||
CurrentLevel: 0,
|
||||
CurrentPlayground: 0,
|
||||
},
|
||||
Settings: &entity.Settings{
|
||||
Settings: &konstructor.Settings{
|
||||
Name: "Game",
|
||||
Screen: &entity.ScreenSettings{
|
||||
Screen: &konstructor.ScreenSettings{
|
||||
Width: 320,
|
||||
Height: 240,
|
||||
Scale: 2,
|
||||
},
|
||||
KeyMap: entity.KeyMap{
|
||||
KeyMap: konstructor.KeyMap{
|
||||
Up: ebiten.KeyUp,
|
||||
Down: ebiten.KeyDown,
|
||||
Right: ebiten.KeyRight,
|
||||
|
||||
Reference in New Issue
Block a user