mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-17 09:06:06 +09:00
wippieeee
This commit is contained in:
@@ -1,10 +1,10 @@
|
|||||||
package net.torvald.terrarum.gameactors
|
package net.torvald.terrarum.gameactors
|
||||||
|
|
||||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||||
|
import net.torvald.terrarum.App
|
||||||
import net.torvald.terrarum.TerrarumAppConfiguration.TILE_SIZED
|
import net.torvald.terrarum.TerrarumAppConfiguration.TILE_SIZED
|
||||||
import kotlin.math.atan2
|
import net.torvald.terrarum.worlddrawer.WorldCamera
|
||||||
import kotlin.math.cos
|
import kotlin.math.*
|
||||||
import kotlin.math.sin
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by minjaesong on 2025-03-10.
|
* Created by minjaesong on 2025-03-10.
|
||||||
@@ -44,7 +44,7 @@ class ActorConveyors : ActorWithBody {
|
|||||||
val wxSpinCntrEnd = (axleX2 + 0.5) * TILE_SIZED
|
val wxSpinCntrEnd = (axleX2 + 0.5) * TILE_SIZED
|
||||||
val wySpinCntrEnd = (axleY2 + 0.5) * TILE_SIZED
|
val wySpinCntrEnd = (axleY2 + 0.5) * TILE_SIZED
|
||||||
|
|
||||||
val r = 0.5 * TILE_SIZED
|
val r = 0.5 * TILE_SIZED.minus(2)
|
||||||
|
|
||||||
val wxBeltTopStart = wxSpinCntrStart + r * sin(inclination)
|
val wxBeltTopStart = wxSpinCntrStart + r * sin(inclination)
|
||||||
val wyBeltTopStart = wySpinCntrStart + r * cos(inclination)
|
val wyBeltTopStart = wySpinCntrStart + r * cos(inclination)
|
||||||
@@ -57,15 +57,33 @@ class ActorConveyors : ActorWithBody {
|
|||||||
val wyBeltBtmEnd = wySpinCntrEnd + r * cos(declination)
|
val wyBeltBtmEnd = wySpinCntrEnd + r * cos(declination)
|
||||||
|
|
||||||
|
|
||||||
|
val segmentCount = max(1.0, (6 * cbrt(r).toFloat() * (180.0 / 360.0f)).toInt().toDouble())
|
||||||
|
|
||||||
// belt top
|
// belt top
|
||||||
drawLineAtWorld(wxBeltTopStart, wyBeltTopStart, wxBeltTopEnd, wyBeltTopEnd)
|
drawLineOnWorld(wxBeltTopStart, wyBeltTopStart, wxBeltTopEnd, wyBeltTopEnd)
|
||||||
// belt bottom
|
// belt bottom
|
||||||
drawLineAtWorld(wxBeltBtmStart, wyBeltBtmStart, wxBeltBtmEnd, wyBeltBtmEnd)
|
drawLineOnWorld(wxBeltBtmStart, wyBeltBtmStart, wxBeltBtmEnd, wyBeltBtmEnd)
|
||||||
// left arc
|
// left arc
|
||||||
|
drawArcOnWorld(wxSpinCntrStart, wySpinCntrStart, r, declination, 180.0)
|
||||||
// right arc
|
// right arc
|
||||||
|
drawArcOnWorld(wxSpinCntrEnd, wySpinCntrEnd, r, inclination, 180.0)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun drawLineOnWorld(x1: Double, y1: Double, x2: Double, y2: Double) {
|
||||||
|
val w = 2.0f
|
||||||
|
App.shapeRender.rectLine(
|
||||||
|
x1.toFloat() - WorldCamera.x, y1.toFloat() - WorldCamera.y,
|
||||||
|
x2.toFloat() - WorldCamera.x, y2.toFloat() - WorldCamera.y,
|
||||||
|
w
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun drawArcOnWorld(xc: Double, yc: Double, r: Double, arcStart: Double, arcDegrees: Double) {
|
||||||
|
val w = 2.0f
|
||||||
|
App.shapeRender.arc(
|
||||||
|
xc.toFloat() - WorldCamera.x,
|
||||||
|
yc.toFloat() - WorldCamera.y,
|
||||||
|
r.toFloat(), arcStart.toFloat(), arcDegrees.toFloat()
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user