CCD implementation for hitting ground

Former-commit-id: 786f0b4551b32be44767eac627dc247df3773968
Former-commit-id: 6ff2be7b31c91a581125c5682055776047660195
This commit is contained in:
Song Minjae
2016-05-02 00:42:04 +09:00
parent f3050736be
commit 6171b44170
9 changed files with 1152 additions and 319 deletions

View File

@@ -1,6 +1,8 @@
package net.torvald.terrarum.gameactors
import net.torvald.point.Point2d
import org.dyn4j.geometry.ChainedVector2
import org.dyn4j.geometry.Vector2
/**
* Created by minjaesong on 16-01-15.
@@ -54,6 +56,18 @@ class Hitbox(x1: Double, y1: Double, width: Double, height: Double) {
this.height = height
}
fun translate(x: Double, y: Double) {
setPosition(posX + x, posY + y)
}
fun translate(vec: ChainedVector2) {
translate(vec.x, vec.y)
}
fun translate(vec: Vector2) {
translate(vec.x, vec.y)
}
fun setPosition(x1: Double, y1: Double) {
hitboxStart = Point2d(x1, y1)
hitboxEnd = Point2d(x1 + width, y1 + height)
@@ -112,4 +126,8 @@ class Hitbox(x1: Double, y1: Double, width: Double, height: Double) {
val centeredY: Double
get() = (hitboxStart.y + hitboxEnd.y) * 0.5f
fun toVector(): Vector2 {
return Vector2(posX, posY)
}
}