Added asteroids sample

This commit is contained in:
soywiz
2020-04-08 01:54:12 +02:00
parent ee5e7b94fa
commit fdb2803e98
2 changed files with 9 additions and 5 deletions

View File

@@ -0,0 +1,7 @@
import com.soywiz.korge.gradle.*
apply<KorgeGradlePlugin>()
korge {
id = "com.soywiz.samples.asteroids"
}

View File

@@ -42,7 +42,8 @@ suspend fun main() = Korge(width = WIDTH, height = HEIGHT, virtualWidth = WIDTH,
fun bulletFrame() {
bullet.advance(+3.0)
if (bullet.x < 10 || bullet.y < 10 || bullet.x > WIDTH + 10 || bullet.y > HEIGHT + 10) {
val BULLET_SIZE = 14
if (bullet.x < -BULLET_SIZE || bullet.y < -BULLET_SIZE || bullet.x > WIDTH + BULLET_SIZE || bullet.y > HEIGHT + BULLET_SIZE) {
bullet.removeFromParent()
}
}
@@ -60,10 +61,6 @@ suspend fun main() = Korge(width = WIDTH, height = HEIGHT, virtualWidth = WIDTH,
//image(shipBitmap)
}
suspend fun waitFrame() {
}
fun View.advance(amount: Double, rot: Angle = (-90).degrees) = this.apply {
x += (this.rotation + rot).cosine * amount
y += (this.rotation + rot).sine * amount