You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
51 lines
1004 B
51 lines
1004 B
package lib
|
|
|
|
import (
|
|
"github.com/hajimehoshi/ebiten/v2"
|
|
"github.com/hajimehoshi/ebiten/v2/ebitenutil"
|
|
)
|
|
|
|
// Scenes: Main Menu
|
|
// Game Mode
|
|
|
|
type GameEvent struct {
|
|
Type int
|
|
}
|
|
|
|
type HandleResult int
|
|
|
|
const (
|
|
EventNoOp int = iota
|
|
EventKeyRelease
|
|
)
|
|
|
|
const (
|
|
DoNothing HandleResult = iota
|
|
EndProgram
|
|
)
|
|
|
|
// Scene is the highest level organization unit of a Game. It handles events.
|
|
// A game has a currently active scene, and can transition
|
|
type Scene interface {
|
|
// Handles a game event and returns a result.
|
|
HandleEvent(*GameEvent) HandleResult
|
|
Draw(screen *ebiten.Image)
|
|
}
|
|
|
|
type MainMenuScene struct {
|
|
selections [1]string
|
|
currentSelectionIndex int
|
|
}
|
|
|
|
func (menu *MainMenuScene) HandleEvent(e *GameEvent) HandleResult {
|
|
if e.Type == 1 {
|
|
if menu.selections[menu.currentSelectionIndex] == "Quit" {
|
|
return EndProgram
|
|
}
|
|
}
|
|
return DoNothing
|
|
}
|
|
|
|
func (menu *MainMenuScene) Draw(screen *ebiten.Image) {
|
|
ebitenutil.DebugPrint(screen, menu.selections[menu.currentSelectionIndex])
|
|
}
|