Game Config and sidebar
Signed-off-by: LimePotato <bm01@limepot.xyz>
This commit is contained in:
parent
381183af75
commit
602787a181
6 changed files with 54 additions and 56 deletions
36
src/main/kotlin/group/ouroboros/potrogue/GameConfig.kt
Normal file
36
src/main/kotlin/group/ouroboros/potrogue/GameConfig.kt
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
package group.ouroboros.potrogue
|
||||||
|
|
||||||
|
import org.hexworks.zircon.api.CP437TilesetResources
|
||||||
|
import org.hexworks.zircon.api.ColorThemes
|
||||||
|
import org.hexworks.zircon.api.application.AppConfig
|
||||||
|
import org.hexworks.zircon.api.data.Size3D
|
||||||
|
|
||||||
|
object GameConfig {
|
||||||
|
|
||||||
|
// game
|
||||||
|
const val DUNGEON_LEVELS = 2
|
||||||
|
|
||||||
|
// look & feel
|
||||||
|
val TILESET = CP437TilesetResources.rogueYun16x16()
|
||||||
|
val THEME = ColorThemes.cyberpunk()
|
||||||
|
const val SIDEBAR_WIDTH = 18
|
||||||
|
const val LOG_AREA_HEIGHT = 8
|
||||||
|
|
||||||
|
// sizing
|
||||||
|
const val WINDOW_WIDTH = 80
|
||||||
|
const val WINDOW_HEIGHT = 50
|
||||||
|
|
||||||
|
val WORLD_SIZE = Size3D.create(WINDOW_WIDTH, WINDOW_HEIGHT, DUNGEON_LEVELS)
|
||||||
|
val GAME_AREA_SIZE = Size3D.create(
|
||||||
|
xLength = WINDOW_WIDTH - SIDEBAR_WIDTH,
|
||||||
|
yLength = WINDOW_HEIGHT - LOG_AREA_HEIGHT,
|
||||||
|
zLength = DUNGEON_LEVELS
|
||||||
|
)
|
||||||
|
|
||||||
|
fun buildAppConfig() = AppConfig.newBuilder()
|
||||||
|
.withDefaultTileset(TILESET)
|
||||||
|
.withSize(WINDOW_WIDTH, WINDOW_HEIGHT)
|
||||||
|
.withTitle("$GAME_ID | $GAME_VER")
|
||||||
|
.build()
|
||||||
|
|
||||||
|
}
|
|
@ -11,31 +11,8 @@ import org.hexworks.zircon.api.screen.Screen
|
||||||
//Important Values
|
//Important Values
|
||||||
public val GAME_ID = "potrogue";
|
public val GAME_ID = "potrogue";
|
||||||
public val GAME_VER = "0.1.0-DEV";
|
public val GAME_VER = "0.1.0-DEV";
|
||||||
public val GAME_THEME = cyberpunk()
|
|
||||||
|
|
||||||
fun main(args: Array<String>) {
|
fun main(args: Array<String>) {
|
||||||
|
val grid = SwingApplications.startTileGrid(GameConfig.buildAppConfig())
|
||||||
//Start the tilegrid and screen
|
|
||||||
val grid = SwingApplications.startTileGrid(
|
|
||||||
AppConfig.newBuilder()
|
|
||||||
.withTitle("$GAME_ID | $GAME_VER")
|
|
||||||
.withDefaultTileset(CP437TilesetResources.rogueYun16x16())
|
|
||||||
.build()
|
|
||||||
)
|
|
||||||
val screen = Screen.create(grid)
|
|
||||||
|
|
||||||
//TODO
|
|
||||||
//Create Custom Color Theme
|
|
||||||
/*
|
|
||||||
val GAME_THEME = ColorThemeBuilder.newBuilder()
|
|
||||||
.withName("potcolor")
|
|
||||||
.withAccentColor(TileColor.transparent())
|
|
||||||
.withPrimaryForegroundColor(TileColor.transparent())
|
|
||||||
.withSecondaryForegroundColor(TileColor.transparent())
|
|
||||||
.withPrimaryBackgroundColor(TileColor.transparent())
|
|
||||||
.withSecondaryBackgroundColor(TileColor.transparent())
|
|
||||||
.build())
|
|
||||||
*/
|
|
||||||
|
|
||||||
StartView(grid).dock()
|
StartView(grid).dock()
|
||||||
}
|
}
|
|
@ -1,15 +1,16 @@
|
||||||
package group.ouroboros.potrogue.view
|
package group.ouroboros.potrogue.view
|
||||||
|
|
||||||
|
|
||||||
import group.ouroboros.potrogue.GAME_THEME
|
import group.ouroboros.potrogue.GameConfig
|
||||||
import org.hexworks.zircon.api.ComponentDecorations.box
|
import org.hexworks.zircon.api.ComponentDecorations.box
|
||||||
import org.hexworks.zircon.api.Components
|
import org.hexworks.zircon.api.Components
|
||||||
|
import org.hexworks.zircon.api.component.ColorTheme
|
||||||
import org.hexworks.zircon.api.component.ComponentAlignment
|
import org.hexworks.zircon.api.component.ComponentAlignment
|
||||||
import org.hexworks.zircon.api.grid.TileGrid
|
import org.hexworks.zircon.api.grid.TileGrid
|
||||||
import org.hexworks.zircon.api.view.base.BaseView
|
import org.hexworks.zircon.api.view.base.BaseView
|
||||||
import kotlin.system.exitProcess
|
import kotlin.system.exitProcess
|
||||||
|
|
||||||
class LoseView (private val grid: TileGrid) : BaseView(grid, GAME_THEME) {
|
class LoseView (private val grid: TileGrid, theme: ColorTheme = GameConfig.THEME) : BaseView(grid, theme) {
|
||||||
|
|
||||||
init {
|
init {
|
||||||
//Title
|
//Title
|
||||||
|
|
|
@ -1,38 +1,20 @@
|
||||||
package group.ouroboros.potrogue.view
|
package group.ouroboros.potrogue.view
|
||||||
|
|
||||||
import group.ouroboros.potrogue.GAME_THEME
|
import group.ouroboros.potrogue.GameConfig
|
||||||
import org.hexworks.zircon.api.ComponentDecorations.box
|
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.Components
|
||||||
import org.hexworks.zircon.api.component.ComponentAlignment.LEFT_CENTER
|
import org.hexworks.zircon.api.component.ColorTheme
|
||||||
import org.hexworks.zircon.api.component.ComponentAlignment.RIGHT_CENTER
|
|
||||||
import org.hexworks.zircon.api.grid.TileGrid
|
import org.hexworks.zircon.api.grid.TileGrid
|
||||||
import org.hexworks.zircon.api.view.base.BaseView
|
import org.hexworks.zircon.api.view.base.BaseView
|
||||||
|
|
||||||
class PlayView (private val grid: TileGrid) : BaseView(grid, GAME_THEME) {
|
|
||||||
|
class PlayView (private val grid: TileGrid, theme: ColorTheme = GameConfig.THEME) : BaseView(grid, theme) {
|
||||||
init {
|
init {
|
||||||
//Create Lose Button
|
val sidebar = Components.panel()
|
||||||
val loseButton = Components.button()
|
.withSize(GameConfig.SIDEBAR_WIDTH, GameConfig.WINDOW_HEIGHT)
|
||||||
// constants like LEFT_CENTER can also be imported for brevity
|
.withDecorations(box())
|
||||||
.withAlignmentWithin(screen, LEFT_CENTER)
|
|
||||||
.withText("Lose!")
|
|
||||||
.withDecorations(box(), shadow())
|
|
||||||
.build()
|
.build()
|
||||||
|
|
||||||
//Create Win BUtton
|
screen.addComponent(sidebar)
|
||||||
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)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,15 +1,16 @@
|
||||||
package group.ouroboros.potrogue.view
|
package group.ouroboros.potrogue.view
|
||||||
|
|
||||||
import group.ouroboros.potrogue.GAME_ID
|
import group.ouroboros.potrogue.GAME_ID
|
||||||
import group.ouroboros.potrogue.GAME_THEME
|
import group.ouroboros.potrogue.GameConfig
|
||||||
import org.hexworks.zircon.api.ComponentDecorations.box
|
import org.hexworks.zircon.api.ComponentDecorations.box
|
||||||
import org.hexworks.zircon.api.ComponentDecorations.shadow
|
import org.hexworks.zircon.api.ComponentDecorations.shadow
|
||||||
import org.hexworks.zircon.api.Components
|
import org.hexworks.zircon.api.Components
|
||||||
|
import org.hexworks.zircon.api.component.ColorTheme
|
||||||
import org.hexworks.zircon.api.component.ComponentAlignment
|
import org.hexworks.zircon.api.component.ComponentAlignment
|
||||||
import org.hexworks.zircon.api.grid.TileGrid
|
import org.hexworks.zircon.api.grid.TileGrid
|
||||||
import org.hexworks.zircon.api.view.base.BaseView
|
import org.hexworks.zircon.api.view.base.BaseView
|
||||||
|
|
||||||
class StartView (private val grid: TileGrid) : BaseView(grid, GAME_THEME) {
|
class StartView (private val grid: TileGrid, theme: ColorTheme = GameConfig.THEME) : BaseView(grid, theme) {
|
||||||
init {
|
init {
|
||||||
val msg = "Welcome to $GAME_ID."
|
val msg = "Welcome to $GAME_ID."
|
||||||
|
|
||||||
|
|
|
@ -1,16 +1,17 @@
|
||||||
package group.ouroboros.potrogue.view
|
package group.ouroboros.potrogue.view
|
||||||
|
|
||||||
import group.ouroboros.potrogue.GAME_THEME
|
import group.ouroboros.potrogue.GameConfig
|
||||||
import org.hexworks.zircon.api.ColorThemes
|
import org.hexworks.zircon.api.ColorThemes
|
||||||
import org.hexworks.zircon.api.ComponentDecorations.box
|
import org.hexworks.zircon.api.ComponentDecorations.box
|
||||||
import org.hexworks.zircon.api.Components
|
import org.hexworks.zircon.api.Components
|
||||||
|
import org.hexworks.zircon.api.component.ColorTheme
|
||||||
import org.hexworks.zircon.api.component.ComponentAlignment
|
import org.hexworks.zircon.api.component.ComponentAlignment
|
||||||
import org.hexworks.zircon.api.grid.TileGrid
|
import org.hexworks.zircon.api.grid.TileGrid
|
||||||
import org.hexworks.zircon.api.view.base.BaseView
|
import org.hexworks.zircon.api.view.base.BaseView
|
||||||
import kotlin.system.exitProcess
|
import kotlin.system.exitProcess
|
||||||
|
|
||||||
// For if winning.... obviously just a test.
|
// For if winning.... obviously just a test.
|
||||||
class WinView (private val grid: TileGrid) : BaseView(grid, GAME_THEME) {
|
class WinView (private val grid: TileGrid, theme: ColorTheme = GameConfig.THEME) : BaseView(grid, theme) {
|
||||||
|
|
||||||
init {
|
init {
|
||||||
//Title
|
//Title
|
||||||
|
|
Loading…
Reference in a new issue