added final menu after last level
This commit is contained in:
parent
6f85a90b58
commit
ae8058e052
10
TODO.md
10
TODO.md
@ -2,18 +2,14 @@
|
||||
|
||||
- ignore comments in lvl files
|
||||
|
||||
- Start the game end timer and add a score FIXME: put the actual max
|
||||
reachable score into the level definition along with the minimum
|
||||
steps required to reach it, also add a step counter
|
||||
|
||||
- Grid Observer:
|
||||
https://github.com/mlange-42/arche/issues/374
|
||||
|
||||
- Add some final message when the player reaches the last level, start
|
||||
from scratch or a message to buy me some beer, whatever
|
||||
|
||||
- Add shaders for animation (player destruction etc)
|
||||
|
||||
- Start New game starts with last played level, better add a Resume
|
||||
Game menu item for this and use Start New always for level 1.
|
||||
|
||||
- for finding caller:
|
||||
pc := make([]uintptr, 10)
|
||||
n := runtime.Callers(0, pc)
|
||||
|
||||
@ -34,6 +34,7 @@ func (scene *LevelScene) GenerateLevels(game *Game) {
|
||||
}
|
||||
|
||||
scene.Game.Observer.SetupLevelScore(min)
|
||||
scene.Game.Observer.SetupMaxLevels(len(min))
|
||||
scene.Game.Levels = scene.Levels
|
||||
}
|
||||
|
||||
|
||||
@ -75,6 +75,49 @@ func (scene *NextlevelScene) Draw(screen *ebiten.Image) {
|
||||
}
|
||||
|
||||
func (scene *NextlevelScene) SetupUI() {
|
||||
observer := observers.GetGameObserver(scene.Game.World)
|
||||
slog.Debug("levels", "max", observer.MaxLevels, "current", observer.CurrentLevel)
|
||||
if observer.MaxLevels == observer.CurrentLevel+1 {
|
||||
scene.SetupUILast()
|
||||
} else {
|
||||
scene.SetupUIRetry()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func (scene *NextlevelScene) SetupUILast() {
|
||||
blue := color.RGBA{0, 255, 128, 255}
|
||||
observer := observers.GetGameObserver(scene.Game.World)
|
||||
|
||||
rowContainer := gameui.NewRowContainer(false)
|
||||
label1text := "Last level, congratulations!"
|
||||
label2text := fmt.Sprintf("Your final score: %d", observer.GetLevelScore())
|
||||
|
||||
buttonMenu := gameui.NewMenuButton("Menu", *assets.FontRenderer.FontNormal,
|
||||
func(args *widget.ButtonClickedEventArgs) {
|
||||
scene.SetNext(Menu)
|
||||
})
|
||||
|
||||
label1 := widget.NewText(
|
||||
widget.TextOpts.Text(label1text, *assets.FontRenderer.FontNormal, blue),
|
||||
widget.TextOpts.Position(widget.TextPositionCenter, widget.TextPositionCenter),
|
||||
)
|
||||
|
||||
label2 := widget.NewText(
|
||||
widget.TextOpts.Text(label2text, *assets.FontRenderer.FontNormal, blue),
|
||||
widget.TextOpts.Position(widget.TextPositionCenter, widget.TextPositionCenter),
|
||||
)
|
||||
|
||||
rowContainer.AddChild(label1)
|
||||
rowContainer.AddChild(label2)
|
||||
rowContainer.AddChild(buttonMenu)
|
||||
|
||||
scene.Ui = &ebitenui.UI{
|
||||
Container: rowContainer.Container(),
|
||||
}
|
||||
}
|
||||
|
||||
func (scene *NextlevelScene) SetupUIRetry() {
|
||||
blue := color.RGBA{0, 255, 128, 255}
|
||||
observer := observers.GetGameObserver(scene.Game.World)
|
||||
|
||||
|
||||
@ -28,6 +28,7 @@ type GameObserver struct {
|
||||
Entities map[ecs.ID]map[ecs.Entity]int
|
||||
LevelScore map[int]*Score // one score per level
|
||||
Id int
|
||||
MaxLevels int
|
||||
}
|
||||
|
||||
func (observer *GameObserver) GetListenerCallback(comp ecs.ID) listener.Callback {
|
||||
@ -140,6 +141,10 @@ func (observer *GameObserver) SetupLevelScore(min []int) {
|
||||
}
|
||||
}
|
||||
|
||||
func (observer *GameObserver) SetupMaxLevels(count int) {
|
||||
observer.MaxLevels = count
|
||||
}
|
||||
|
||||
// set current level stats and reset counters
|
||||
func (observer *GameObserver) AddScore() {
|
||||
level := observer.CurrentLevel
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user