mirror of
https://github.com/jlengrand/korge-samples.git
synced 2026-03-10 08:31:18 +00:00
Added asteroids sample
This commit is contained in:
7
sample-asteroids/build.gradle.kts
Normal file
7
sample-asteroids/build.gradle.kts
Normal file
@@ -0,0 +1,7 @@
|
||||
import com.soywiz.korge.gradle.*
|
||||
|
||||
apply<KorgeGradlePlugin>()
|
||||
|
||||
korge {
|
||||
id = "com.soywiz.samples.asteroids"
|
||||
}
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user