From 83b0b4cb19d7f0137cde962ee81a900baf2bd953 Mon Sep 17 00:00:00 2001 From: James Barnett Date: Wed, 30 Dec 2020 14:38:34 +0000 Subject: Add switchable texture sets. Fix minimap --- src/main/kotlin/Minimap.kt | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'src/main/kotlin/Minimap.kt') diff --git a/src/main/kotlin/Minimap.kt b/src/main/kotlin/Minimap.kt index eb762ab..34862e0 100644 --- a/src/main/kotlin/Minimap.kt +++ b/src/main/kotlin/Minimap.kt @@ -3,15 +3,13 @@ import org.w3c.dom.CanvasRenderingContext2D import org.w3c.dom.HTMLCanvasElement class Minimap(private val map: Map) { - private val scale = 30 + private val scale = 20 private val canvas = (document.createElement("canvas") as HTMLCanvasElement) .apply { width = map.width * scale height = map.height * scale id = "minimap" - style.width = "${width}px" - style.height = "${height}px" } private val context = canvas.getContext("2d") as CanvasRenderingContext2D @@ -21,7 +19,7 @@ class Minimap(private val map: Map) { private fun drawMap() { for (y in 0 until map.height) { - for (x in 0 until map.height) { + for (x in 0 until map.width) { val wall = map.data[y][x] if (wall > 0) { context.fillStyle = "#000000" @@ -35,15 +33,15 @@ class Minimap(private val map: Map) { context.clearRect(0.0, 0.0, (map.width * scale).toDouble(), (map.height * scale).toDouble()) drawMap() context.fillStyle = "#FF0000" - context.fillRect(camera.xPos * scale, camera.yPos * scale, scale.toDouble(), scale.toDouble()) + context.fillRect((camera.xPos * scale)-5, (camera.yPos * scale)-5, 10.0, 10.0) context.strokeStyle = "#00FF00" context.lineWidth = 2.0 context.beginPath() context.moveTo(camera.xPos * scale, camera.yPos * scale) - val cameraCos = kotlin.math.cos(toRadians(camera.rotation)) * 4 - val cameraSin = kotlin.math.sin(toRadians(camera.rotation)) * 4 + val cameraCos = kotlin.math.cos(toRadians(camera.rotation)) + val cameraSin = kotlin.math.sin(toRadians(camera.rotation)) val dirX = camera.xPos + cameraCos val dirY = camera.yPos + cameraSin -- cgit v1.2.3