move engine to engines/easy_ebitengine

This commit is contained in:
2023-07-06 23:40:57 +02:00
parent 38b8053223
commit a4e7eedb39
9 changed files with 10 additions and 10 deletions

View File

@@ -0,0 +1,35 @@
package easy_ebitengine
import (
"github.com/hajimehoshi/ebiten"
"github.com/hajimehoshi/ebiten/text"
)
func (e *Engine) MenuUpdate() {
menu := e.Domain.GetMenu(e.KContext.ScreenValue)
if e.UpPressed() && menu.CurrentSelected != 0 {
menu.CurrentSelected--
}
if e.DownPressed() && menu.CurrentSelected != len(menu.MenuItems)-1 {
menu.CurrentSelected++
}
if e.Action0Pressed() {
menu.MenuItems[menu.CurrentSelected].Handler()
}
e.Domain.SetMenu(e.KContext.ScreenValue, menu)
}
func (e *Engine) MenuDraw(screen *ebiten.Image) {
menu := e.Domain.GetMenu(e.KContext.ScreenValue)
face := menu.Layout.MenuItemFont.GetFontFace()
for i, menu_item := range menu.MenuItems {
color := menu.GetMenuItemColor(i)
offset := int(menu.Layout.MenuItemFont.Size) * (i + 1)
text.Draw(screen, menu_item.Label+"\n", face, 8, offset, color)
}
}