mirror of
https://github.com/jlengrand/korge-samples.git
synced 2026-03-10 08:31:18 +00:00
KorGE 1.13.0.0
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -10,3 +10,4 @@ game.storage
|
||||
*.iml
|
||||
*.log
|
||||
.DS_Store
|
||||
/sample-pong/build/
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
korgePluginVersion=1.12.8.0
|
||||
korgePluginVersion=1.13.0.0
|
||||
#korgeVersion=1.13.0-SNAPSHOT
|
||||
#korgeVersion=1.12.8-SNAPSHOT
|
||||
#korimVersion=1.12.15
|
||||
#korimVersion=1.12.11-SNAPSHOT
|
||||
|
||||
@@ -30,7 +30,7 @@ suspend fun main() = Korge(
|
||||
|
||||
spawnAsteroid(WIDTH - 20.0, 20.0)
|
||||
|
||||
ship.onCollision {
|
||||
ship.onCollision(kind = CollisionKind.SHAPE) {
|
||||
if (it is Asteroid) {
|
||||
//ship.removeFromParent()
|
||||
println("GAME OVER!")
|
||||
@@ -44,7 +44,7 @@ suspend fun main() = Korge(
|
||||
asteroid.x = random[0.0, WIDTH.toDouble()]
|
||||
asteroid.y = random[0.0, HEIGHT.toDouble()]
|
||||
asteroid.angle = random[0.0, 360.0].degrees
|
||||
} while (asteroid.collidesWith(ship) || ship.distanceTo(asteroid) < 100.0)
|
||||
} while (ship.distanceTo(asteroid) < 100.0)
|
||||
}
|
||||
|
||||
var bulletReload = 0.0
|
||||
@@ -65,7 +65,7 @@ suspend fun main() = Korge(
|
||||
.rotation(ship.rotation)
|
||||
.advance(assets.shipSize * 0.75)
|
||||
|
||||
bullet.onCollision {
|
||||
bullet.onCollision(kind = CollisionKind.SHAPE) {
|
||||
if (it is Asteroid) {
|
||||
bullet.removeFromParent()
|
||||
it.divide()
|
||||
@@ -104,13 +104,13 @@ class Asteroid(val assets: Assets, val asteroidSize: Int = 3) : Image(assets.ast
|
||||
val scale = time / 16.milliseconds
|
||||
val dx = angle.cosine * scale
|
||||
val dy = angle.sine * scale
|
||||
x += dx
|
||||
y += dy
|
||||
//x += dx
|
||||
//y += dy
|
||||
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
|
||||
//rotationDegrees += scale
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
import com.soywiz.korge.*
|
||||
import com.soywiz.korge.atlas.*
|
||||
import com.soywiz.korge.view.*
|
||||
import com.soywiz.korio.*
|
||||
import com.soywiz.korio.dynamic.*
|
||||
import com.soywiz.korio.file.std.*
|
||||
import com.soywiz.korge.Korge
|
||||
import com.soywiz.korge.atlas.readAtlas
|
||||
import com.soywiz.korge.view.Stage
|
||||
import com.soywiz.korge.view.image
|
||||
import com.soywiz.korge.view.position
|
||||
import com.soywiz.korio.file.std.resourcesVfs
|
||||
|
||||
suspend fun main() = Korge(width = 640, height = 480, virtualWidth = 320, virtualHeight = 240) {
|
||||
atlasMain()
|
||||
}
|
||||
|
||||
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)
|
||||
val logos = resourcesVfs["logos.atlas.json"].readAtlas()
|
||||
image(logos["korau.png"]).position(0, 0)
|
||||
image(logos["korim.png"]).position(64, 32)
|
||||
image(logos["korge.png"]).position(128, 64)
|
||||
}
|
||||
|
||||
@@ -25,14 +25,14 @@ suspend fun main() = Korge {
|
||||
val gamepadUpdateText = textLine("GamepadUpdateEv")
|
||||
val gamepadUpdate2Text = textLine("GamepadUpdate2Ev")
|
||||
|
||||
//stage.addEventListener<KeyEvent> { keysEvText.text = "${nowUnix()}:$it" }
|
||||
//stage.addEventListener<MouseEvent> { mouseEvText.text = "${nowUnix()}:$it" }
|
||||
//stage.addEventListener<ReshapeEvent> { resizeText.text = "${nowUnix()}:$it" }
|
||||
//stage.addEventListener<GamePadConnectionEvent> { gamepadConnectedText.text = "${nowUnix()}:$it" }
|
||||
//stage.addEventListener<GamePadUpdateEvent> {
|
||||
// gamepadUpdateText.text = "${nowUnix()}:$it"
|
||||
// gamepadUpdate2Text.text = "" + it.gamepads.lastOrNull { it.connected }?.rawButtonsPressed
|
||||
//}
|
||||
stage.addEventListener<KeyEvent> { keysEvText.text = "${nowUnix()}:$it" }
|
||||
stage.addEventListener<MouseEvent> { mouseEvText.text = "${nowUnix()}:$it" }
|
||||
stage.addEventListener<ReshapeEvent> { resizeText.text = "${nowUnix()}:$it" }
|
||||
stage.addEventListener<GamePadConnectionEvent> { gamepadConnectedText.text = "${nowUnix()}:$it" }
|
||||
stage.addEventListener<GamePadUpdateEvent> {
|
||||
gamepadUpdateText.text = "${nowUnix()}:$it"
|
||||
gamepadUpdate2Text.text = "" + it.gamepads.lastOrNull { it.connected }?.rawButtonsPressed
|
||||
}
|
||||
|
||||
gamepad {
|
||||
button.invoke { gamepadButtonText.text = "$it" }
|
||||
|
||||
@@ -7,19 +7,19 @@ import com.soywiz.korio.async.*
|
||||
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 atlas = resourcesVfs["lips.atlas.json"].readAtlas()
|
||||
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,5 +1,7 @@
|
||||
import com.soywiz.klock.timesPerSecond
|
||||
import com.soywiz.korge.*
|
||||
import com.soywiz.korge.time.*
|
||||
import com.soywiz.korge.view.addFixedUpdater
|
||||
import com.soywiz.korge.view.tiles.*
|
||||
import com.soywiz.korim.bitmap.*
|
||||
import com.soywiz.korim.format.*
|
||||
@@ -9,12 +11,9 @@ import com.soywiz.korio.file.std.*
|
||||
suspend fun main() = Korge(width = 512, height = 512) {
|
||||
val tileset = TileSet(mapOf(0 to bitmap("korge.png").toBMP32().scaleLinear(0.5, 0.5).slice()))
|
||||
val tilemap = tileMap(Bitmap32(1, 1), repeatX = TileMap.Repeat.REPEAT, repeatY = TileMap.Repeat.REPEAT, tileset = tileset)
|
||||
launchImmediately {
|
||||
while (true) {
|
||||
tilemap.x += 1
|
||||
tilemap.y += 0.25
|
||||
delayFrame()
|
||||
}
|
||||
addFixedUpdater(60.timesPerSecond) {
|
||||
tilemap.x += 1
|
||||
tilemap.y += 0.25
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user