We create a play view

This commit is contained in:
nelle 2023-10-28 13:51:04 -06:00
parent 7e9eb21f83
commit b27e090850
2 changed files with 36 additions and 0 deletions

View file

@ -0,0 +1,30 @@
package group.ouroboros.potrogue.view
import org.hexworks.zircon.api.ColorThemes
import org.hexworks.zircon.api.ComponentDecorations.box
import org.hexworks.zircon.api.ComponentDecorations.shadow
import org.hexworks.zircon.api.Components
import org.hexworks.zircon.api.component.ComponentAlignment.LEFT_CENTER
import org.hexworks.zircon.api.component.ComponentAlignment.RIGHT_CENTER
import org.hexworks.zircon.api.grid.TileGrid
import org.hexworks.zircon.api.view.base.BaseView
class PlayView (private val grid: TileGrid) : BaseView(grid, ColorThemes.arc()) {
init {
val loseButton = Components.button()
// constants like LEFT_CENTER can also be imported for brevity
.withAlignmentWithin(screen, LEFT_CENTER)
.withText("Lose!")
.withDecorations(box(), shadow())
.build()
val winButton = Components.button()
.withAlignmentWithin(screen, RIGHT_CENTER)
.withText("Win!")
.withDecorations(box(), shadow())
.build()
// multiple components can be added once
screen.addComponents(loseButton, winButton)
}
}

View file

@ -37,6 +37,12 @@ class StartView (private val grid: TileGrid) : BaseView(grid, GAME_THEME) {
.withDecorations(box(), shadow())
.build()
// Once the start button is pressed, move on to the PlayView
//TODO move this on to a configuration screen for world/player customization before PlayView, for now basic gameplay is in order though.
startButton.onActivated {
replaceWith(PlayView(grid))
}
// We can add multiple components at once
screen.addComponents(header, startButton)
}