aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/TextureManager.kt
diff options
context:
space:
mode:
authorJames Barnett <noreply@jamesbarnett.xyz>2020-12-30 14:38:34 +0000
committerJames Barnett <noreply@jamesbarnett.xyz>2020-12-30 14:38:34 +0000
commit83b0b4cb19d7f0137cde962ee81a900baf2bd953 (patch)
tree838204167415de676190a1534767497f084e7a7b /src/main/kotlin/TextureManager.kt
parentad192fe7068081ed88f8616581bf450d601e99b1 (diff)
downloadkotlin-raycaster-83b0b4cb19d7f0137cde962ee81a900baf2bd953.tar.xz
kotlin-raycaster-83b0b4cb19d7f0137cde962ee81a900baf2bd953.zip
Add switchable texture sets. Fix minimap
Diffstat (limited to 'src/main/kotlin/TextureManager.kt')
-rw-r--r--src/main/kotlin/TextureManager.kt7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/main/kotlin/TextureManager.kt b/src/main/kotlin/TextureManager.kt
index 58005e9..7c5ab10 100644
--- a/src/main/kotlin/TextureManager.kt
+++ b/src/main/kotlin/TextureManager.kt
@@ -10,14 +10,15 @@ class TextureManager {
private lateinit var textures: List<Texture>
fun getTexture(id: Int): Texture {
- return textures.first { it.id == id }
+ return textures.find { it.id == id } ?: textures.first()
}
- fun loadTextures() {
+ fun loadTextures(set: String) {
textures = document.getElementsByClassName("texture-definition").asList()
.map { it as HTMLImageElement }
+ .filter { it.getAttribute("data-set") == set }
.map {
- val id = it.id.toInt()
+ val id = it.getAttribute("data-texture-id")!!.toInt()
val width = it.getAttribute("data-width")?.toInt() ?: 64
val height = it.getAttribute("data-height")?.toInt() ?: 64
Texture(id, width, height, parseImage(it, width, height))