mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-11 19:14:05 +09:00
tiles with light level <= 1 will be rendered as black square, phys support for non-self-moving bodies (e.g. balls)
Former-commit-id: 5611e2d89f4601e57d014c45f0479600778217f6 Former-commit-id: d900c0733a6d1dcbd9aaed8e9f7f1671c3866624
This commit is contained in:
@@ -6,6 +6,7 @@ import net.torvald.terrarum.gameactors.PhysTestBall
|
||||
import net.torvald.terrarum.mapdrawer.TilesDrawer
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.mapdrawer.MapCamera
|
||||
import org.dyn4j.geometry.Vector2
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 16-03-05.
|
||||
@@ -13,10 +14,26 @@ import net.torvald.terrarum.mapdrawer.MapCamera
|
||||
internal object SpawnPhysTestBall : ConsoleCommand {
|
||||
@Throws(Exception::class)
|
||||
override fun execute(args: Array<String>) {
|
||||
if (args.size == 2) {
|
||||
val mouseX = Terrarum.appgc.input.mouseX
|
||||
val mouseY = Terrarum.appgc.input.mouseY
|
||||
val mouseX = Terrarum.appgc.input.mouseX
|
||||
val mouseY = Terrarum.appgc.input.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()
|
||||
ball.setPosition(
|
||||
(mouseX + MapCamera.x).toDouble(),
|
||||
(mouseY + MapCamera.y).toDouble()
|
||||
)
|
||||
ball.elasticity = elasticity
|
||||
ball.applyForce(Vector2(xvel, yvel))
|
||||
|
||||
Terrarum.ingame.addActor(ball)
|
||||
}
|
||||
else if (args.size == 2) {
|
||||
val elasticity = args[1].toDouble()
|
||||
|
||||
val ball = PhysTestBall()
|
||||
@@ -34,6 +51,6 @@ internal object SpawnPhysTestBall : ConsoleCommand {
|
||||
}
|
||||
|
||||
override fun printUsage() {
|
||||
Echo("usage: spawnball [elasticity]")
|
||||
Echo("usage: spawnball elasticity [x velocity] [y velocity]")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user