mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-20 15:34:05 +09:00
CCD implementation for hitting ground
Former-commit-id: 786f0b4551b32be44767eac627dc247df3773968 Former-commit-id: 6ff2be7b31c91a581125c5682055776047660195
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user