Feature/update 1.13.0.1 (#23)

* Use korgwVersion=1.12.12-SNAPSHOT and fix asteroids sample line width

* 1.13.0.1

* Updated atlas usage

* Some fixes
This commit is contained in:
Carlos Ballesteros Velasco
2020-06-09 18:03:47 +02:00
committed by GitHub
parent 3e5beb9bc4
commit 7534dac6a6
11 changed files with 51 additions and 24 deletions

View File

@@ -1,4 +1,7 @@
korgePluginVersion=1.12.8.0
korgePluginVersion=1.13.0.1
#korimVersion=1.12.23-SNAPSHOT
#korgwVersion=1.12.12-SNAPSHOT
#korgeVersion=1.13.0-SNAPSHOT
#korgeVersion=1.12.8-SNAPSHOT
#korimVersion=1.12.15
#korimVersion=1.12.11-SNAPSHOT

Binary file not shown.

View File

@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

2
gradlew vendored
View File

@@ -82,7 +82,6 @@ esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
@@ -130,7 +129,6 @@ fi
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath

1
gradlew.bat vendored
View File

@@ -84,7 +84,6 @@ set CMD_LINE_ARGS=%*
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%

View File

@@ -0,0 +1,24 @@
<html>
<body style="background: #333;">
<canvas id="canvas" width="512" height="512"></canvas>
<script>
const canvas = document.querySelector("#canvas")
const ctx = canvas.getContext('2d')
const shipSize = 24;
const asteroidSize = shipSize * 2
//ctx.lineWidth = asteroidSize * 0.05
ctx.lineWidth = 0.05
ctx.strokeStyle = 'white'
ctx.lineCap = 'round'
ctx.scale(asteroidSize, asteroidSize)
ctx.moveTo(0.0, 0.5)
ctx.lineTo(0.2, 0.0)
ctx.lineTo(0.7, 0.0)
ctx.lineTo(1.0, 0.5)
ctx.lineTo(0.7, 1.0)
ctx.lineTo(0.3, 1.0)
ctx.closePath()
ctx.stroke()
</script>
</body>
</html>

View File

@@ -1,5 +1,7 @@
import com.soywiz.kds.*
import com.soywiz.klock.*
import com.soywiz.klock.hr.hrMicroseconds
import com.soywiz.klock.hr.hrMilliseconds
import com.soywiz.korev.*
import com.soywiz.korge.*
import com.soywiz.korge.view.*
@@ -48,8 +50,8 @@ suspend fun main() = Korge(
}
var bulletReload = 0.0
addUpdater { time ->
val scale = time / 16.milliseconds
addHrUpdater { time ->
val scale = time / 16.hrMilliseconds
if (pressing(Key.LEFT)) ship.rotation -= 3.degrees * scale
if (pressing(Key.RIGHT)) ship.rotation += 3.degrees * scale
if (pressing(Key.UP)) ship.advance(2.0 * scale)
@@ -100,17 +102,17 @@ class Asteroid(val assets: Assets, val asteroidSize: Int = 3) : Image(assets.ast
scale = asteroidSize.toDouble() / 3.0
name = "asteroid"
speed = 0.6
addUpdater { time ->
val scale = time / 16.milliseconds
addHrUpdater { time ->
val scale = time / 16.hrMilliseconds
val dx = angle.cosine * scale
val dy = angle.sine * scale
x += dx
y += dy
rotationDegrees += scale
if (y < 0 && dy < 0) angle += 45.degrees
if (x < 0 && dx < 0) angle += 45.degrees
if (x > WIDTH && dx > 0) angle += 45.degrees
if (y > HEIGHT && dy > 0) angle += 45.degrees
rotationDegrees += scale
}
}
@@ -146,7 +148,7 @@ inline fun View.advance(amount: Number, rot: Angle = (-90).degrees) = advance(am
class Assets(val views: Views, val shipSize: Int = 24) {
val asteroidSize = shipSize * 2
val shipBitmap = NativeImage(shipSize, shipSize).context2d {
lineWidth = shipSize * 0.05
lineWidth = 0.05
lineCap = LineCap.ROUND
stroke(Colors.WHITE) {
scale(shipSize)
@@ -165,8 +167,8 @@ class Assets(val views: Views, val shipSize: Int = 24) {
lineToV(height)
}
}
val asteroidBitmap = NativeImage(asteroidSize, asteroidSize).context2d {
lineWidth = asteroidSize * 0.05
val asteroidBitmap = Bitmap32(asteroidSize, asteroidSize).context2d { // Let's use software vector rendering here, for testing purposes
lineWidth = 0.05
lineCap = LineCap.ROUND
stroke(Colors.WHITE) {
scale(asteroidSize)

View File

@@ -11,7 +11,7 @@ suspend fun main() = Korge(width = 640, height = 480, virtualWidth = 320, virtua
suspend fun Stage.atlasMain() {
val logos = resourcesVfs["logos.atlas.json"].readAtlas(views)
image(logos["korau.png"].texture).position(0, 0)
image(logos["korim.png"].texture).position(64, 32)
image(logos["korge.png"].texture).position(128, 64)
image(logos["korau.png"]).position(0, 0)
image(logos["korim.png"]).position(64, 32)
image(logos["korge.png"]).position(128, 64)
}

View File

@@ -18,10 +18,10 @@ class AtlasTest : ViewsForTesting() {
@Test
fun testAtlas() = suspendTest {
val atlas = resourcesVfs["logos.atlas.json"].readAtlas(views)
assertEquals(3, atlas.textures.size)
assertEquals(Size(64, 64), atlas.textures["korau.png"]!!.texture.size)
assertEquals(Size(64, 64), atlas.textures["korge.png"]!!.texture.size)
assertEquals(Size(64, 64), atlas.textures["korim.png"]!!.texture.size)
assertEquals(3, atlas.entries.size)
assertEquals(Size(64, 64), atlas["korau.png"].size)
assertEquals(Size(64, 64), atlas["korge.png"].size)
assertEquals(Size(64, 64), atlas["korim.png"].size)
}
private val BmpSlice.size get() = Size(width, height)

View File

@@ -8,18 +8,18 @@ import com.soywiz.korio.file.std.*
suspend fun main() = Korge {
val atlas = resourcesVfs["lips.atlas.json"].readAtlas(views)
val lips = image(atlas["lisa-A.png"].texture)
val lips2 = image(atlas["lisa-A.png"].texture).position(400, 0)
val lips = image(atlas["lisa-A.png"])
val lips2 = image(atlas["lisa-A.png"]).position(400, 0)
addEventListener<LipSyncEvent> {
println(it)
if (it.name == "lisa") {
lips2.texture = atlas["lisa-${it.lip}.png"].texture
lips2.texture = atlas["lisa-${it.lip}.png"]
}
}
launchImmediately {
fun handler(it: LipSyncEvent) {
views.dispatch(it)
lips.texture = atlas["lisa-${it.lip}.png"].texture
lips.texture = atlas["lisa-${it.lip}.png"]
}
resourcesVfs["001.voice.wav"].readVoice().play("lisa") { handler(it) }

1
sample-pong/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
/build