mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-15 08:06:06 +09:00
trajectory to draw at the world edge
This commit is contained in:
@@ -753,7 +753,7 @@ object IngameRenderer : Disposable {
|
|||||||
val heldItem = ItemCodex[itemID] // will be null for blocks
|
val heldItem = ItemCodex[itemID] // will be null for blocks
|
||||||
// this is a case-by-case affair
|
// this is a case-by-case affair
|
||||||
when (heldItem) {
|
when (heldItem) {
|
||||||
is ItemThrowable -> drawAimGuideForThrowable(fb, batch, frameDelta, player, world, heldItem)
|
is ItemThrowable -> drawTrajectoryForThrowable(fb, batch, frameDelta, player, world, heldItem)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -765,7 +765,9 @@ object IngameRenderer : Disposable {
|
|||||||
private val cubeSize = 7.0
|
private val cubeSize = 7.0
|
||||||
private val externalV = Vector2()
|
private val externalV = Vector2()
|
||||||
private val maxStep = 56
|
private val maxStep = 56
|
||||||
private fun drawAimGuideForThrowable(frameBuffer: FrameBuffer, batch: SpriteBatch, frameDelta: Float, player: ActorWithBody, world: GameWorld, item: ItemThrowable) {
|
private fun drawTrajectoryForThrowable(frameBuffer: FrameBuffer, batch: SpriteBatch, frameDelta: Float, player: ActorWithBody, world: GameWorld, item: ItemThrowable) {
|
||||||
|
val ww = world.width * TILE_SIZEF
|
||||||
|
|
||||||
mouseInInteractableRange(player) { mx, my, mtx, mty ->
|
mouseInInteractableRange(player) { mx, my, mtx, mty ->
|
||||||
val (throwPos, throwVector) = getThrowPosAndVector(player)
|
val (throwPos, throwVector) = getThrowPosAndVector(player)
|
||||||
val grav = world.gravitation
|
val grav = world.gravitation
|
||||||
@@ -777,13 +779,11 @@ object IngameRenderer : Disposable {
|
|||||||
batch.color = Color(0.9f, 0.9f, 0.9f, 0.9f * (1f - (c.toFloat() / maxStep).sqr()))
|
batch.color = Color(0.9f, 0.9f, 0.9f, 0.9f * (1f - (c.toFloat() / maxStep).sqr()))
|
||||||
|
|
||||||
// plot a dot
|
// plot a dot
|
||||||
if (c > 0) Toolkit.fillArea(
|
if (c > 0) {
|
||||||
batch,
|
Toolkit.fillArea(batch, throwPos.x.toFloat(), throwPos.y.toFloat(), 2f, 2f)
|
||||||
throwPos.x.toFloat(),
|
Toolkit.fillArea(batch, throwPos.x.toFloat() + ww, throwPos.y.toFloat(), 2f, 2f)
|
||||||
throwPos.y.toFloat(),
|
Toolkit.fillArea(batch, throwPos.x.toFloat() - ww, throwPos.y.toFloat(), 2f, 2f)
|
||||||
2f,
|
}
|
||||||
2f
|
|
||||||
)
|
|
||||||
|
|
||||||
// simulate physics
|
// simulate physics
|
||||||
applyGravitation(grav, cubeSize) // TODO use actual value instead of `cubeSize`
|
applyGravitation(grav, cubeSize) // TODO use actual value instead of `cubeSize`
|
||||||
|
|||||||
Reference in New Issue
Block a user