Flappy Word 'Released'
Filed Under: Game Dev
This news is about a month old by now, but: that’s right, I’m ‘done’ with Flappy Word.
Things I learned
2) Implementing the word-typing (you know, the main mechanic) taught me a fair bit.
a) Use System.Enum.Parse to convert between letters (chars) and key codes (enums) so you know which key the player should type next. I don’t understand what magic this function is performing but it’s very useful.
b) I used Resources for the dictionary file. I’ve no idea if this is the optimal way to handle big text-based data assets in Unity, but it was simple and I’ve found no reason to switch to any other method.
c) This big huge string is parsed and broken up into an array of strings, which is then sorted for length. Sorting is nice and simple thanks to an anonymous delegate:
Delegates are kind of analogous to modern C++ lambdas (wee local function objects), with differences. They can’t capture variables from their scope, but other methods can be ‘assigned’ to them (I don’t think I understand what that actually means yet).
3) Screen shake made the game feel better, but it introduced audio problems. I was using AudioSource.PlayClipAtPoint, which had worked fine up until then as a quick throwaway audio clip solution, but now that the camera (and therefore listener) was jiggling about the 3D spatialisation was noticeable, and horrible. Detaching the Listener from the camera worked, but it still bothered me that I didn’t have a method for just playing non-spatialised temporary audio clips.
So I had to write my own function which does EXACTLY what PlayClipAtPoint does but without the position and zeroing out the
spatialBlend variable. Because the Unity scripting API doesn’t have one for some reason.
4) Unity’s UI stuff is cool. My UIController script sure as hell doesn’t interface with it as gracefully as I’d like. That’s something to improve upon next time.
5) Avoid having one big monolithic script that controls everything by factoring parts of it out into separate scripts as early as possible, even if you end up attaching them all to one ‘controller’ GameObject. It’s just better that way. The mono-Monobehaviour I created was horrifying to work with until I refactored most of it out into new scripts.
Anyway, if I keep going I’ll be writing for ages. This was a surprisingly educational project.
I’ve decided to make the Bitbucket repository public. By NO means should any of the code within be imitated. It is all bad. Horrible and bad, but if you end up taking a look hopefully you can learn how not to do things.
You could clone it, or you could just download the full source in a zip file.