-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8f319c6
commit dd7a2c8
Showing
10 changed files
with
148 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
.gradle/ | ||
.idea/ | ||
build/ | ||
/GameLib.save | ||
/SoulGame.save |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#######A######## | ||
# #+# # | ||
# # # # :## # | ||
# # # # # | ||
# ### # #### # | ||
# # # # | ||
# #:### # :## # | ||
# ###:# ###### # | ||
# # | ||
### #### ### ### | ||
#: :# | ||
################ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#######A######## | ||
#:# #+# #:# | ||
# # ## # | ||
# # # ###### # # | ||
# # # #: # # | ||
# # # # # # # # | ||
# # # # # # # # | ||
# # :# # # # | ||
# # ###### # # # | ||
# # # | ||
#:# ###### #:# | ||
################ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
SoulGameImpl/src/main/kotlin/fr/o80/soulgame/scenes/levelselector/LevelSelectorScene.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
package fr.o80.soulgame.scenes.levelselector | ||
|
||
import fr.o80.gamelib.Scene | ||
import fr.o80.gamelib.loop.KeyPipeline | ||
import fr.o80.gamelib.loop.MouseButtonPipeline | ||
import fr.o80.gamelib.loop.MouseMovePipeline | ||
import fr.o80.gamelib.loop.Window | ||
import fr.o80.gamelib.menu.Menu | ||
import fr.o80.gamelib.menu.TextResources | ||
import fr.o80.gamelib.service.Services | ||
import fr.o80.soulgame.SoulSceneManager | ||
import fr.o80.soulgame.resource | ||
import fr.o80.soulgame.scenes.greenBackground | ||
|
||
class LevelSelectorScene( | ||
private val sceneManager: SoulSceneManager | ||
) : Scene { | ||
|
||
private lateinit var menu: Menu | ||
|
||
private val system = LevelSelectorSystem() | ||
|
||
override fun open( | ||
window: Window, | ||
services: Services, | ||
keyPipeline: KeyPipeline, | ||
mouseButtonPipeline: MouseButtonPipeline, | ||
mouseMovePipeline: MouseMovePipeline | ||
) { | ||
menu = Menu.MenuBuilder() | ||
.of( | ||
top = .0, | ||
left = .0, | ||
right = window.width.toDouble(), | ||
bottom = window.height.toDouble() | ||
) | ||
.andResources( | ||
background = greenBackground, | ||
textResources = TextResources( | ||
font = resource("fonts/LaserCutRegular.ttf"), | ||
fontHeight = 50f | ||
), | ||
titleResources = TextResources( | ||
font = resource("fonts/LaserCutRegular.ttf"), | ||
fontHeight = 99f | ||
) | ||
) | ||
.withPipelines( | ||
mouseButtonPipeline, | ||
mouseMovePipeline | ||
) | ||
.andLayout { | ||
system.forEachLevel { levelName -> | ||
button(levelName) { | ||
sceneManager.openLevel(levelName) | ||
} | ||
} | ||
button("Back") { | ||
sceneManager.openMain() | ||
} | ||
} | ||
.build() | ||
} | ||
|
||
override fun close() { | ||
menu.close() | ||
} | ||
|
||
override suspend fun update() { | ||
menu.update() | ||
} | ||
|
||
override suspend fun render() { | ||
menu.render() | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
SoulGameImpl/src/main/kotlin/fr/o80/soulgame/scenes/levelselector/LevelSelectorSystem.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package fr.o80.soulgame.scenes.levelselector | ||
|
||
import fr.o80.soulgame.resourceFile | ||
|
||
class LevelSelectorSystem { | ||
|
||
private val levelNames: List<String> by lazy { | ||
resourceFile("levels/").list()?.toList()?.map { it.removeSuffix(".txt") } | ||
?: emptyList() | ||
} | ||
|
||
fun forEachLevel(block: (String) -> Unit) { | ||
levelNames.forEach { levelName -> | ||
block(levelName) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters