mirror of
https://github.com/breezy-weather/breezy-weather.git
synced 2025-12-28 05:24:53 +00:00
Refactor: use coerceAtLeast instead of an if expression
Also makes it clear that it's the device resolution that matters for the crash, rather than the device density
This commit is contained in:
parent
e69d68d41d
commit
cdfc099891
@ -73,10 +73,9 @@ class SnowImplementor(
|
||||
-radius
|
||||
}
|
||||
|
||||
val bound = (2 * speedY).toInt()
|
||||
// Fix bound to at least two to prevent crashes on small screens (where bound would be 0) and provide
|
||||
// some variation on medium screens (where bound would always be 1 and the RNG would only give 0)
|
||||
speedX = r.nextInt(if (bound >= 2) bound else 2) - speedY
|
||||
// Fix input to nextInt to at least two to prevent crashes on low res screens (where bound would be 0)
|
||||
// and provide some variation on medium-res screens (where bound would always be 1)
|
||||
speedX = r.nextInt((2 * speedY).toInt().coerceAtLeast(2)) - speedY
|
||||
computeCenterPosition()
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user