diff --git a/.idea/modules/kudens.iml b/.idea/modules/kudens.iml index 9f69bde..69d95ba 100644 --- a/.idea/modules/kudens.iml +++ b/.idea/modules/kudens.iml @@ -1,5 +1,5 @@ - + diff --git a/.idea/modules/kudens.iml b/.idea/modules/kudens.iml index 9f69bde..69d95ba 100644 --- a/.idea/modules/kudens.iml +++ b/.idea/modules/kudens.iml @@ -1,5 +1,5 @@ - + diff --git a/.idea/modules/kudens_main.iml b/.idea/modules/kudens_main.iml index 0cb94fb..43c8cb1 100644 --- a/.idea/modules/kudens_main.iml +++ b/.idea/modules/kudens_main.iml @@ -1,5 +1,5 @@ - + diff --git a/.idea/modules/kudens.iml b/.idea/modules/kudens.iml index 9f69bde..69d95ba 100644 --- a/.idea/modules/kudens.iml +++ b/.idea/modules/kudens.iml @@ -1,5 +1,5 @@ - + diff --git a/.idea/modules/kudens_main.iml b/.idea/modules/kudens_main.iml index 0cb94fb..43c8cb1 100644 --- a/.idea/modules/kudens_main.iml +++ b/.idea/modules/kudens_main.iml @@ -1,5 +1,5 @@ - + diff --git a/.idea/modules/kudens_test.iml b/.idea/modules/kudens_test.iml index 63591a0..ddfb4f2 100644 --- a/.idea/modules/kudens_test.iml +++ b/.idea/modules/kudens_test.iml @@ -1,5 +1,5 @@ - + diff --git a/.idea/modules/kudens.iml b/.idea/modules/kudens.iml index 9f69bde..69d95ba 100644 --- a/.idea/modules/kudens.iml +++ b/.idea/modules/kudens.iml @@ -1,5 +1,5 @@ - + diff --git a/.idea/modules/kudens_main.iml b/.idea/modules/kudens_main.iml index 0cb94fb..43c8cb1 100644 --- a/.idea/modules/kudens_main.iml +++ b/.idea/modules/kudens_main.iml @@ -1,5 +1,5 @@ - + diff --git a/.idea/modules/kudens_test.iml b/.idea/modules/kudens_test.iml index 63591a0..ddfb4f2 100644 --- a/.idea/modules/kudens_test.iml +++ b/.idea/modules/kudens_test.iml @@ -1,5 +1,5 @@ - + diff --git a/build.gradle b/build.gradle index 99768dd..961e692 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,5 @@ group 'perses.games' -version '1.1.0-SNAPSHOT' +version '1.0.2-SNAPSHOT' apply plugin: 'kotlin2js' apply plugin: 'idea' diff --git a/.idea/modules/kudens.iml b/.idea/modules/kudens.iml index 9f69bde..69d95ba 100644 --- a/.idea/modules/kudens.iml +++ b/.idea/modules/kudens.iml @@ -1,5 +1,5 @@ - + diff --git a/.idea/modules/kudens_main.iml b/.idea/modules/kudens_main.iml index 0cb94fb..43c8cb1 100644 --- a/.idea/modules/kudens_main.iml +++ b/.idea/modules/kudens_main.iml @@ -1,5 +1,5 @@ - + diff --git a/.idea/modules/kudens_test.iml b/.idea/modules/kudens_test.iml index 63591a0..ddfb4f2 100644 --- a/.idea/modules/kudens_test.iml +++ b/.idea/modules/kudens_test.iml @@ -1,5 +1,5 @@ - + diff --git a/build.gradle b/build.gradle index 99768dd..961e692 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,5 @@ group 'perses.games' -version '1.1.0-SNAPSHOT' +version '1.0.2-SNAPSHOT' apply plugin: 'kotlin2js' apply plugin: 'idea' diff --git a/src/main/kotlin/games/perses/game/Game.kt b/src/main/kotlin/games/perses/game/Game.kt index a3391ec..a8d0578 100644 --- a/src/main/kotlin/games/perses/game/Game.kt +++ b/src/main/kotlin/games/perses/game/Game.kt @@ -84,6 +84,9 @@ var fpsCount = 0 var fpsCountTime = 0f + var borderLeft = 0 + var borderTop = 0 + fun gl() = html.webgl fun resize() { @@ -113,11 +116,11 @@ gl().viewport(0, 0, view.width.toInt(), view.height.toInt()) - val left = (windowWidth - view.windowWidth) / 2 - val top = (windowHeight - view.windowHeight) / 2 + borderLeft = (windowWidth - view.windowWidth) / 2 + borderTop = (windowHeight - view.windowHeight) / 2 - canvas.setAttribute("style", "position: absolute; left: ${left}px; top: ${top}px; z-index: 5; width: ${view.windowWidth}px; height: ${view.windowHeight}px;" ) - textCanvas.setAttribute("style", "position: absolute; left: ${left}px; top: ${top}px; z-index: 10; width: ${view.windowWidth}px; height: ${view.windowHeight}px;" ) + canvas.setAttribute("style", "position: absolute; left: ${borderLeft}px; top: ${borderTop}px; z-index: 5; width: ${view.windowWidth}px; height: ${view.windowHeight}px;" ) + textCanvas.setAttribute("style", "position: absolute; left: ${borderLeft}px; top: ${borderTop}px; z-index: 10; width: ${view.windowWidth}px; height: ${view.windowHeight}px;" ) } } @@ -134,7 +137,7 @@ } fun setScreen(screen: Screen) { - currentScreen.closeResources() + currentScreen.unloadResources() currentScreen = screen diff --git a/.idea/modules/kudens.iml b/.idea/modules/kudens.iml index 9f69bde..69d95ba 100644 --- a/.idea/modules/kudens.iml +++ b/.idea/modules/kudens.iml @@ -1,5 +1,5 @@ - + diff --git a/.idea/modules/kudens_main.iml b/.idea/modules/kudens_main.iml index 0cb94fb..43c8cb1 100644 --- a/.idea/modules/kudens_main.iml +++ b/.idea/modules/kudens_main.iml @@ -1,5 +1,5 @@ - + diff --git a/.idea/modules/kudens_test.iml b/.idea/modules/kudens_test.iml index 63591a0..ddfb4f2 100644 --- a/.idea/modules/kudens_test.iml +++ b/.idea/modules/kudens_test.iml @@ -1,5 +1,5 @@ - + diff --git a/build.gradle b/build.gradle index 99768dd..961e692 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,5 @@ group 'perses.games' -version '1.1.0-SNAPSHOT' +version '1.0.2-SNAPSHOT' apply plugin: 'kotlin2js' apply plugin: 'idea' diff --git a/src/main/kotlin/games/perses/game/Game.kt b/src/main/kotlin/games/perses/game/Game.kt index a3391ec..a8d0578 100644 --- a/src/main/kotlin/games/perses/game/Game.kt +++ b/src/main/kotlin/games/perses/game/Game.kt @@ -84,6 +84,9 @@ var fpsCount = 0 var fpsCountTime = 0f + var borderLeft = 0 + var borderTop = 0 + fun gl() = html.webgl fun resize() { @@ -113,11 +116,11 @@ gl().viewport(0, 0, view.width.toInt(), view.height.toInt()) - val left = (windowWidth - view.windowWidth) / 2 - val top = (windowHeight - view.windowHeight) / 2 + borderLeft = (windowWidth - view.windowWidth) / 2 + borderTop = (windowHeight - view.windowHeight) / 2 - canvas.setAttribute("style", "position: absolute; left: ${left}px; top: ${top}px; z-index: 5; width: ${view.windowWidth}px; height: ${view.windowHeight}px;" ) - textCanvas.setAttribute("style", "position: absolute; left: ${left}px; top: ${top}px; z-index: 10; width: ${view.windowWidth}px; height: ${view.windowHeight}px;" ) + canvas.setAttribute("style", "position: absolute; left: ${borderLeft}px; top: ${borderTop}px; z-index: 5; width: ${view.windowWidth}px; height: ${view.windowHeight}px;" ) + textCanvas.setAttribute("style", "position: absolute; left: ${borderLeft}px; top: ${borderTop}px; z-index: 10; width: ${view.windowWidth}px; height: ${view.windowHeight}px;" ) } } @@ -134,7 +137,7 @@ } fun setScreen(screen: Screen) { - currentScreen.closeResources() + currentScreen.unloadResources() currentScreen = screen diff --git a/src/main/kotlin/games/perses/game/Screen.kt b/src/main/kotlin/games/perses/game/Screen.kt index 6dc3525..10b6eae 100644 --- a/src/main/kotlin/games/perses/game/Screen.kt +++ b/src/main/kotlin/games/perses/game/Screen.kt @@ -10,7 +10,15 @@ open fun loadResources() {} - open fun closeResources() {} + @Deprecated( + message = "replace with unloadResources", + replaceWith = ReplaceWith("unloadResources()") + ) + open fun closeResources() { + unloadResources() + } + + open fun unloadResources() {} abstract fun update(time: Float, delta: Float) diff --git a/.idea/modules/kudens.iml b/.idea/modules/kudens.iml index 9f69bde..69d95ba 100644 --- a/.idea/modules/kudens.iml +++ b/.idea/modules/kudens.iml @@ -1,5 +1,5 @@ - + diff --git a/.idea/modules/kudens_main.iml b/.idea/modules/kudens_main.iml index 0cb94fb..43c8cb1 100644 --- a/.idea/modules/kudens_main.iml +++ b/.idea/modules/kudens_main.iml @@ -1,5 +1,5 @@ - + diff --git a/.idea/modules/kudens_test.iml b/.idea/modules/kudens_test.iml index 63591a0..ddfb4f2 100644 --- a/.idea/modules/kudens_test.iml +++ b/.idea/modules/kudens_test.iml @@ -1,5 +1,5 @@ - + diff --git a/build.gradle b/build.gradle index 99768dd..961e692 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,5 @@ group 'perses.games' -version '1.1.0-SNAPSHOT' +version '1.0.2-SNAPSHOT' apply plugin: 'kotlin2js' apply plugin: 'idea' diff --git a/src/main/kotlin/games/perses/game/Game.kt b/src/main/kotlin/games/perses/game/Game.kt index a3391ec..a8d0578 100644 --- a/src/main/kotlin/games/perses/game/Game.kt +++ b/src/main/kotlin/games/perses/game/Game.kt @@ -84,6 +84,9 @@ var fpsCount = 0 var fpsCountTime = 0f + var borderLeft = 0 + var borderTop = 0 + fun gl() = html.webgl fun resize() { @@ -113,11 +116,11 @@ gl().viewport(0, 0, view.width.toInt(), view.height.toInt()) - val left = (windowWidth - view.windowWidth) / 2 - val top = (windowHeight - view.windowHeight) / 2 + borderLeft = (windowWidth - view.windowWidth) / 2 + borderTop = (windowHeight - view.windowHeight) / 2 - canvas.setAttribute("style", "position: absolute; left: ${left}px; top: ${top}px; z-index: 5; width: ${view.windowWidth}px; height: ${view.windowHeight}px;" ) - textCanvas.setAttribute("style", "position: absolute; left: ${left}px; top: ${top}px; z-index: 10; width: ${view.windowWidth}px; height: ${view.windowHeight}px;" ) + canvas.setAttribute("style", "position: absolute; left: ${borderLeft}px; top: ${borderTop}px; z-index: 5; width: ${view.windowWidth}px; height: ${view.windowHeight}px;" ) + textCanvas.setAttribute("style", "position: absolute; left: ${borderLeft}px; top: ${borderTop}px; z-index: 10; width: ${view.windowWidth}px; height: ${view.windowHeight}px;" ) } } @@ -134,7 +137,7 @@ } fun setScreen(screen: Screen) { - currentScreen.closeResources() + currentScreen.unloadResources() currentScreen = screen diff --git a/src/main/kotlin/games/perses/game/Screen.kt b/src/main/kotlin/games/perses/game/Screen.kt index 6dc3525..10b6eae 100644 --- a/src/main/kotlin/games/perses/game/Screen.kt +++ b/src/main/kotlin/games/perses/game/Screen.kt @@ -10,7 +10,15 @@ open fun loadResources() {} - open fun closeResources() {} + @Deprecated( + message = "replace with unloadResources", + replaceWith = ReplaceWith("unloadResources()") + ) + open fun closeResources() { + unloadResources() + } + + open fun unloadResources() {} abstract fun update(time: Float, delta: Float) diff --git a/src/main/kotlin/games/perses/game/View.kt b/src/main/kotlin/games/perses/game/View.kt index b51342b..776140c 100644 --- a/src/main/kotlin/games/perses/game/View.kt +++ b/src/main/kotlin/games/perses/game/View.kt @@ -85,7 +85,7 @@ } } - //println("width: $width, height: $height") + println("width: $width, height: $height") } fun screenToGameCoordX(screenX: Float): Float { @@ -95,11 +95,8 @@ ViewType.ABSOLUTE -> { // nop } - ViewType.WIDTH -> { - result = (screenX / windowWidth * width) - width / 2 - } - ViewType.HEIGHT -> { - result = (screenX / windowWidth * width) - width / 2 + ViewType.WIDTH, ViewType.HEIGHT -> { + result = ( (screenX - Game.borderLeft) * width / windowWidth ) } ViewType.PROJECTION -> { // uhm @@ -119,11 +116,8 @@ ViewType.ABSOLUTE -> { // nop } - ViewType.WIDTH -> { - result = -((screenY / windowHeight * height) - height / 2) - } - ViewType.HEIGHT -> { - result = -((screenY / windowHeight * height) - height / 2) + ViewType.WIDTH, ViewType.HEIGHT -> { + result = height - ( (screenY - Game.borderTop) * height / windowHeight ) } ViewType.PROJECTION -> { // uhm @@ -144,11 +138,8 @@ ViewType.ABSOLUTE -> { // nop } - ViewType.WIDTH -> { - result = (windowWidth / width * normalizedX) - } - ViewType.HEIGHT -> { - result = (windowWidth / width * normalizedX) + ViewType.WIDTH, ViewType.HEIGHT -> { + result = ( gameX / width * windowWidth ) + Game.borderLeft } ViewType.PROJECTION -> { // uhm @@ -169,11 +160,8 @@ ViewType.ABSOLUTE -> { // nop } - ViewType.WIDTH -> { - result = windowHeight - (windowHeight / height * normalizedY) - } - ViewType.HEIGHT -> { - result = windowHeight - (windowHeight / height * normalizedY) + ViewType.WIDTH, ViewType.HEIGHT -> { + result = height - ( gameY / height * windowHeight ) + Game.borderTop } ViewType.PROJECTION -> { // uhm diff --git a/.idea/modules/kudens.iml b/.idea/modules/kudens.iml index 9f69bde..69d95ba 100644 --- a/.idea/modules/kudens.iml +++ b/.idea/modules/kudens.iml @@ -1,5 +1,5 @@ - + diff --git a/.idea/modules/kudens_main.iml b/.idea/modules/kudens_main.iml index 0cb94fb..43c8cb1 100644 --- a/.idea/modules/kudens_main.iml +++ b/.idea/modules/kudens_main.iml @@ -1,5 +1,5 @@ - + diff --git a/.idea/modules/kudens_test.iml b/.idea/modules/kudens_test.iml index 63591a0..ddfb4f2 100644 --- a/.idea/modules/kudens_test.iml +++ b/.idea/modules/kudens_test.iml @@ -1,5 +1,5 @@ - + diff --git a/build.gradle b/build.gradle index 99768dd..961e692 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,5 @@ group 'perses.games' -version '1.1.0-SNAPSHOT' +version '1.0.2-SNAPSHOT' apply plugin: 'kotlin2js' apply plugin: 'idea' diff --git a/src/main/kotlin/games/perses/game/Game.kt b/src/main/kotlin/games/perses/game/Game.kt index a3391ec..a8d0578 100644 --- a/src/main/kotlin/games/perses/game/Game.kt +++ b/src/main/kotlin/games/perses/game/Game.kt @@ -84,6 +84,9 @@ var fpsCount = 0 var fpsCountTime = 0f + var borderLeft = 0 + var borderTop = 0 + fun gl() = html.webgl fun resize() { @@ -113,11 +116,11 @@ gl().viewport(0, 0, view.width.toInt(), view.height.toInt()) - val left = (windowWidth - view.windowWidth) / 2 - val top = (windowHeight - view.windowHeight) / 2 + borderLeft = (windowWidth - view.windowWidth) / 2 + borderTop = (windowHeight - view.windowHeight) / 2 - canvas.setAttribute("style", "position: absolute; left: ${left}px; top: ${top}px; z-index: 5; width: ${view.windowWidth}px; height: ${view.windowHeight}px;" ) - textCanvas.setAttribute("style", "position: absolute; left: ${left}px; top: ${top}px; z-index: 10; width: ${view.windowWidth}px; height: ${view.windowHeight}px;" ) + canvas.setAttribute("style", "position: absolute; left: ${borderLeft}px; top: ${borderTop}px; z-index: 5; width: ${view.windowWidth}px; height: ${view.windowHeight}px;" ) + textCanvas.setAttribute("style", "position: absolute; left: ${borderLeft}px; top: ${borderTop}px; z-index: 10; width: ${view.windowWidth}px; height: ${view.windowHeight}px;" ) } } @@ -134,7 +137,7 @@ } fun setScreen(screen: Screen) { - currentScreen.closeResources() + currentScreen.unloadResources() currentScreen = screen diff --git a/src/main/kotlin/games/perses/game/Screen.kt b/src/main/kotlin/games/perses/game/Screen.kt index 6dc3525..10b6eae 100644 --- a/src/main/kotlin/games/perses/game/Screen.kt +++ b/src/main/kotlin/games/perses/game/Screen.kt @@ -10,7 +10,15 @@ open fun loadResources() {} - open fun closeResources() {} + @Deprecated( + message = "replace with unloadResources", + replaceWith = ReplaceWith("unloadResources()") + ) + open fun closeResources() { + unloadResources() + } + + open fun unloadResources() {} abstract fun update(time: Float, delta: Float) diff --git a/src/main/kotlin/games/perses/game/View.kt b/src/main/kotlin/games/perses/game/View.kt index b51342b..776140c 100644 --- a/src/main/kotlin/games/perses/game/View.kt +++ b/src/main/kotlin/games/perses/game/View.kt @@ -85,7 +85,7 @@ } } - //println("width: $width, height: $height") + println("width: $width, height: $height") } fun screenToGameCoordX(screenX: Float): Float { @@ -95,11 +95,8 @@ ViewType.ABSOLUTE -> { // nop } - ViewType.WIDTH -> { - result = (screenX / windowWidth * width) - width / 2 - } - ViewType.HEIGHT -> { - result = (screenX / windowWidth * width) - width / 2 + ViewType.WIDTH, ViewType.HEIGHT -> { + result = ( (screenX - Game.borderLeft) * width / windowWidth ) } ViewType.PROJECTION -> { // uhm @@ -119,11 +116,8 @@ ViewType.ABSOLUTE -> { // nop } - ViewType.WIDTH -> { - result = -((screenY / windowHeight * height) - height / 2) - } - ViewType.HEIGHT -> { - result = -((screenY / windowHeight * height) - height / 2) + ViewType.WIDTH, ViewType.HEIGHT -> { + result = height - ( (screenY - Game.borderTop) * height / windowHeight ) } ViewType.PROJECTION -> { // uhm @@ -144,11 +138,8 @@ ViewType.ABSOLUTE -> { // nop } - ViewType.WIDTH -> { - result = (windowWidth / width * normalizedX) - } - ViewType.HEIGHT -> { - result = (windowWidth / width * normalizedX) + ViewType.WIDTH, ViewType.HEIGHT -> { + result = ( gameX / width * windowWidth ) + Game.borderLeft } ViewType.PROJECTION -> { // uhm @@ -169,11 +160,8 @@ ViewType.ABSOLUTE -> { // nop } - ViewType.WIDTH -> { - result = windowHeight - (windowHeight / height * normalizedY) - } - ViewType.HEIGHT -> { - result = windowHeight - (windowHeight / height * normalizedY) + ViewType.WIDTH, ViewType.HEIGHT -> { + result = height - ( gameY / height * windowHeight ) + Game.borderTop } ViewType.PROJECTION -> { // uhm diff --git a/src/main/kotlin/games/perses/input/Keys.kt b/src/main/kotlin/games/perses/input/Keys.kt index a3ec0d3..e003e82 100644 --- a/src/main/kotlin/games/perses/input/Keys.kt +++ b/src/main/kotlin/games/perses/input/Keys.kt @@ -33,6 +33,8 @@ fun pointerClick(pointer: Int, x: Float, y: Float) + //fun mouseMove(x: Float, y: Float) + } open class EmptyInputProcessor : InputProcessor { @@ -44,6 +46,8 @@ override fun keyPressed(charCode: Int) { } override fun keyUp(keyCode: Int) { } + + //override fun mouseMove(x: Float, y: Float) { } } object Keys { @@ -126,7 +130,7 @@ val vx: Float = Game.view.screenToGameCoordX(event.clientX.toFloat()) val vy: Float = Game.view.screenToGameCoordY(event.clientY.toFloat()) - + //println("mouse move ${event.clientX.toFloat()}, ${event.clientY.toFloat()} -> $vx, $vy") } } diff --git a/.idea/modules/kudens.iml b/.idea/modules/kudens.iml index 9f69bde..69d95ba 100644 --- a/.idea/modules/kudens.iml +++ b/.idea/modules/kudens.iml @@ -1,5 +1,5 @@ - + diff --git a/.idea/modules/kudens_main.iml b/.idea/modules/kudens_main.iml index 0cb94fb..43c8cb1 100644 --- a/.idea/modules/kudens_main.iml +++ b/.idea/modules/kudens_main.iml @@ -1,5 +1,5 @@ - + diff --git a/.idea/modules/kudens_test.iml b/.idea/modules/kudens_test.iml index 63591a0..ddfb4f2 100644 --- a/.idea/modules/kudens_test.iml +++ b/.idea/modules/kudens_test.iml @@ -1,5 +1,5 @@ - + diff --git a/build.gradle b/build.gradle index 99768dd..961e692 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,5 @@ group 'perses.games' -version '1.1.0-SNAPSHOT' +version '1.0.2-SNAPSHOT' apply plugin: 'kotlin2js' apply plugin: 'idea' diff --git a/src/main/kotlin/games/perses/game/Game.kt b/src/main/kotlin/games/perses/game/Game.kt index a3391ec..a8d0578 100644 --- a/src/main/kotlin/games/perses/game/Game.kt +++ b/src/main/kotlin/games/perses/game/Game.kt @@ -84,6 +84,9 @@ var fpsCount = 0 var fpsCountTime = 0f + var borderLeft = 0 + var borderTop = 0 + fun gl() = html.webgl fun resize() { @@ -113,11 +116,11 @@ gl().viewport(0, 0, view.width.toInt(), view.height.toInt()) - val left = (windowWidth - view.windowWidth) / 2 - val top = (windowHeight - view.windowHeight) / 2 + borderLeft = (windowWidth - view.windowWidth) / 2 + borderTop = (windowHeight - view.windowHeight) / 2 - canvas.setAttribute("style", "position: absolute; left: ${left}px; top: ${top}px; z-index: 5; width: ${view.windowWidth}px; height: ${view.windowHeight}px;" ) - textCanvas.setAttribute("style", "position: absolute; left: ${left}px; top: ${top}px; z-index: 10; width: ${view.windowWidth}px; height: ${view.windowHeight}px;" ) + canvas.setAttribute("style", "position: absolute; left: ${borderLeft}px; top: ${borderTop}px; z-index: 5; width: ${view.windowWidth}px; height: ${view.windowHeight}px;" ) + textCanvas.setAttribute("style", "position: absolute; left: ${borderLeft}px; top: ${borderTop}px; z-index: 10; width: ${view.windowWidth}px; height: ${view.windowHeight}px;" ) } } @@ -134,7 +137,7 @@ } fun setScreen(screen: Screen) { - currentScreen.closeResources() + currentScreen.unloadResources() currentScreen = screen diff --git a/src/main/kotlin/games/perses/game/Screen.kt b/src/main/kotlin/games/perses/game/Screen.kt index 6dc3525..10b6eae 100644 --- a/src/main/kotlin/games/perses/game/Screen.kt +++ b/src/main/kotlin/games/perses/game/Screen.kt @@ -10,7 +10,15 @@ open fun loadResources() {} - open fun closeResources() {} + @Deprecated( + message = "replace with unloadResources", + replaceWith = ReplaceWith("unloadResources()") + ) + open fun closeResources() { + unloadResources() + } + + open fun unloadResources() {} abstract fun update(time: Float, delta: Float) diff --git a/src/main/kotlin/games/perses/game/View.kt b/src/main/kotlin/games/perses/game/View.kt index b51342b..776140c 100644 --- a/src/main/kotlin/games/perses/game/View.kt +++ b/src/main/kotlin/games/perses/game/View.kt @@ -85,7 +85,7 @@ } } - //println("width: $width, height: $height") + println("width: $width, height: $height") } fun screenToGameCoordX(screenX: Float): Float { @@ -95,11 +95,8 @@ ViewType.ABSOLUTE -> { // nop } - ViewType.WIDTH -> { - result = (screenX / windowWidth * width) - width / 2 - } - ViewType.HEIGHT -> { - result = (screenX / windowWidth * width) - width / 2 + ViewType.WIDTH, ViewType.HEIGHT -> { + result = ( (screenX - Game.borderLeft) * width / windowWidth ) } ViewType.PROJECTION -> { // uhm @@ -119,11 +116,8 @@ ViewType.ABSOLUTE -> { // nop } - ViewType.WIDTH -> { - result = -((screenY / windowHeight * height) - height / 2) - } - ViewType.HEIGHT -> { - result = -((screenY / windowHeight * height) - height / 2) + ViewType.WIDTH, ViewType.HEIGHT -> { + result = height - ( (screenY - Game.borderTop) * height / windowHeight ) } ViewType.PROJECTION -> { // uhm @@ -144,11 +138,8 @@ ViewType.ABSOLUTE -> { // nop } - ViewType.WIDTH -> { - result = (windowWidth / width * normalizedX) - } - ViewType.HEIGHT -> { - result = (windowWidth / width * normalizedX) + ViewType.WIDTH, ViewType.HEIGHT -> { + result = ( gameX / width * windowWidth ) + Game.borderLeft } ViewType.PROJECTION -> { // uhm @@ -169,11 +160,8 @@ ViewType.ABSOLUTE -> { // nop } - ViewType.WIDTH -> { - result = windowHeight - (windowHeight / height * normalizedY) - } - ViewType.HEIGHT -> { - result = windowHeight - (windowHeight / height * normalizedY) + ViewType.WIDTH, ViewType.HEIGHT -> { + result = height - ( gameY / height * windowHeight ) + Game.borderTop } ViewType.PROJECTION -> { // uhm diff --git a/src/main/kotlin/games/perses/input/Keys.kt b/src/main/kotlin/games/perses/input/Keys.kt index a3ec0d3..e003e82 100644 --- a/src/main/kotlin/games/perses/input/Keys.kt +++ b/src/main/kotlin/games/perses/input/Keys.kt @@ -33,6 +33,8 @@ fun pointerClick(pointer: Int, x: Float, y: Float) + //fun mouseMove(x: Float, y: Float) + } open class EmptyInputProcessor : InputProcessor { @@ -44,6 +46,8 @@ override fun keyPressed(charCode: Int) { } override fun keyUp(keyCode: Int) { } + + //override fun mouseMove(x: Float, y: Float) { } } object Keys { @@ -126,7 +130,7 @@ val vx: Float = Game.view.screenToGameCoordX(event.clientX.toFloat()) val vy: Float = Game.view.screenToGameCoordY(event.clientY.toFloat()) - + //println("mouse move ${event.clientX.toFloat()}, ${event.clientY.toFloat()} -> $vx, $vy") } } diff --git a/src/main/kotlin/games/perses/texture/Textures.kt b/src/main/kotlin/games/perses/texture/Textures.kt index 2ae5bda..7be77ef 100644 --- a/src/main/kotlin/games/perses/texture/Textures.kt +++ b/src/main/kotlin/games/perses/texture/Textures.kt @@ -285,7 +285,7 @@ fun get(name: String) = textures[name] ?: throw IllegalArgumentException("Texture with name $name is not loaded!") fun clear() { - // delete and unbind all textures... + // todo: delete and unbind all textures... } fun render() {