mastodon.gamedev.place is one of the many independent Mastodon servers you can use to participate in the fediverse.
Mastodon server focused on game development and related topics.

Server stats:

5.6K
active users

This weekend I was playing around with defining an animation DSL.

I've wanted to play this for a while after watching @davesmith00000's interview for "Scala for Fun & Profit" and @kubukoz Playdate talk. Everyone's doing DSLs for gamedev! 😄

It's still quite rough, but I think it's useful for things like menu animations. Maybe I'll use something like this in the next GameJam entry to add a bit more juice to the menus.

This example looks like this:


  val backgroundAnimation = {
    linear(0, 512, 10.0).loop
      .map(delta => (delta.toInt, delta.toInt))
      .translateWrap
  }

  val baloonAnimation = {
    val rotation =
      (linear(-Math.PI / 32, Math.PI / 32, 1.0) >> linear(Math.PI / 32, -Math.PI / 32, 1.0)).rotate
    val beat =
      (easeOut(1.2, 0.9, 0.5) >> easeIn(0.9, 1.0, 0.1)).scaleXY

    (rotation && beat).loop.map(asSurfaceTransform)
  }

  val textAnimation = {
    val rotation =
      (easeIn(-Math.PI / 32, Math.PI / 32, 1.0) >> easeIn(Math.PI / 32, -Math.PI / 32, 1.0)).rotate
    val beat =
      (easeIn(1.3, 0.9, 0.5) >> easeIn(0.8, 1.0, 0.1)).scaleXY

    (rotation && beat).loop.map(asSurfaceTransform)
  }

@davesmith00000@mastodon.gamedev.place There you go!

I do need to clean up some hacks before I share the full thing. 😅

@JD557 Looks good! Not a million miles away from Indigo's.

With the benefit of hindsight, I have wondered about the wisdom of a DSL over a builder-like pattern. The latter is surely better for IDE discoverability, though obviously not as pretty to look at. 🤔

@davesmith00000@mastodon.gamedev.place Why not both? 😜

It's probably not that hard to have both a DSL and a builder just by adding a named .withX version to each operators.