Skip to content

Instantly share code, notes, and snippets.

@IvanShafran
Created January 3, 2022 16:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save IvanShafran/522cbc4cb9142e900c4a3f4f04768763 to your computer and use it in GitHub Desktop.
Save IvanShafran/522cbc4cb9142e900c4a3f4f04768763 to your computer and use it in GitHub Desktop.
class AnimatedGameObject(
private val bitmaps: List<Bitmap>,
private val duration: Long
) {
fun getBitmap(timeInMillis: Long): Bitmap {
val mod = timeInMillis % duration
val index = (mod / duration.toFloat()) * bitmaps.size
return bitmaps[index.toInt()]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment