mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-11 06:11:50 +09:00
53 lines
1.5 KiB
Kotlin
53 lines
1.5 KiB
Kotlin
package net.torvald.terrarum.modulebasegame.console
|
|
|
|
import net.torvald.terrarum.modulebasegame.gameactors.PhysTestBall
|
|
import net.torvald.terrarum.Terrarum
|
|
import net.torvald.terrarum.console.ConsoleCommand
|
|
import net.torvald.terrarum.console.Echo
|
|
import net.torvald.terrarum.modulebasegame.Ingame
|
|
import org.dyn4j.geometry.Vector2
|
|
|
|
/**
|
|
* Created by minjaesong on 2016-03-05.
|
|
*/
|
|
internal object SpawnPhysTestBall : ConsoleCommand {
|
|
@Throws(Exception::class)
|
|
override fun execute(args: Array<String>) {
|
|
val world = (Terrarum.ingame!! as Ingame).world
|
|
|
|
|
|
val mouseX = Terrarum.mouseX
|
|
val mouseY = Terrarum.mouseY
|
|
|
|
if (args.size >= 3) {
|
|
val elasticity = args[1].toDouble()
|
|
|
|
val xvel = args[2].toDouble()
|
|
val yvel = if (args.size >= 4) args[3].toDouble() else 0.0
|
|
|
|
val ball = PhysTestBall(world)
|
|
ball.setPosition(mouseX, mouseY)
|
|
ball.elasticity = elasticity
|
|
ball.applyForce(Vector2(xvel, yvel))
|
|
|
|
Terrarum.ingame!!.addNewActor(ball)
|
|
}
|
|
else if (args.size == 2) {
|
|
val elasticity = args[1].toDouble()
|
|
|
|
val ball = PhysTestBall(world)
|
|
ball.setPosition(mouseX, mouseY)
|
|
ball.elasticity = elasticity
|
|
|
|
Terrarum.ingame!!.addNewActor(ball)
|
|
}
|
|
else {
|
|
printUsage()
|
|
}
|
|
}
|
|
|
|
override fun printUsage() {
|
|
Echo("usage: spawnball elasticity [x velocity] [y velocity]")
|
|
}
|
|
}
|