João Costa @JD557@blog.joaocosta.eu Follow

Portuguese software engineer at Kevel.

My instance is running on a small server so please #nobot

Web

https://www.joaocosta.eu/

GitHub

https://github.com/JD557

Twitter

https://twitter.com/JD557

Itch.io

https://jd557.itch.io

  • Notes
  • Articles 6
  • Followers 41
  • Following 57
João Costa's avatar
João Costa
@JD557@blog.joaocosta.eu

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)
  }

#ScreenshotSaturday

GIF
  • permalink
  • interact from your instance
  • 1 year, 1 month ago
  • 2 likes
  • 2 shares
  • 1 reply
Likes
@vascorsd@mastodon.social @davesmith00000@mastodon.gamedev.place
Shares
@zetashift@mstdn.party @davesmith00000@mastodon.gamedev.place
davesmith00000's avatar
davesmith00000
@davesmith00000@mastodon.gamedev.place

in reply to this object

@JD557 screenshot of the formatted code needed. 😁

  • permalink
  • 1 year, 1 month ago
João Costa's avatar
João Costa
@JD557@blog.joaocosta.eu

in reply to this object

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

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

Screenshot with the formatted code
  • permalink
  • 1 year, 1 month ago
  • 1 like
  • 1 reply
davesmith00000's avatar
davesmith00000
@davesmith00000@mastodon.gamedev.place

in reply to this object

@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. 🤔

  • permalink
  • 1 year, 1 month ago
João Costa's avatar
João Costa
@JD557@blog.joaocosta.eu

in reply to this object

@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.

  • permalink
  • 1 year, 1 month ago
Powered by microblog.pub 2.0.0+dev (source code) and the ActivityPub protocol. Admin.