the-doomed-posts-of-muteKi

I'm the hedgehog masque replica guy

嘘だらけ塗ったチョースト


twitter, if you must
twitter.com/the_damn_muteKi

eieio
@eieio

I finished Flappy Dird! I thought I'd spend a little time talking about how it works.

If you want all the deets you can read my blog about it here or go poke at the code here. But the gist is:

  • Maybe obvious based on the gif but: you can put emojis in filenames and finder will display them. This is useful because it's hilarious, but also because it makes drawing to the finder window way easier since spacing is consistent.
  • The directories that the game is played in contain a ton of files (that we give emoji filenames). Those files are actually symlinks to their parent directory - so double clicking on them doesn't change the directory that you're in.
  • MacOS has a "last opened" timestamp that updates when you open a directory in Finder - this means that we can detect when you double-click one of the symlinked files by repeatedly accessing the last opened timestamp (which is accessible via mdls).
  • To detect "taps" we use AppleScript, which can get the number (if any) of files currently selected in a Finder window.
  • To make double buffering work we also use AppleScript, which can tell Finder to change the directory that it's currently displaying. We alternate between showing buf1 and writing to buf2 and vice-versa. This matters a ton - without it there's a bunch of screen tearing.
  • AppleScript startup speed is awful (like 0.2 seconds or something) so the core game loop is a tiny bit of AppleScript that shells out to Python for the game logic.

I think that is most of the trickery!


You must log in to comment.

in reply to @eieio's post:

I could never have thought of doing something like this, but your explanation makes sense and I can follow all of it and I HATE IT THIS IS SO AMAZING AND DUMB.

I'm sharing this with everyone I know.

Thank you!! I’m actually so glad it is clear how it works - it’s the dumbest thing I’ve made this year but it was sooo fun and also a pretty satisfying environment to work in.