Zero Grace Megadrive: Day 2 progress review
Today was the day where I settled into a coding groove and did almost everything needed to ship. In case you're wondering, my code style has drifted over the years from "academic" to "quick and dirty". There isn't a definite style, it throws around globals willy-nilly and I copy-pasted a few things from other PICO-8 projects in(drawing perspective dots, collision response, typewriter text). Still, there's method to my madness. I framed the game code around a few common game coding ideas:
- Finite state machines. I use a simple "switch based on a variable" FSM to decide which screen I'm on, and when I transition from one to the next I run some state transition code. There are many ways in which such a simple FSM strategy won't scale, but a classic arcade game is not one of them.
- Double buffering. The game loop keeps things synchronized in a style reminiscent of Jackson Structured Programming: Processing one buffer at a time, turning that into a list of events, then passing the list of events forward. This makes it easy to manage details of collision algorithms etc. - everything's in linear order so if it's wrong, it just needs to be reordered or split up with more buffers.
- Lookup tables. I didn't need many of them in this game, but this is the fast way to specify many kinds of game design rule without thinking too hard about the algorithm.
In general I wait for code to "mature" before I try to give it much structure. As an individual contributor, copy-pasted code tends to remain manageable for quite a long while. It only becomes a serious issue once a whole team is doing it and piling up copies in huge quantities. So for game jams it's fine to duplicate things for convenience and let the code speak for itself.
The gameplay relies a lot on emergent chaos, a topic which I opened my Dive into Gaming series with. Snake et al already have some of this chaotic behavior, but the focus of this game in a mechanical sense is on giving the player a new button to play with that adds some new rules. Although it takes some precision, it's possible to land on the head of the worm and that'll give you some kind of bonus multiplier. Most of the time, jumping is just very freeing and allows for new strategies. I did think about having another button to not draw your own line earlier, but it was simple enough to merge "not draw the line" with "while you're in the air", so it's a one-button game and the only other button I might explore is turbo or some kind of power weapon - but I won't during the compo.
I have some leftover cruft in there from the collision response that's meant to let you run into NPCs to talk to them, but I was faced with the decision of whether I wanted to actually represent the worms as actors or just "special tiles" and I went with the latter - which made some things easier and other things harder, since when they're tiles, I don't have to synchronize as much, but it's harder to give them specific behaviors and I end up with some duplicated stuff around the line drawing that I had already made for the player. So I have actors and then I have a table for the "worm heads" that is regenerated whenever necessary. This will probably change when I go back and maintain the game.
Most of the difficult algorithm coding really came into play with getting finicky details of the tile grid working. That's stuff I can probably improve in a second pass. It would have been a lot simpler in retrospect to let each worm keep a memory of its entire length and then split them like a list, rather than relying mostly on the tilemap to do that.
I hated working with PICO-8's music tools, but then I came to a realization: You have to approach it SFX-first. As you might know, in PICO-8, the SFX format and the music format are the same thing, represented in different ways and exposing slightly different features. And while the SFX interface is simple and lets you craft a decent bleep-bloop noise in moments, the tracker interface is cluttered with modal elements and pattern re-usability and makes it relatively easy to become confused and wreck your previous work thinking you are working on a copy when you aren't.
So, partway through working on the music I switched from doing everything from scratch in the tracker, as I would do it if I were in OpenMPT or something, to building out some patterns in the SFX editor first and then detailing in the tracker as necessary. This went much more smoothly and quickly! Although it did seem a bit absurd to sequence melodies by clicking very precisely, that was what I started doing. And it worked. I want to give the music a second try, actually, but I think I have to move on. (I'm also thinking that of the main character image - could benefit from a better pose.)
I still have problems with PICO-8 sound in other respects - half of the oscillators are borderline unusable because of aliasing - but at least on this one, I think I get it now.
I'm going to watch BNHA and turn in now.