From 1f0def0f1c570f42d2f781926c836655a9a98b55 Mon Sep 17 00:00:00 2001 From: LeHaine Date: Wed, 20 Jul 2022 11:58:48 -0400 Subject: [PATCH] littlekt: update to version 0.3.0 kotlin: update to version 1.7.0 --- .../kotlin/com/game/template/Game.kt | 21 ++++++++++++++++--- gradle/libs.versions.toml | 6 +++--- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/game/src/commonMain/kotlin/com/game/template/Game.kt b/game/src/commonMain/kotlin/com/game/template/Game.kt index 2e8d32a..c5cc974 100644 --- a/game/src/commonMain/kotlin/com/game/template/Game.kt +++ b/game/src/commonMain/kotlin/com/game/template/Game.kt @@ -4,24 +4,39 @@ import com.lehaine.littlekt.Context import com.lehaine.littlekt.ContextListener import com.lehaine.littlekt.graphics.* import com.lehaine.littlekt.graphics.gl.ClearBufferMask +import com.lehaine.littlekt.graphics.shape.ShapeRenderer +import com.lehaine.littlekt.math.geom.degrees +import com.lehaine.littlekt.math.geom.radians +import com.lehaine.littlekt.util.viewport.ExtendViewport +import kotlin.time.Duration.Companion.milliseconds class Game(context: Context) : ContextListener(context) { override suspend fun Context.start() { val batch = SpriteBatch(this) - val camera = OrthographicCamera(graphics.width, graphics.height) + val shapeRenderer = ShapeRenderer(batch) + val viewport = ExtendViewport(960, 540) + val camera = viewport.camera + var rotation = 0.radians + var rotationTimer = 0.milliseconds onResize { width, height -> - camera.update(width, height, context) + viewport.update(width, height, context) } - onRender { + onRender { dt -> gl.clearColor(Color.DARK_GRAY) gl.clear(ClearBufferMask.COLOR_BUFFER_BIT) batch.use(camera.viewProjection) { Fonts.default.draw(it, "Hello LittleKt!", 0f, 0f) + shapeRenderer.filledRectangle(-50f, 50f, 100f, 50f, rotation, color = Color.RED.toFloatBits()) + } + rotationTimer += dt + if (rotationTimer > 10.milliseconds) { + rotationTimer = 0.milliseconds + rotation += 1.degrees } } } diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index d42aecd..e56c624 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,11 +1,11 @@ [versions] plugin-android = "7.0.4" -plugin-kotlin = "1.6.10" +plugin-kotlin = "1.7.0" kotlinx-html = "0.7.2" -kotlinx-coroutines = "1.6.0-native-mt" +kotlinx-coroutines = "1.6.4" -littlekt = "0.2.0" +littlekt = "0.3.0" [libraries] plugin-android = { module = "com.android.tools.build:gradle", version.ref = "plugin-android" }