mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-07 12:21:52 +09:00
rubber coloured belts
This commit is contained in:
@@ -75,6 +75,16 @@ class ActorConveyors : ActorWithBody {
|
|||||||
private val bbx2: Double
|
private val bbx2: Double
|
||||||
private val bby2: Double
|
private val bby2: Double
|
||||||
|
|
||||||
|
private var turn: Double = 0.0 // TODO decide if the max should be 1.0 or TWO_PI. For a numerical precision, 1.0 is recommended though
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
private val COL_BELT = Color(0x444444ff)
|
||||||
|
private val COL_BELT_ALT = Color(0x666666ff)
|
||||||
|
|
||||||
|
private val COL_BELT_TOP = Color(0x666666ff.toInt())
|
||||||
|
private val COL_BELT_TOP_ALT = Color(0x999999ff.toInt())
|
||||||
|
}
|
||||||
|
|
||||||
@Transient private var shapeRender = App.makeShapeRenderer()
|
@Transient private var shapeRender = App.makeShapeRenderer()
|
||||||
|
|
||||||
override fun reload() {
|
override fun reload() {
|
||||||
@@ -125,31 +135,36 @@ class ActorConveyors : ActorWithBody {
|
|||||||
|
|
||||||
shapeRender.projectionMatrix = batch.projectionMatrix
|
shapeRender.projectionMatrix = batch.projectionMatrix
|
||||||
shapeRender.inUse {
|
shapeRender.inUse {
|
||||||
it.color = Color.RED
|
it.color = COL_BELT
|
||||||
|
|
||||||
// belt top
|
// belt top
|
||||||
drawLineOnWorld(btx1, bty1, btx2, bty2)
|
drawLineOnWorld(btx1, bty1, btx2, bty2, 2f)
|
||||||
// belt bottom
|
// belt bottom
|
||||||
drawLineOnWorld(bbx1, bby1, bbx2, bby2)
|
drawLineOnWorld(bbx1, bby1, bbx2, bby2, 2f)
|
||||||
// left arc
|
// left arc
|
||||||
drawArcOnWorld(cx1, cy1, r, dd, -Math.PI)
|
drawArcOnWorld(cx1, cy1, r, dd, -Math.PI, 2f)
|
||||||
// right arc
|
// right arc
|
||||||
drawArcOnWorld(cx2, cy2, r, di, -Math.PI)
|
drawArcOnWorld(cx2, cy2, r, di, -Math.PI, 2f)
|
||||||
|
|
||||||
|
it.color = COL_BELT_TOP
|
||||||
|
// belt top
|
||||||
|
drawLineOnWorld(btx1, bty1 - 0.5f, btx2, bty2 - 0.5f, 1f)
|
||||||
|
// belt bottom
|
||||||
|
drawLineOnWorld(bbx1, bby1 - 0.5f, bbx2, bby2 - 0.5f, 1f)
|
||||||
}
|
}
|
||||||
|
|
||||||
batch.begin()
|
batch.begin()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun drawLineOnWorld(x1: Double, y1: Double, x2: Double, y2: Double) {
|
private fun drawLineOnWorld(x1: Double, y1: Double, x2: Double, y2: Double, width: Float) {
|
||||||
val w = 2.0f
|
|
||||||
shapeRender.rectLine(
|
shapeRender.rectLine(
|
||||||
x1.toFloat(), y1.toFloat(),
|
x1.toFloat(), y1.toFloat(),
|
||||||
x2.toFloat(), y2.toFloat(),
|
x2.toFloat(), y2.toFloat(),
|
||||||
w
|
width
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun drawArcOnWorld(xc: Double, yc: Double, r: Double, arcStart: Double, arcDeg: Double) {
|
private fun drawArcOnWorld(xc: Double, yc: Double, r: Double, arcStart: Double, arcDeg: Double, width: Float) {
|
||||||
// dissect the circle
|
// dissect the circle
|
||||||
val pathLen = (arcDeg * r).absoluteValue
|
val pathLen = (arcDeg * r).absoluteValue
|
||||||
//// estimated number of segments. pathLen divided by sqrt(2)
|
//// estimated number of segments. pathLen divided by sqrt(2)
|
||||||
@@ -165,7 +180,7 @@ class ActorConveyors : ActorWithBody {
|
|||||||
val x2 = r * sin(degEnd) + xc
|
val x2 = r * sin(degEnd) + xc
|
||||||
val y2 = r * cos(degEnd) + yc
|
val y2 = r * cos(degEnd) + yc
|
||||||
|
|
||||||
drawLineOnWorld(x1, y1, x2, y2)
|
drawLineOnWorld(x1, y1, x2, y2, width)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user