diff --git a/src/com/persesgames/game/View.kt b/src/com/persesgames/game/View.kt index e5590e0..4ff5dcf 100644 --- a/src/com/persesgames/game/View.kt +++ b/src/com/persesgames/game/View.kt @@ -78,7 +78,7 @@ vMatrix.setOrthographicProjection(0f, width, 0f, height, near, far) } ViewType.PROJECTION -> { - vMatrix.setPerspectiveProjection(angle, aspectRatio, near, far); + vMatrix.setPerspectiveProjection(angle, aspectRatio, near, far) } else -> { throw IllegalStateException("ViewType $viewType not implemented!") diff --git a/src/com/persesgames/game/View.kt b/src/com/persesgames/game/View.kt index e5590e0..4ff5dcf 100644 --- a/src/com/persesgames/game/View.kt +++ b/src/com/persesgames/game/View.kt @@ -78,7 +78,7 @@ vMatrix.setOrthographicProjection(0f, width, 0f, height, near, far) } ViewType.PROJECTION -> { - vMatrix.setPerspectiveProjection(angle, aspectRatio, near, far); + vMatrix.setPerspectiveProjection(angle, aspectRatio, near, far) } else -> { throw IllegalStateException("ViewType $viewType not implemented!") diff --git a/src/com/persesgames/input/Keys.kt b/src/com/persesgames/input/Keys.kt index 6705c67..c5be758 100644 --- a/src/com/persesgames/input/Keys.kt +++ b/src/com/persesgames/input/Keys.kt @@ -4,7 +4,6 @@ import org.w3c.dom.events.Event import org.w3c.dom.events.KeyboardEvent import org.w3c.dom.events.MouseEvent -import java.util.* import kotlin.browser.document import kotlin.dom.on @@ -37,24 +36,19 @@ } open class EmptyInputProcessor : InputProcessor { - override fun pointerClick(pointer: Int, x: Float, y: Float) { - } - override fun keyDown(keyCode: Int) { - } + override fun pointerClick(pointer: Int, x: Float, y: Float) { } - override fun keyPressed(charCode: Int) { - } + override fun keyDown(keyCode: Int) { } - override fun keyUp(keyCode: Int) { - } + override fun keyPressed(charCode: Int) { } - + override fun keyUp(keyCode: Int) { } } object Keys { - private val keys: MutableMap = HashMap(); + private val keys: MutableMap = HashMap() private var inputProcesser: InputProcessor = EmptyInputProcessor() init { diff --git a/src/com/persesgames/game/View.kt b/src/com/persesgames/game/View.kt index e5590e0..4ff5dcf 100644 --- a/src/com/persesgames/game/View.kt +++ b/src/com/persesgames/game/View.kt @@ -78,7 +78,7 @@ vMatrix.setOrthographicProjection(0f, width, 0f, height, near, far) } ViewType.PROJECTION -> { - vMatrix.setPerspectiveProjection(angle, aspectRatio, near, far); + vMatrix.setPerspectiveProjection(angle, aspectRatio, near, far) } else -> { throw IllegalStateException("ViewType $viewType not implemented!") diff --git a/src/com/persesgames/input/Keys.kt b/src/com/persesgames/input/Keys.kt index 6705c67..c5be758 100644 --- a/src/com/persesgames/input/Keys.kt +++ b/src/com/persesgames/input/Keys.kt @@ -4,7 +4,6 @@ import org.w3c.dom.events.Event import org.w3c.dom.events.KeyboardEvent import org.w3c.dom.events.MouseEvent -import java.util.* import kotlin.browser.document import kotlin.dom.on @@ -37,24 +36,19 @@ } open class EmptyInputProcessor : InputProcessor { - override fun pointerClick(pointer: Int, x: Float, y: Float) { - } - override fun keyDown(keyCode: Int) { - } + override fun pointerClick(pointer: Int, x: Float, y: Float) { } - override fun keyPressed(charCode: Int) { - } + override fun keyDown(keyCode: Int) { } - override fun keyUp(keyCode: Int) { - } + override fun keyPressed(charCode: Int) { } - + override fun keyUp(keyCode: Int) { } } object Keys { - private val keys: MutableMap = HashMap(); + private val keys: MutableMap = HashMap() private var inputProcesser: InputProcessor = EmptyInputProcessor() init { diff --git a/src/com/persesgames/map/tiled/TiledMap.kt b/src/com/persesgames/map/tiled/TiledMap.kt index a84a5a3..487f565 100644 --- a/src/com/persesgames/map/tiled/TiledMap.kt +++ b/src/com/persesgames/map/tiled/TiledMap.kt @@ -3,7 +3,6 @@ import com.persesgames.net.getUrlAsString import com.persesgames.texture.Texture import com.persesgames.texture.Textures -import java.util.* import kotlin.browser.window /** diff --git a/src/com/persesgames/game/View.kt b/src/com/persesgames/game/View.kt index e5590e0..4ff5dcf 100644 --- a/src/com/persesgames/game/View.kt +++ b/src/com/persesgames/game/View.kt @@ -78,7 +78,7 @@ vMatrix.setOrthographicProjection(0f, width, 0f, height, near, far) } ViewType.PROJECTION -> { - vMatrix.setPerspectiveProjection(angle, aspectRatio, near, far); + vMatrix.setPerspectiveProjection(angle, aspectRatio, near, far) } else -> { throw IllegalStateException("ViewType $viewType not implemented!") diff --git a/src/com/persesgames/input/Keys.kt b/src/com/persesgames/input/Keys.kt index 6705c67..c5be758 100644 --- a/src/com/persesgames/input/Keys.kt +++ b/src/com/persesgames/input/Keys.kt @@ -4,7 +4,6 @@ import org.w3c.dom.events.Event import org.w3c.dom.events.KeyboardEvent import org.w3c.dom.events.MouseEvent -import java.util.* import kotlin.browser.document import kotlin.dom.on @@ -37,24 +36,19 @@ } open class EmptyInputProcessor : InputProcessor { - override fun pointerClick(pointer: Int, x: Float, y: Float) { - } - override fun keyDown(keyCode: Int) { - } + override fun pointerClick(pointer: Int, x: Float, y: Float) { } - override fun keyPressed(charCode: Int) { - } + override fun keyDown(keyCode: Int) { } - override fun keyUp(keyCode: Int) { - } + override fun keyPressed(charCode: Int) { } - + override fun keyUp(keyCode: Int) { } } object Keys { - private val keys: MutableMap = HashMap(); + private val keys: MutableMap = HashMap() private var inputProcesser: InputProcessor = EmptyInputProcessor() init { diff --git a/src/com/persesgames/map/tiled/TiledMap.kt b/src/com/persesgames/map/tiled/TiledMap.kt index a84a5a3..487f565 100644 --- a/src/com/persesgames/map/tiled/TiledMap.kt +++ b/src/com/persesgames/map/tiled/TiledMap.kt @@ -3,7 +3,6 @@ import com.persesgames.net.getUrlAsString import com.persesgames.texture.Texture import com.persesgames.texture.Textures -import java.util.* import kotlin.browser.window /** diff --git a/src/com/persesgames/shader/ShaderProgram.kt b/src/com/persesgames/shader/ShaderProgram.kt index 3c3aad5..43da2ad 100644 --- a/src/com/persesgames/shader/ShaderProgram.kt +++ b/src/com/persesgames/shader/ShaderProgram.kt @@ -39,15 +39,15 @@ webgl.useProgram(shaderProgram) - this.verticesBlockSize = 0; + this.verticesBlockSize = 0 // set attribute locations... for (info in vainfo.iterator()) { info.location = webgl.getAttribLocation(shaderProgram, info.locationName) - info.offset = verticesBlockSize; + info.offset = verticesBlockSize - verticesBlockSize += info.numElements; - println("attrib: ${info.locationName}, info.location: ${info.location}, info.offset: ${info.offset}"); + verticesBlockSize += info.numElements + //println("attrib: ${info.locationName}, info.location: ${info.location}, info.offset: ${info.offset}") } when(drawType) { @@ -59,15 +59,14 @@ } } - println("verticesBlockSize $verticesBlockSize"); + //println("verticesBlockSize $verticesBlockSize") - println("ShaderProgram constructor done"); + //println("ShaderProgram constructor done") } private fun compileShader(source: String, type: Int): WebGLShader { - val result: WebGLShader + val result: WebGLShader = webgl.createShader(type) ?: throw IllegalStateException("Unable to request shader from webgl context!") - result = webgl.createShader(type) ?: throw IllegalStateException("Unable to request shader from webgl context!") webgl.shaderSource(result, source) webgl.compileShader(result) diff --git a/src/com/persesgames/game/View.kt b/src/com/persesgames/game/View.kt index e5590e0..4ff5dcf 100644 --- a/src/com/persesgames/game/View.kt +++ b/src/com/persesgames/game/View.kt @@ -78,7 +78,7 @@ vMatrix.setOrthographicProjection(0f, width, 0f, height, near, far) } ViewType.PROJECTION -> { - vMatrix.setPerspectiveProjection(angle, aspectRatio, near, far); + vMatrix.setPerspectiveProjection(angle, aspectRatio, near, far) } else -> { throw IllegalStateException("ViewType $viewType not implemented!") diff --git a/src/com/persesgames/input/Keys.kt b/src/com/persesgames/input/Keys.kt index 6705c67..c5be758 100644 --- a/src/com/persesgames/input/Keys.kt +++ b/src/com/persesgames/input/Keys.kt @@ -4,7 +4,6 @@ import org.w3c.dom.events.Event import org.w3c.dom.events.KeyboardEvent import org.w3c.dom.events.MouseEvent -import java.util.* import kotlin.browser.document import kotlin.dom.on @@ -37,24 +36,19 @@ } open class EmptyInputProcessor : InputProcessor { - override fun pointerClick(pointer: Int, x: Float, y: Float) { - } - override fun keyDown(keyCode: Int) { - } + override fun pointerClick(pointer: Int, x: Float, y: Float) { } - override fun keyPressed(charCode: Int) { - } + override fun keyDown(keyCode: Int) { } - override fun keyUp(keyCode: Int) { - } + override fun keyPressed(charCode: Int) { } - + override fun keyUp(keyCode: Int) { } } object Keys { - private val keys: MutableMap = HashMap(); + private val keys: MutableMap = HashMap() private var inputProcesser: InputProcessor = EmptyInputProcessor() init { diff --git a/src/com/persesgames/map/tiled/TiledMap.kt b/src/com/persesgames/map/tiled/TiledMap.kt index a84a5a3..487f565 100644 --- a/src/com/persesgames/map/tiled/TiledMap.kt +++ b/src/com/persesgames/map/tiled/TiledMap.kt @@ -3,7 +3,6 @@ import com.persesgames.net.getUrlAsString import com.persesgames.texture.Texture import com.persesgames.texture.Textures -import java.util.* import kotlin.browser.window /** diff --git a/src/com/persesgames/shader/ShaderProgram.kt b/src/com/persesgames/shader/ShaderProgram.kt index 3c3aad5..43da2ad 100644 --- a/src/com/persesgames/shader/ShaderProgram.kt +++ b/src/com/persesgames/shader/ShaderProgram.kt @@ -39,15 +39,15 @@ webgl.useProgram(shaderProgram) - this.verticesBlockSize = 0; + this.verticesBlockSize = 0 // set attribute locations... for (info in vainfo.iterator()) { info.location = webgl.getAttribLocation(shaderProgram, info.locationName) - info.offset = verticesBlockSize; + info.offset = verticesBlockSize - verticesBlockSize += info.numElements; - println("attrib: ${info.locationName}, info.location: ${info.location}, info.offset: ${info.offset}"); + verticesBlockSize += info.numElements + //println("attrib: ${info.locationName}, info.location: ${info.location}, info.offset: ${info.offset}") } when(drawType) { @@ -59,15 +59,14 @@ } } - println("verticesBlockSize $verticesBlockSize"); + //println("verticesBlockSize $verticesBlockSize") - println("ShaderProgram constructor done"); + //println("ShaderProgram constructor done") } private fun compileShader(source: String, type: Int): WebGLShader { - val result: WebGLShader + val result: WebGLShader = webgl.createShader(type) ?: throw IllegalStateException("Unable to request shader from webgl context!") - result = webgl.createShader(type) ?: throw IllegalStateException("Unable to request shader from webgl context!") webgl.shaderSource(result, source) webgl.compileShader(result) diff --git a/src/com/persesgames/shader/ShaderProgramMesh.kt b/src/com/persesgames/shader/ShaderProgramMesh.kt index f4c4dd5..8ecdba9 100644 --- a/src/com/persesgames/shader/ShaderProgramMesh.kt +++ b/src/com/persesgames/shader/ShaderProgramMesh.kt @@ -19,13 +19,12 @@ val shaderProgram: ShaderProgram ) { val webgl = shaderProgram.webgl - val data: Float32Array + val data: Float32Array = Float32Array(20000 - (20000 % shaderProgram.drawLength)) var currentIndex: Int = 0 val attribBuffer: WebGLBuffer var counter = 0 init { - data = Float32Array(20000 - (20000 % shaderProgram.drawLength)) attribBuffer = webgl.createBuffer() ?: throw IllegalStateException("Unable to create webgl buffer!") webgl.bindBuffer(WebGLRenderingContext.ARRAY_BUFFER, attribBuffer); @@ -52,9 +51,6 @@ fun render(userdata: T) { counter++ if (currentIndex > 0) { -/* if (counter % 100 == 0) { - println("currentIndex=$currentIndex blockSize=${shaderProgram.verticesBlockSize} drawLength=${shaderProgram.drawLength} drawing=${(currentIndex / shaderProgram.verticesBlockSize).toInt()}") - }*/ if (currentIndex % shaderProgram.verticesBlockSize != 0) { throw IllegalStateException("Number of vertices not a multiple of the attribute block size!") } diff --git a/src/com/persesgames/game/View.kt b/src/com/persesgames/game/View.kt index e5590e0..4ff5dcf 100644 --- a/src/com/persesgames/game/View.kt +++ b/src/com/persesgames/game/View.kt @@ -78,7 +78,7 @@ vMatrix.setOrthographicProjection(0f, width, 0f, height, near, far) } ViewType.PROJECTION -> { - vMatrix.setPerspectiveProjection(angle, aspectRatio, near, far); + vMatrix.setPerspectiveProjection(angle, aspectRatio, near, far) } else -> { throw IllegalStateException("ViewType $viewType not implemented!") diff --git a/src/com/persesgames/input/Keys.kt b/src/com/persesgames/input/Keys.kt index 6705c67..c5be758 100644 --- a/src/com/persesgames/input/Keys.kt +++ b/src/com/persesgames/input/Keys.kt @@ -4,7 +4,6 @@ import org.w3c.dom.events.Event import org.w3c.dom.events.KeyboardEvent import org.w3c.dom.events.MouseEvent -import java.util.* import kotlin.browser.document import kotlin.dom.on @@ -37,24 +36,19 @@ } open class EmptyInputProcessor : InputProcessor { - override fun pointerClick(pointer: Int, x: Float, y: Float) { - } - override fun keyDown(keyCode: Int) { - } + override fun pointerClick(pointer: Int, x: Float, y: Float) { } - override fun keyPressed(charCode: Int) { - } + override fun keyDown(keyCode: Int) { } - override fun keyUp(keyCode: Int) { - } + override fun keyPressed(charCode: Int) { } - + override fun keyUp(keyCode: Int) { } } object Keys { - private val keys: MutableMap = HashMap(); + private val keys: MutableMap = HashMap() private var inputProcesser: InputProcessor = EmptyInputProcessor() init { diff --git a/src/com/persesgames/map/tiled/TiledMap.kt b/src/com/persesgames/map/tiled/TiledMap.kt index a84a5a3..487f565 100644 --- a/src/com/persesgames/map/tiled/TiledMap.kt +++ b/src/com/persesgames/map/tiled/TiledMap.kt @@ -3,7 +3,6 @@ import com.persesgames.net.getUrlAsString import com.persesgames.texture.Texture import com.persesgames.texture.Textures -import java.util.* import kotlin.browser.window /** diff --git a/src/com/persesgames/shader/ShaderProgram.kt b/src/com/persesgames/shader/ShaderProgram.kt index 3c3aad5..43da2ad 100644 --- a/src/com/persesgames/shader/ShaderProgram.kt +++ b/src/com/persesgames/shader/ShaderProgram.kt @@ -39,15 +39,15 @@ webgl.useProgram(shaderProgram) - this.verticesBlockSize = 0; + this.verticesBlockSize = 0 // set attribute locations... for (info in vainfo.iterator()) { info.location = webgl.getAttribLocation(shaderProgram, info.locationName) - info.offset = verticesBlockSize; + info.offset = verticesBlockSize - verticesBlockSize += info.numElements; - println("attrib: ${info.locationName}, info.location: ${info.location}, info.offset: ${info.offset}"); + verticesBlockSize += info.numElements + //println("attrib: ${info.locationName}, info.location: ${info.location}, info.offset: ${info.offset}") } when(drawType) { @@ -59,15 +59,14 @@ } } - println("verticesBlockSize $verticesBlockSize"); + //println("verticesBlockSize $verticesBlockSize") - println("ShaderProgram constructor done"); + //println("ShaderProgram constructor done") } private fun compileShader(source: String, type: Int): WebGLShader { - val result: WebGLShader + val result: WebGLShader = webgl.createShader(type) ?: throw IllegalStateException("Unable to request shader from webgl context!") - result = webgl.createShader(type) ?: throw IllegalStateException("Unable to request shader from webgl context!") webgl.shaderSource(result, source) webgl.compileShader(result) diff --git a/src/com/persesgames/shader/ShaderProgramMesh.kt b/src/com/persesgames/shader/ShaderProgramMesh.kt index f4c4dd5..8ecdba9 100644 --- a/src/com/persesgames/shader/ShaderProgramMesh.kt +++ b/src/com/persesgames/shader/ShaderProgramMesh.kt @@ -19,13 +19,12 @@ val shaderProgram: ShaderProgram ) { val webgl = shaderProgram.webgl - val data: Float32Array + val data: Float32Array = Float32Array(20000 - (20000 % shaderProgram.drawLength)) var currentIndex: Int = 0 val attribBuffer: WebGLBuffer var counter = 0 init { - data = Float32Array(20000 - (20000 % shaderProgram.drawLength)) attribBuffer = webgl.createBuffer() ?: throw IllegalStateException("Unable to create webgl buffer!") webgl.bindBuffer(WebGLRenderingContext.ARRAY_BUFFER, attribBuffer); @@ -52,9 +51,6 @@ fun render(userdata: T) { counter++ if (currentIndex > 0) { -/* if (counter % 100 == 0) { - println("currentIndex=$currentIndex blockSize=${shaderProgram.verticesBlockSize} drawLength=${shaderProgram.drawLength} drawing=${(currentIndex / shaderProgram.verticesBlockSize).toInt()}") - }*/ if (currentIndex % shaderProgram.verticesBlockSize != 0) { throw IllegalStateException("Number of vertices not a multiple of the attribute block size!") } diff --git a/src/com/persesgames/sound/Music.kt b/src/com/persesgames/sound/Music.kt index 88a531d..9bce787 100644 --- a/src/com/persesgames/sound/Music.kt +++ b/src/com/persesgames/sound/Music.kt @@ -1,7 +1,6 @@ package com.persesgames.sound import org.w3c.dom.HTMLAudioElement -import java.util.* import kotlin.browser.document import kotlin.dom.on diff --git a/src/com/persesgames/game/View.kt b/src/com/persesgames/game/View.kt index e5590e0..4ff5dcf 100644 --- a/src/com/persesgames/game/View.kt +++ b/src/com/persesgames/game/View.kt @@ -78,7 +78,7 @@ vMatrix.setOrthographicProjection(0f, width, 0f, height, near, far) } ViewType.PROJECTION -> { - vMatrix.setPerspectiveProjection(angle, aspectRatio, near, far); + vMatrix.setPerspectiveProjection(angle, aspectRatio, near, far) } else -> { throw IllegalStateException("ViewType $viewType not implemented!") diff --git a/src/com/persesgames/input/Keys.kt b/src/com/persesgames/input/Keys.kt index 6705c67..c5be758 100644 --- a/src/com/persesgames/input/Keys.kt +++ b/src/com/persesgames/input/Keys.kt @@ -4,7 +4,6 @@ import org.w3c.dom.events.Event import org.w3c.dom.events.KeyboardEvent import org.w3c.dom.events.MouseEvent -import java.util.* import kotlin.browser.document import kotlin.dom.on @@ -37,24 +36,19 @@ } open class EmptyInputProcessor : InputProcessor { - override fun pointerClick(pointer: Int, x: Float, y: Float) { - } - override fun keyDown(keyCode: Int) { - } + override fun pointerClick(pointer: Int, x: Float, y: Float) { } - override fun keyPressed(charCode: Int) { - } + override fun keyDown(keyCode: Int) { } - override fun keyUp(keyCode: Int) { - } + override fun keyPressed(charCode: Int) { } - + override fun keyUp(keyCode: Int) { } } object Keys { - private val keys: MutableMap = HashMap(); + private val keys: MutableMap = HashMap() private var inputProcesser: InputProcessor = EmptyInputProcessor() init { diff --git a/src/com/persesgames/map/tiled/TiledMap.kt b/src/com/persesgames/map/tiled/TiledMap.kt index a84a5a3..487f565 100644 --- a/src/com/persesgames/map/tiled/TiledMap.kt +++ b/src/com/persesgames/map/tiled/TiledMap.kt @@ -3,7 +3,6 @@ import com.persesgames.net.getUrlAsString import com.persesgames.texture.Texture import com.persesgames.texture.Textures -import java.util.* import kotlin.browser.window /** diff --git a/src/com/persesgames/shader/ShaderProgram.kt b/src/com/persesgames/shader/ShaderProgram.kt index 3c3aad5..43da2ad 100644 --- a/src/com/persesgames/shader/ShaderProgram.kt +++ b/src/com/persesgames/shader/ShaderProgram.kt @@ -39,15 +39,15 @@ webgl.useProgram(shaderProgram) - this.verticesBlockSize = 0; + this.verticesBlockSize = 0 // set attribute locations... for (info in vainfo.iterator()) { info.location = webgl.getAttribLocation(shaderProgram, info.locationName) - info.offset = verticesBlockSize; + info.offset = verticesBlockSize - verticesBlockSize += info.numElements; - println("attrib: ${info.locationName}, info.location: ${info.location}, info.offset: ${info.offset}"); + verticesBlockSize += info.numElements + //println("attrib: ${info.locationName}, info.location: ${info.location}, info.offset: ${info.offset}") } when(drawType) { @@ -59,15 +59,14 @@ } } - println("verticesBlockSize $verticesBlockSize"); + //println("verticesBlockSize $verticesBlockSize") - println("ShaderProgram constructor done"); + //println("ShaderProgram constructor done") } private fun compileShader(source: String, type: Int): WebGLShader { - val result: WebGLShader + val result: WebGLShader = webgl.createShader(type) ?: throw IllegalStateException("Unable to request shader from webgl context!") - result = webgl.createShader(type) ?: throw IllegalStateException("Unable to request shader from webgl context!") webgl.shaderSource(result, source) webgl.compileShader(result) diff --git a/src/com/persesgames/shader/ShaderProgramMesh.kt b/src/com/persesgames/shader/ShaderProgramMesh.kt index f4c4dd5..8ecdba9 100644 --- a/src/com/persesgames/shader/ShaderProgramMesh.kt +++ b/src/com/persesgames/shader/ShaderProgramMesh.kt @@ -19,13 +19,12 @@ val shaderProgram: ShaderProgram ) { val webgl = shaderProgram.webgl - val data: Float32Array + val data: Float32Array = Float32Array(20000 - (20000 % shaderProgram.drawLength)) var currentIndex: Int = 0 val attribBuffer: WebGLBuffer var counter = 0 init { - data = Float32Array(20000 - (20000 % shaderProgram.drawLength)) attribBuffer = webgl.createBuffer() ?: throw IllegalStateException("Unable to create webgl buffer!") webgl.bindBuffer(WebGLRenderingContext.ARRAY_BUFFER, attribBuffer); @@ -52,9 +51,6 @@ fun render(userdata: T) { counter++ if (currentIndex > 0) { -/* if (counter % 100 == 0) { - println("currentIndex=$currentIndex blockSize=${shaderProgram.verticesBlockSize} drawLength=${shaderProgram.drawLength} drawing=${(currentIndex / shaderProgram.verticesBlockSize).toInt()}") - }*/ if (currentIndex % shaderProgram.verticesBlockSize != 0) { throw IllegalStateException("Number of vertices not a multiple of the attribute block size!") } diff --git a/src/com/persesgames/sound/Music.kt b/src/com/persesgames/sound/Music.kt index 88a531d..9bce787 100644 --- a/src/com/persesgames/sound/Music.kt +++ b/src/com/persesgames/sound/Music.kt @@ -1,7 +1,6 @@ package com.persesgames.sound import org.w3c.dom.HTMLAudioElement -import java.util.* import kotlin.browser.document import kotlin.dom.on diff --git a/src/com/persesgames/sound/Sounds.kt b/src/com/persesgames/sound/Sounds.kt index 8d8c549..a0a4df6 100644 --- a/src/com/persesgames/sound/Sounds.kt +++ b/src/com/persesgames/sound/Sounds.kt @@ -1,7 +1,6 @@ package com.persesgames.sound import org.w3c.dom.HTMLAudioElement -import java.util.* import kotlin.browser.document /** @@ -15,7 +14,7 @@ var nextChannel: Int = 0 init { - println("CREATING: $name") + //println("CREATING: $name") channels = Array(numberOfChannels, { document.createElement("audio") as HTMLAudioElement }) for (audio in channels) { @@ -27,7 +26,7 @@ } fun play() { - println("PLAYING: $name - $nextChannel") + //println("PLAYING: $name - $nextChannel") channels[nextChannel].currentTime = 0.0 channels[nextChannel].play() diff --git a/src/com/persesgames/game/View.kt b/src/com/persesgames/game/View.kt index e5590e0..4ff5dcf 100644 --- a/src/com/persesgames/game/View.kt +++ b/src/com/persesgames/game/View.kt @@ -78,7 +78,7 @@ vMatrix.setOrthographicProjection(0f, width, 0f, height, near, far) } ViewType.PROJECTION -> { - vMatrix.setPerspectiveProjection(angle, aspectRatio, near, far); + vMatrix.setPerspectiveProjection(angle, aspectRatio, near, far) } else -> { throw IllegalStateException("ViewType $viewType not implemented!") diff --git a/src/com/persesgames/input/Keys.kt b/src/com/persesgames/input/Keys.kt index 6705c67..c5be758 100644 --- a/src/com/persesgames/input/Keys.kt +++ b/src/com/persesgames/input/Keys.kt @@ -4,7 +4,6 @@ import org.w3c.dom.events.Event import org.w3c.dom.events.KeyboardEvent import org.w3c.dom.events.MouseEvent -import java.util.* import kotlin.browser.document import kotlin.dom.on @@ -37,24 +36,19 @@ } open class EmptyInputProcessor : InputProcessor { - override fun pointerClick(pointer: Int, x: Float, y: Float) { - } - override fun keyDown(keyCode: Int) { - } + override fun pointerClick(pointer: Int, x: Float, y: Float) { } - override fun keyPressed(charCode: Int) { - } + override fun keyDown(keyCode: Int) { } - override fun keyUp(keyCode: Int) { - } + override fun keyPressed(charCode: Int) { } - + override fun keyUp(keyCode: Int) { } } object Keys { - private val keys: MutableMap = HashMap(); + private val keys: MutableMap = HashMap() private var inputProcesser: InputProcessor = EmptyInputProcessor() init { diff --git a/src/com/persesgames/map/tiled/TiledMap.kt b/src/com/persesgames/map/tiled/TiledMap.kt index a84a5a3..487f565 100644 --- a/src/com/persesgames/map/tiled/TiledMap.kt +++ b/src/com/persesgames/map/tiled/TiledMap.kt @@ -3,7 +3,6 @@ import com.persesgames.net.getUrlAsString import com.persesgames.texture.Texture import com.persesgames.texture.Textures -import java.util.* import kotlin.browser.window /** diff --git a/src/com/persesgames/shader/ShaderProgram.kt b/src/com/persesgames/shader/ShaderProgram.kt index 3c3aad5..43da2ad 100644 --- a/src/com/persesgames/shader/ShaderProgram.kt +++ b/src/com/persesgames/shader/ShaderProgram.kt @@ -39,15 +39,15 @@ webgl.useProgram(shaderProgram) - this.verticesBlockSize = 0; + this.verticesBlockSize = 0 // set attribute locations... for (info in vainfo.iterator()) { info.location = webgl.getAttribLocation(shaderProgram, info.locationName) - info.offset = verticesBlockSize; + info.offset = verticesBlockSize - verticesBlockSize += info.numElements; - println("attrib: ${info.locationName}, info.location: ${info.location}, info.offset: ${info.offset}"); + verticesBlockSize += info.numElements + //println("attrib: ${info.locationName}, info.location: ${info.location}, info.offset: ${info.offset}") } when(drawType) { @@ -59,15 +59,14 @@ } } - println("verticesBlockSize $verticesBlockSize"); + //println("verticesBlockSize $verticesBlockSize") - println("ShaderProgram constructor done"); + //println("ShaderProgram constructor done") } private fun compileShader(source: String, type: Int): WebGLShader { - val result: WebGLShader + val result: WebGLShader = webgl.createShader(type) ?: throw IllegalStateException("Unable to request shader from webgl context!") - result = webgl.createShader(type) ?: throw IllegalStateException("Unable to request shader from webgl context!") webgl.shaderSource(result, source) webgl.compileShader(result) diff --git a/src/com/persesgames/shader/ShaderProgramMesh.kt b/src/com/persesgames/shader/ShaderProgramMesh.kt index f4c4dd5..8ecdba9 100644 --- a/src/com/persesgames/shader/ShaderProgramMesh.kt +++ b/src/com/persesgames/shader/ShaderProgramMesh.kt @@ -19,13 +19,12 @@ val shaderProgram: ShaderProgram ) { val webgl = shaderProgram.webgl - val data: Float32Array + val data: Float32Array = Float32Array(20000 - (20000 % shaderProgram.drawLength)) var currentIndex: Int = 0 val attribBuffer: WebGLBuffer var counter = 0 init { - data = Float32Array(20000 - (20000 % shaderProgram.drawLength)) attribBuffer = webgl.createBuffer() ?: throw IllegalStateException("Unable to create webgl buffer!") webgl.bindBuffer(WebGLRenderingContext.ARRAY_BUFFER, attribBuffer); @@ -52,9 +51,6 @@ fun render(userdata: T) { counter++ if (currentIndex > 0) { -/* if (counter % 100 == 0) { - println("currentIndex=$currentIndex blockSize=${shaderProgram.verticesBlockSize} drawLength=${shaderProgram.drawLength} drawing=${(currentIndex / shaderProgram.verticesBlockSize).toInt()}") - }*/ if (currentIndex % shaderProgram.verticesBlockSize != 0) { throw IllegalStateException("Number of vertices not a multiple of the attribute block size!") } diff --git a/src/com/persesgames/sound/Music.kt b/src/com/persesgames/sound/Music.kt index 88a531d..9bce787 100644 --- a/src/com/persesgames/sound/Music.kt +++ b/src/com/persesgames/sound/Music.kt @@ -1,7 +1,6 @@ package com.persesgames.sound import org.w3c.dom.HTMLAudioElement -import java.util.* import kotlin.browser.document import kotlin.dom.on diff --git a/src/com/persesgames/sound/Sounds.kt b/src/com/persesgames/sound/Sounds.kt index 8d8c549..a0a4df6 100644 --- a/src/com/persesgames/sound/Sounds.kt +++ b/src/com/persesgames/sound/Sounds.kt @@ -1,7 +1,6 @@ package com.persesgames.sound import org.w3c.dom.HTMLAudioElement -import java.util.* import kotlin.browser.document /** @@ -15,7 +14,7 @@ var nextChannel: Int = 0 init { - println("CREATING: $name") + //println("CREATING: $name") channels = Array(numberOfChannels, { document.createElement("audio") as HTMLAudioElement }) for (audio in channels) { @@ -27,7 +26,7 @@ } fun play() { - println("PLAYING: $name - $nextChannel") + //println("PLAYING: $name - $nextChannel") channels[nextChannel].currentTime = 0.0 channels[nextChannel].play() diff --git a/src/com/persesgames/texture/Textures.kt b/src/com/persesgames/texture/Textures.kt index 24840b6..b82db97 100644 --- a/src/com/persesgames/texture/Textures.kt +++ b/src/com/persesgames/texture/Textures.kt @@ -10,8 +10,6 @@ import org.khronos.webgl.WebGLRenderingContext import org.khronos.webgl.WebGLTexture import org.w3c.dom.HTMLImageElement -import org.w3c.fetch.Request -import java.util.* import kotlin.browser.document /** @@ -161,9 +159,6 @@ init { val setter = { program: ShaderProgram, data: TextureData -> - //program.webgl.activeTexture(WebGLRenderingContext.TEXTURE0); - //program.webgl.bindTexture(WebGLRenderingContext.TEXTURE_2D, data.texture); - program.setUniform1i("u_sampler", 0) program.setUniformMatrix4fv("u_projectionView", Game.view.vMatrix.getFloat32Array()) }