controller keymap fix, inventory skeleton

This commit is contained in:
2023-07-05 10:33:50 +02:00
parent 2c556a3dac
commit 25b03cfd2f
10 changed files with 93 additions and 44 deletions

15
domain/inventory.go Normal file
View File

@@ -0,0 +1,15 @@
package domain
import "game/konstructor/entity"
func (d *Domain) AddToInventory(item *entity.Item) bool {
return true
}
func (d *Domain) RemoveFromInventory(item *entity.Item) bool {
return true
}
func (d *Domain) UseInventoryItem(item *entity.Item) bool {
return true
}

View File

@@ -0,0 +1,15 @@
package engine
import "game/konstructor/entity"
func (e *Engine) AddToInventory(item *entity.Item) {
e.Domain.AddToInventory(item)
}
func (e *Engine) RemoveFromInventory(item *entity.Item) {
e.Domain.RemoveFromInventory(item)
}
func (e *Engine) UseInventoryItem(item *entity.Item) {
e.Domain.UseInventoryItem(item)
}

View File

@@ -7,4 +7,7 @@ type DomainInterface interface {
GetDialog(name string) Dialog
SetDialog(name string, menu Dialog)
GetLevel(index int) Level
AddToInventory(item *Item) bool
RemoveFromInventory(item *Item) bool
UseInventoryItem(item *Item) bool
}

View File

@@ -0,0 +1,12 @@
package entity
type ItemType struct {
ID string
RenderOptions RenderOptions
}
type Item struct {
ID string
Type ItemType
Position Position
}

View File

@@ -0,0 +1,12 @@
package entity
type NPCType struct {
ID string
RenderOptions RenderOptions
}
type NPC struct {
ID string
Type NPCType
Position Position
}

View File

@@ -0,0 +1,12 @@
package entity
type ObjectType struct {
ID string
RenderOptions RenderOptions
}
type Object struct {
ID string
Type ObjectType
Position Position
}

View File

@@ -0,0 +1,18 @@
package entity
type InventoryItem struct {
Item Item
Used bool
Active bool
}
type Inventory struct {
Items []InventoryItem
}
type Player struct {
ID string
RenderOptions RenderOptions
Position Position
Inventory Inventory
}

View File

@@ -7,48 +7,10 @@ type Position struct {
}
type RenderOptions struct {
Image string
Width int
Height int
}
type ObjectType struct {
ID string
RenderOptions RenderOptions
}
type Object struct {
ID string
Type ObjectType
Position Position
}
type NPCType struct {
ID string
RenderOptions RenderOptions
}
type NPC struct {
ID string
Type NPCType
Position Position
}
type Player struct {
ID string
RenderOptions RenderOptions
Position Position
}
type ItemType struct {
ID string
RenderOptions RenderOptions
}
type Item struct {
ID string
Type ItemType
Position Position
Image string
Width int
Height int
Visible bool
}
type Playground struct {

View File

@@ -21,5 +21,5 @@ type ScreenSettings struct {
type Settings struct {
Name string
Screen *ScreenSettings
KeyMap *KeyMap
KeyMap KeyMap
}

View File

@@ -33,7 +33,7 @@ func main() {
Width: 640,
Height: 480,
},
KeyMap: &entity.KeyMap{
KeyMap: entity.KeyMap{
Up: ebiten.KeyUp,
Down: ebiten.KeyDown,
Right: ebiten.KeyRight,