We do a little commenting
Signed-off-by: LimePotato <bm01@limepot.xyz>
This commit is contained in:
parent
7294110d34
commit
381183af75
4 changed files with 19 additions and 1 deletions
|
@ -12,31 +12,37 @@ import kotlin.system.exitProcess
|
|||
class LoseView (private val grid: TileGrid) : BaseView(grid, GAME_THEME) {
|
||||
|
||||
init {
|
||||
//Title
|
||||
val header = Components.header()
|
||||
.withText("Game Over")
|
||||
.withAlignmentWithin(screen, ComponentAlignment.CENTER)
|
||||
.build()
|
||||
|
||||
//Reset Button
|
||||
val restartButton = Components.button()
|
||||
.withAlignmentAround(header, ComponentAlignment.BOTTOM_LEFT)
|
||||
.withText("Restart")
|
||||
.withDecorations(box())
|
||||
.build()
|
||||
|
||||
//Quit Button
|
||||
val exitButton = Components.button()
|
||||
.withAlignmentAround(header, ComponentAlignment.BOTTOM_RIGHT)
|
||||
.withText("Quit")
|
||||
.withDecorations(box())
|
||||
.build()
|
||||
|
||||
//On Reset Button activated, move back to PlayView
|
||||
restartButton.onActivated {
|
||||
replaceWith(PlayView(grid))
|
||||
}
|
||||
|
||||
//On Quit BUtton activated, exit program
|
||||
exitButton.onActivated {
|
||||
exitProcess(0)
|
||||
}
|
||||
|
||||
//Bake the cake
|
||||
screen.addComponents(header, restartButton, exitButton)
|
||||
}
|
||||
}
|
|
@ -11,6 +11,7 @@ import org.hexworks.zircon.api.view.base.BaseView
|
|||
|
||||
class PlayView (private val grid: TileGrid) : BaseView(grid, GAME_THEME) {
|
||||
init {
|
||||
//Create Lose Button
|
||||
val loseButton = Components.button()
|
||||
// constants like LEFT_CENTER can also be imported for brevity
|
||||
.withAlignmentWithin(screen, LEFT_CENTER)
|
||||
|
@ -18,16 +19,20 @@ class PlayView (private val grid: TileGrid) : BaseView(grid, GAME_THEME) {
|
|||
.withDecorations(box(), shadow())
|
||||
.build()
|
||||
|
||||
//Create Win BUtton
|
||||
val winButton = Components.button()
|
||||
.withAlignmentWithin(screen, RIGHT_CENTER)
|
||||
.withText("Win!")
|
||||
.withDecorations(box(), shadow())
|
||||
.build()
|
||||
|
||||
//On Win Button activated, move to WinView
|
||||
winButton.onActivated { replaceWith(WinView(grid)) }
|
||||
//On Lose Button activated, move to LoseView
|
||||
loseButton.onActivated { replaceWith(LoseView(grid)) }
|
||||
|
||||
// multiple components can be added once
|
||||
// Bake The Cake
|
||||
screen.addComponents(loseButton, winButton)
|
||||
}
|
||||
}
|
|
@ -2,7 +2,6 @@ package group.ouroboros.potrogue.view
|
|||
|
||||
import group.ouroboros.potrogue.GAME_ID
|
||||
import group.ouroboros.potrogue.GAME_THEME
|
||||
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
|
||||
|
@ -45,6 +44,7 @@ class StartView (private val grid: TileGrid) : BaseView(grid, GAME_THEME) {
|
|||
}
|
||||
|
||||
// We can add multiple components at once
|
||||
//Bake The Cake
|
||||
screen.addComponents(header, startButton)
|
||||
}
|
||||
}
|
|
@ -13,31 +13,38 @@ import kotlin.system.exitProcess
|
|||
class WinView (private val grid: TileGrid) : BaseView(grid, GAME_THEME) {
|
||||
|
||||
init {
|
||||
//Title
|
||||
val header = Components.header()
|
||||
.withText("You won!")
|
||||
.withAlignmentWithin(screen, ComponentAlignment.CENTER)
|
||||
.build()
|
||||
|
||||
//Create Reset Button
|
||||
val restartButton = Components.button()
|
||||
.withAlignmentAround(header, ComponentAlignment.BOTTOM_LEFT)
|
||||
.withText("Restart")
|
||||
.withDecorations(box())
|
||||
.build()
|
||||
|
||||
|
||||
//Create Quit Button
|
||||
val exitButton = Components.button()
|
||||
.withAlignmentAround(header, ComponentAlignment.BOTTOM_RIGHT)
|
||||
.withText("Quit")
|
||||
.withDecorations(box())
|
||||
.build()
|
||||
|
||||
//On Reset Button activated, move back to PlayView
|
||||
restartButton.onActivated {
|
||||
replaceWith(PlayView(grid))
|
||||
}
|
||||
|
||||
//On Quit Button activated, exit program
|
||||
exitButton.onActivated {
|
||||
exitProcess(0)
|
||||
}
|
||||
|
||||
//Bake The Cake
|
||||
screen.addComponents(header, restartButton, exitButton)
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue