From 29e52544d389f88a4af836ae1d82b838ed7a10c7 Mon Sep 17 00:00:00 2001 From: James Barnett Date: Thu, 31 Dec 2020 14:23:45 +0000 Subject: Fix texture loading. Add log overlay --- src/main/kotlin/Logger.kt | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 src/main/kotlin/Logger.kt (limited to 'src/main/kotlin/Logger.kt') diff --git a/src/main/kotlin/Logger.kt b/src/main/kotlin/Logger.kt new file mode 100644 index 0000000..a9b30c5 --- /dev/null +++ b/src/main/kotlin/Logger.kt @@ -0,0 +1,22 @@ +import kotlinx.browser.document +import org.w3c.dom.HTMLElement + +object Logger { + private val logMessage = document.getElementById("log-message") as HTMLElement + private val logPosition = document.getElementById("log-position") as HTMLElement + + fun log(message: String) { + logMessage.textContent = message + console.log(message) + } + + fun logPosition(camera: Camera) { + with(camera) { + var normalisedRotation = rotation % 360 + if(normalisedRotation < 0) normalisedRotation += 360 + logPosition.textContent = "x: ${xPos.toRoundedString()} y: ${yPos.toRoundedString()} rotation: $normalisedRotation" + } + } + + +} \ No newline at end of file -- cgit v1.2.3