diff options
| author | James Barnett <noreply@jamesbarnett.xyz> | 2020-12-30 14:38:34 +0000 |
|---|---|---|
| committer | James Barnett <noreply@jamesbarnett.xyz> | 2020-12-30 14:38:34 +0000 |
| commit | 83b0b4cb19d7f0137cde962ee81a900baf2bd953 (patch) | |
| tree | 838204167415de676190a1534767497f084e7a7b /src/main/kotlin/TextureManager.kt | |
| parent | ad192fe7068081ed88f8616581bf450d601e99b1 (diff) | |
| download | kotlin-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.kt | 7 |
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)) |