fixes:
- using 1 func for grid collision checking with func arguments in player and obstacle systems. - moving obstacles now kill player if business ends points toward him on contact - added retry in popup menu
This commit is contained in:
@@ -18,7 +18,7 @@ type Game struct {
|
||||
Scenes map[SceneName]Scene
|
||||
CurrentScene SceneName
|
||||
Observer *observers.GameObserver
|
||||
Levels []*Level // fed in LevelScene.GenerateLevels()
|
||||
Levels []*Level // fed in PlayScene.GenerateLevels()
|
||||
Config *config.Config
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ func NewGame(width, height, cellsize int, cfg *config.Config, startscene SceneNa
|
||||
game.Scenes[Menu] = NewMenuScene(game)
|
||||
game.Scenes[About] = NewAboutScene(game)
|
||||
game.Scenes[Popup] = NewPopupScene(game)
|
||||
game.Scenes[Play] = NewLevelScene(game, cfg.Startlevel)
|
||||
game.Scenes[Play] = NewPlayScene(game, cfg.Startlevel)
|
||||
game.Scenes[Select] = NewSelectScene(game)
|
||||
|
||||
game.CurrentScene = startscene
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
"github.com/hajimehoshi/ebiten/v2/inpututil"
|
||||
)
|
||||
|
||||
type LevelScene struct {
|
||||
type PlayScene struct {
|
||||
Game *Game
|
||||
CurrentLevel int
|
||||
Levels []*Level
|
||||
@@ -21,8 +21,8 @@ type LevelScene struct {
|
||||
}
|
||||
|
||||
// Implements the actual playing Scene
|
||||
func NewLevelScene(game *Game, startlevel int) Scene {
|
||||
scene := &LevelScene{Whoami: Play, Next: Play, Game: game}
|
||||
func NewPlayScene(game *Game, startlevel int) Scene {
|
||||
scene := &PlayScene{Whoami: Play, Next: Play, Game: game}
|
||||
|
||||
scene.GenerateLevels(game)
|
||||
scene.SetLevel(startlevel)
|
||||
@@ -33,7 +33,7 @@ func NewLevelScene(game *Game, startlevel int) Scene {
|
||||
return scene
|
||||
}
|
||||
|
||||
func (scene *LevelScene) GenerateLevels(game *Game) {
|
||||
func (scene *PlayScene) GenerateLevels(game *Game) {
|
||||
min := []int{}
|
||||
for _, level := range assets.Project.Levels {
|
||||
level := level
|
||||
@@ -46,30 +46,30 @@ func (scene *LevelScene) GenerateLevels(game *Game) {
|
||||
scene.Game.Levels = scene.Levels
|
||||
}
|
||||
|
||||
func (scene *LevelScene) SetLevel(level int) {
|
||||
func (scene *PlayScene) SetLevel(level int) {
|
||||
scene.CurrentLevel = level
|
||||
scene.Levels[scene.CurrentLevel].SetupGrid(scene.Game)
|
||||
}
|
||||
|
||||
// Interface methods
|
||||
func (scene *LevelScene) SetNext(next SceneName) {
|
||||
func (scene *PlayScene) SetNext(next SceneName) {
|
||||
scene.Next = next
|
||||
}
|
||||
|
||||
func (scene *LevelScene) GetNext() SceneName {
|
||||
func (scene *PlayScene) GetNext() SceneName {
|
||||
// FIXME: set to winner or options screen
|
||||
return scene.Next
|
||||
}
|
||||
|
||||
func (scene *LevelScene) ResetNext() {
|
||||
func (scene *PlayScene) ResetNext() {
|
||||
scene.Next = scene.Whoami
|
||||
}
|
||||
|
||||
func (scene *LevelScene) Clearscreen() bool {
|
||||
func (scene *PlayScene) Clearscreen() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (scene *LevelScene) Update() error {
|
||||
func (scene *PlayScene) Update() error {
|
||||
scene.Levels[scene.CurrentLevel].Update()
|
||||
|
||||
switch {
|
||||
@@ -87,7 +87,7 @@ func (scene *LevelScene) Update() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (scene *LevelScene) Draw(screen *ebiten.Image) {
|
||||
func (scene *PlayScene) Draw(screen *ebiten.Image) {
|
||||
// FIXME: why not in Update() ?!?!?!
|
||||
if scene.CurrentLevel != scene.Game.Observer.CurrentLevel {
|
||||
slog.Debug("level", "current", scene.CurrentLevel,
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
"log/slog"
|
||||
"openquell/assets"
|
||||
"openquell/gameui"
|
||||
"openquell/observers"
|
||||
|
||||
"github.com/ebitenui/ebitenui"
|
||||
"github.com/ebitenui/ebitenui/widget"
|
||||
@@ -75,6 +76,7 @@ func (scene *PopupScene) Draw(screen *ebiten.Image) {
|
||||
|
||||
func (scene *PopupScene) SetupUI() {
|
||||
blue := color.RGBA{0, 255, 128, 255}
|
||||
observer := observers.GetGameObserver(scene.Game.World)
|
||||
|
||||
rowContainer := gameui.NewRowContainer(false)
|
||||
|
||||
@@ -88,10 +90,11 @@ func (scene *PopupScene) SetupUI() {
|
||||
scene.SetNext(Menu)
|
||||
})
|
||||
|
||||
// buttonOptions := gameui.NewMenuButton("Options", *assets.FontRenderer.FontNormal,
|
||||
// func(args *widget.ButtonClickedEventArgs) {
|
||||
// scene.SetNext(Settings)
|
||||
// })
|
||||
buttonRetry := gameui.NewMenuButton("Retry", *assets.FontRenderer.FontNormal,
|
||||
func(args *widget.ButtonClickedEventArgs) {
|
||||
scene.SetNext(Play)
|
||||
observer.Retry = true
|
||||
})
|
||||
|
||||
label := widget.NewText(
|
||||
widget.TextOpts.Text("Menu", *assets.FontRenderer.FontBig, blue),
|
||||
@@ -100,8 +103,8 @@ func (scene *PopupScene) SetupUI() {
|
||||
|
||||
rowContainer.AddChild(label)
|
||||
rowContainer.AddChild(buttonContinue)
|
||||
rowContainer.AddChild(buttonRetry)
|
||||
rowContainer.AddChild(buttonAbort)
|
||||
//rowContainer.AddChild(buttonOptions)
|
||||
|
||||
scene.Ui = &ebitenui.UI{
|
||||
Container: rowContainer.Container(),
|
||||
|
||||
Reference in New Issue
Block a user