altavir
08/15/2021, 3:16 PMval bouncingSphere = SolidGroup {
sphere(5.0, "ball") {
detail = 16
color("red")
val h = 100.0
y = h
GlobalScope.launch {
val g = 10.0
val dt = 0.1
var time = 0.0
var velocity = 0.0
while (isActive) {
delay(20)
time += dt
velocity -= g * dt
y = y.toDouble() + velocity * dt
if (y.toDouble() <= 2.5){
velocity = sqrt(2*g*h)
}
}
}
}
box(200, 5, 200, name = "floor"){
y = -2.5
}
}