Skip to content

GregEakin/BlobSallad.Android

Repository files navigation

Blob Sallad for Android

I found this little blob engine code, and converted it run on Android with Kotlin. See the WPF dot.Net version.

From the website: Blob Sallad

Blob Sallad

Original version by: Björn Lindberg

See the writeup at Dev.Opera

Blob Sallad — Canvas Tag and JavaScript Physics Simulation Experiment

Sample code

Here's the code that calculates the Verlet Integration to integrate Newton's equations of motion, as used in the Störmer method.

fun move(dt: Float) {
    val dt2 = dt * dt

    val currX = pos.x
    val prevX = prev.x
    val accX = _force.x / mass
    prev.x = currX
    pos.x = (2.0f - friction) * currX - (1.0f - friction) * prevX + accX * dt2

    val currY = pos.y
    val prevY = prev.y
    val accY = _force.y / mass
    prev.y = currY
    pos.y = (2.0f - friction) * currY - (1.0f - friction) * prevY + accY * dt2
}

Author

🔥 Greg Eakin

Releases

No releases published

Packages

No packages published