From b27e090850e07db926071562aaeb76c69b08d7e3 Mon Sep 17 00:00:00 2001 From: LimePotato Date: Sat, 28 Oct 2023 13:51:04 -0600 Subject: [PATCH] We create a play view --- .../group/ouroboros/potrogue/view/PlayView.kt | 30 +++++++++++++++++++ .../ouroboros/potrogue/view/StartView.kt | 6 ++++ 2 files changed, 36 insertions(+) create mode 100644 src/main/kotlin/group/ouroboros/potrogue/view/PlayView.kt diff --git a/src/main/kotlin/group/ouroboros/potrogue/view/PlayView.kt b/src/main/kotlin/group/ouroboros/potrogue/view/PlayView.kt new file mode 100644 index 0000000..434feda --- /dev/null +++ b/src/main/kotlin/group/ouroboros/potrogue/view/PlayView.kt @@ -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) + } +} \ No newline at end of file diff --git a/src/main/kotlin/group/ouroboros/potrogue/view/StartView.kt b/src/main/kotlin/group/ouroboros/potrogue/view/StartView.kt index ab035b7..36ca6f8 100644 --- a/src/main/kotlin/group/ouroboros/potrogue/view/StartView.kt +++ b/src/main/kotlin/group/ouroboros/potrogue/view/StartView.kt @@ -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) }