Skip to content

Instantly share code, notes, and snippets.

@JavadocMD
Last active August 29, 2015 14:06
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 JavadocMD/37030357f7f6bd38d173 to your computer and use it in GitHub Desktop.
Save JavadocMD/37030357f7f6bd38d173 to your computer and use it in GitHub Desktop.
Rendering spinning number wheels
// Setup the data for our elements...
lazy val stop: Stream[Float] = 3f #:: stop.map(_ + .5f)
lazy val dt: Stream[Float] = 0f #:: .10f #:: .05f #:: -.05f #:: dt
lazy val dx: Stream[Int] = Stream.from(0, 15)
// I can have as many elements as I want by adjusting this number.
val values = (stop, dt, dx).zipped.take(10)
override def render() = {
time += Gdx.graphics.getDeltaTime()
Gdx.gl.glClearColor(clear.r, clear.g, clear.b, clear.a);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
batch.begin();
// And render all of them!
values map { case (stop, offset, dx) =>
val tex = if (time > stop) w7 else anim.getKeyFrame(time + offset)
batch.draw(tex, 200 + dx, 200)
}
batch.end();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment