ScreenType enum
This commit is contained in:
@@ -20,32 +20,32 @@ func (e *Engine) Layout(outsideWidth, outsideHeight int) (int, int) {
|
|||||||
|
|
||||||
func (e *Engine) Update(screen *ebiten.Image) error {
|
func (e *Engine) Update(screen *ebiten.Image) error {
|
||||||
e.WatchKeyPress()
|
e.WatchKeyPress()
|
||||||
if e.KContext.ScreenTypeIs("menu") {
|
if e.KContext.ScreenTypeIs(entity.MenuScreenType) {
|
||||||
e.MenuUpdate()
|
e.MenuUpdate()
|
||||||
}
|
}
|
||||||
if e.KContext.ScreenTypeIs("dialog") {
|
if e.KContext.ScreenTypeIs(entity.DialogScreenType) {
|
||||||
e.DialogUpdate()
|
e.DialogUpdate()
|
||||||
}
|
}
|
||||||
if e.KContext.ScreenTypeIs("playground") {
|
if e.KContext.ScreenTypeIs(entity.PlaygroundScreenType) {
|
||||||
e.PlaygroundUpdate()
|
e.PlaygroundUpdate()
|
||||||
}
|
}
|
||||||
if e.KContext.ScreenTypeIs("inventory") {
|
if e.KContext.ScreenTypeIs(entity.InventoryScreenType) {
|
||||||
e.InventoryUpdate()
|
e.InventoryUpdate()
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *Engine) Draw(screen *ebiten.Image) {
|
func (e *Engine) Draw(screen *ebiten.Image) {
|
||||||
if e.KContext.ScreenTypeIs("menu") {
|
if e.KContext.ScreenTypeIs(entity.MenuScreenType) {
|
||||||
e.MenuDraw(screen)
|
e.MenuDraw(screen)
|
||||||
}
|
}
|
||||||
if e.KContext.ScreenTypeIs("dialog") {
|
if e.KContext.ScreenTypeIs(entity.DialogScreenType) {
|
||||||
e.DialogDraw(screen)
|
e.DialogDraw(screen)
|
||||||
}
|
}
|
||||||
if e.KContext.ScreenTypeIs("playground") {
|
if e.KContext.ScreenTypeIs(entity.PlaygroundScreenType) {
|
||||||
e.PlaygroundDraw(screen)
|
e.PlaygroundDraw(screen)
|
||||||
}
|
}
|
||||||
if e.KContext.ScreenTypeIs("inventory") {
|
if e.KContext.ScreenTypeIs(entity.InventoryScreenType) {
|
||||||
e.InventoryDraw(screen)
|
e.InventoryDraw(screen)
|
||||||
}
|
}
|
||||||
if e.Action3Pressed() {
|
if e.Action3Pressed() {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package entity
|
package entity
|
||||||
|
|
||||||
type KContext struct {
|
type KContext struct {
|
||||||
ScreenType string
|
ScreenType ScreenType
|
||||||
ScreenValue string
|
ScreenValue string
|
||||||
CurrentLevel int
|
CurrentLevel int
|
||||||
Players []Player
|
Players []Player
|
||||||
@@ -11,6 +11,6 @@ func (c *KContext) getPrimaryPlayer() Player {
|
|||||||
return c.Players[0]
|
return c.Players[0]
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *KContext) ScreenTypeIs(name string) bool {
|
func (c *KContext) ScreenTypeIs(name ScreenType) bool {
|
||||||
return c.ScreenType == name
|
return c.ScreenType == name
|
||||||
}
|
}
|
||||||
|
|||||||
10
konstructor/entity/entity.screen.go
Normal file
10
konstructor/entity/entity.screen.go
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
package entity
|
||||||
|
|
||||||
|
type ScreenType string
|
||||||
|
|
||||||
|
const (
|
||||||
|
MenuScreenType ScreenType = "menu"
|
||||||
|
DialogScreenType ScreenType = "dialog"
|
||||||
|
PlaygroundScreenType ScreenType = "playground"
|
||||||
|
InventoryScreenType ScreenType = "inventory"
|
||||||
|
)
|
||||||
Reference in New Issue
Block a user