mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-12 11:34:05 +09:00
intTilewiseHitbox is now being updated in sync with other variables instead of getter
This commit is contained in:
@@ -84,28 +84,28 @@ open class ActorWithBody(renderOrder: RenderOrder, val physProp: PhysProperties)
|
|||||||
*
|
*
|
||||||
* e.g. USE `for (x in hitbox.startX..hitbox.endX)`, NOT `for (x in hitbox.startX until hitbox.endX)`
|
* e.g. USE `for (x in hitbox.startX..hitbox.endX)`, NOT `for (x in hitbox.startX until hitbox.endX)`
|
||||||
*/ // got the idea from gl_FragCoord
|
*/ // got the idea from gl_FragCoord
|
||||||
val hIntTilewiseHitbox: Hitbox
|
val hIntTilewiseHitbox: Hitbox = Hitbox(0.0, 0.0, 0.0, 0.0)
|
||||||
get() = Hitbox.fromTwoPoints(
|
/*get() = Hitbox.fromTwoPoints(
|
||||||
hitbox.startX.plus(PHYS_EPSILON_DIST).div(TILE_SIZE).floor() + 0.5,
|
hitbox.startX.plus(PHYS_EPSILON_DIST).div(TILE_SIZE).floor() + 0.5,
|
||||||
hitbox.startY.plus(PHYS_EPSILON_DIST).div(TILE_SIZE).floor() + 0.5,
|
hitbox.startY.plus(PHYS_EPSILON_DIST).div(TILE_SIZE).floor() + 0.5,
|
||||||
hitbox.endX.plus(PHYS_EPSILON_DIST).div(TILE_SIZE).floor() + 0.5,
|
hitbox.endX.plus(PHYS_EPSILON_DIST).div(TILE_SIZE).floor() + 0.5,
|
||||||
hitbox.endY.plus(PHYS_EPSILON_DIST).div(TILE_SIZE).floor() + 0.5,
|
hitbox.endY.plus(PHYS_EPSILON_DIST).div(TILE_SIZE).floor() + 0.5,
|
||||||
true
|
true
|
||||||
)
|
)*/
|
||||||
|
|
||||||
|
|
||||||
/** Used by non-physics shits. (e.g. BlockBase determining "occupied" blocks)
|
/** Used by non-physics shits. (e.g. BlockBase determining "occupied" blocks)
|
||||||
*
|
*
|
||||||
* e.g. USE `for (x in hitbox.startX..hitbox.endX)`, NOT `for (x in hitbox.startX until hitbox.endX)`
|
* e.g. USE `for (x in hitbox.startX..hitbox.endX)`, NOT `for (x in hitbox.startX until hitbox.endX)`
|
||||||
*/
|
*/
|
||||||
val intTilewiseHitbox: Hitbox
|
val intTilewiseHitbox: Hitbox = Hitbox(0.0, 0.0, 0.0, 0.0)
|
||||||
get() = Hitbox.fromTwoPoints(
|
/*get() = Hitbox.fromTwoPoints(
|
||||||
hitbox.startX.div(TILE_SIZE).floor(),
|
hitbox.startX.div(TILE_SIZE).floor(),
|
||||||
hitbox.startY.div(TILE_SIZE).floor(),
|
hitbox.startY.div(TILE_SIZE).floor(),
|
||||||
hitbox.endX.minus(PHYS_EPSILON_DIST).div(TILE_SIZE).floor(),
|
hitbox.endX.minus(PHYS_EPSILON_DIST).div(TILE_SIZE).floor(),
|
||||||
hitbox.endY.minus(PHYS_EPSILON_DIST).div(TILE_SIZE).floor(),
|
hitbox.endY.minus(PHYS_EPSILON_DIST).div(TILE_SIZE).floor(),
|
||||||
true
|
true
|
||||||
)
|
)*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unit: Pixels per 1/60 (or AppLoader.UPDATE_RATE) seconds.
|
* Unit: Pixels per 1/60 (or AppLoader.UPDATE_RATE) seconds.
|
||||||
@@ -490,12 +490,24 @@ open class ActorWithBody(renderOrder: RenderOrder, val physProp: PhysProperties)
|
|||||||
colliding = false
|
colliding = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
hIntTilewiseHitbox.setFromTwoPoints(
|
||||||
|
hitbox.startX.plus(PHYS_EPSILON_DIST).div(TILE_SIZE).floor() + 0.5,
|
||||||
|
hitbox.startY.plus(PHYS_EPSILON_DIST).div(TILE_SIZE).floor() + 0.5,
|
||||||
|
hitbox.endX.plus(PHYS_EPSILON_DIST).div(TILE_SIZE).floor() + 0.5,
|
||||||
|
hitbox.endY.plus(PHYS_EPSILON_DIST).div(TILE_SIZE).floor() + 0.5
|
||||||
|
)
|
||||||
|
intTilewiseHitbox.setFromTwoPoints(
|
||||||
|
hitbox.startX.div(TILE_SIZE).floor(),
|
||||||
|
hitbox.startY.div(TILE_SIZE).floor(),
|
||||||
|
hitbox.endX.minus(PHYS_EPSILON_DIST).div(TILE_SIZE).floor(),
|
||||||
|
hitbox.endY.minus(PHYS_EPSILON_DIST).div(TILE_SIZE).floor()
|
||||||
|
)
|
||||||
|
|
||||||
centrePosVector.set(hitbox.centeredX, hitbox.centeredY)
|
centrePosVector.set(hitbox.centeredX, hitbox.centeredY)
|
||||||
centrePosPoint.set(hitbox.centeredX, hitbox.centeredY)
|
centrePosPoint.set(hitbox.centeredX, hitbox.centeredY)
|
||||||
feetPosVector.set(hitbox.centeredX, hitbox.endY)
|
feetPosVector.set(hitbox.centeredX, hitbox.endY)
|
||||||
feetPosPoint.set(hitbox.centeredX, hitbox.endY)
|
feetPosPoint.set(hitbox.centeredX, hitbox.endY)
|
||||||
feetPosTile.x = hIntTilewiseHitbox.centeredX.floorInt()
|
feetPosTile.set(hIntTilewiseHitbox.centeredX.floorInt(), hIntTilewiseHitbox.endY.floorInt())
|
||||||
feetPosTile.y = hIntTilewiseHitbox.endY.floorInt()
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1609,7 +1621,6 @@ open class ActorWithBody(renderOrder: RenderOrder, val physProp: PhysProperties)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//println(intTilewiseHitbox)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user