merge entity package to konstructor

This commit is contained in:
2023-07-06 23:33:43 +02:00
parent 2fcf6f4fdc
commit 38b8053223
28 changed files with 89 additions and 94 deletions

View File

@@ -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() {

View File

@@ -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 {

View File

@@ -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,

View File

@@ -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)
}

View File

@@ -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]
}

View File

@@ -1,4 +1,4 @@
package entity
package konstructor
import "image/color"

View File

@@ -1,4 +1,4 @@
package entity
package konstructor
type DomainInterface interface {
Init()

View File

@@ -1,4 +1,4 @@
package entity
package konstructor
type EngineArgs struct {
Domain DomainInterface

View File

@@ -1,4 +1,4 @@
package entity
package konstructor
import (
"image/color"

View File

@@ -1,4 +1,4 @@
package entity
package konstructor
type ItemType struct {
ID string

View File

@@ -1,4 +1,4 @@
package entity
package konstructor
type KContext struct {
ScreenType ScreenType

View File

@@ -1,4 +1,4 @@
package entity
package konstructor
import "image/color"

View File

@@ -1,4 +1,4 @@
package entity
package konstructor
type NPCType struct {
ID string

View File

@@ -1,4 +1,4 @@
package entity
package konstructor
type ObjectType struct {
ID string

View File

@@ -1,4 +1,4 @@
package entity
package konstructor
type InventoryItem struct {
Item Item

View File

@@ -1,4 +1,4 @@
package entity
package konstructor
type Position struct {
X int

View File

@@ -1,4 +1,4 @@
package entity
package konstructor
import (
"bytes"

View File

@@ -1,4 +1,4 @@
package entity
package konstructor
type ScreenType string

View File

@@ -1,4 +1,4 @@
package entity
package konstructor
type KeyMap struct {
Up any

View File

@@ -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,