mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-14 07:36:06 +09:00
no day-night cycle on titlescreen demo
This commit is contained in:
@@ -121,6 +121,17 @@ class WorldTime(initTime: Long = 0L) {
|
||||
inline val moonPhase: Double
|
||||
get() = (TIME_T.plus(1700000L) % LUNAR_CYCLE).toDouble() / LUNAR_CYCLE
|
||||
|
||||
fun getSolarElevationAt(ordinalDay: Int, second: Int): Double {
|
||||
val TIME_T = DAY_LENGTH * ordinalDay + second
|
||||
|
||||
val x = (TIME_T % YEAR_SECONDS).toDouble() / DAY_LENGTH + 15 // decimal days. One full day = 1.0
|
||||
val d = -23.44 * cos(TWO_PI * x / YEAR_DAYS)
|
||||
|
||||
// 51.56 and 23.44 will make yearly min/max elevation to be 75deg
|
||||
// -0.2504264: a number that makes y=min when x=0 (x=0 is midnight)
|
||||
return 51.56 * sin(TWO_PI * (x - 0.2504264)) + d
|
||||
}
|
||||
|
||||
val solarElevationDeg: Double
|
||||
get() {
|
||||
val x = (TIME_T % YEAR_SECONDS).toDouble() / DAY_LENGTH + 15 // decimal days. One full day = 1.0
|
||||
|
||||
Reference in New Issue
Block a user