State of things 2022-12-12
Posted by
on .Note: This article was written by hand in HTML. I haven't gotten around to setting up any sort of proper blogging platform yet, so I'm winging it. I haven't even decided on a URL scheme for these posts yet, so don't rely on permalinks being permanent.
Progress continues on the comic. I'm still averaging about a page a day. I wanted to get a few extra pages done over the weekend but that didn't happen. Still on schedule though.
I stumbled across the Uxn virtual machine the other day thanks to a link from Hacker News. It's a fascinating little computer, and I've been obsessed with learning to program for it.
I started by following the tutorial on compudanzas but quickly wound up branching off and doing my own thing. I've now got a little one-room dungeon you can walk around:
The hardest part was figuring out collision detection, but eventually I got it working. Whenever the game tries to move the player to a new position, I first do the following:
- Correct the player's new coordinates to account for map drawing offset.
- Do some math on the coordinate to determine what map chunk they're moving into.
- Modulo the coordinate to determine the local coordinate within the chunk.
- Create a bit mask representing the coordinate within the chunk.
- Check if there's a collision between the bitmask and the bits of the chunk.
- If no collision, update the player's position to the new coordinate.
Most of the difficulty was not in determining the actual
high-level algorithm. Instead it was in diagnosing problems
caused by mixing up the commands for bytes and shorts. If
you try to SWP2
the top two values on the stack
but one of them is a byte and the other is a short, you're
going to have a confusing time.
I also ran into some confusion when trying to get the game
running at a steady framerate instead of as fast as the
application was receiving keyboard events. The code was working
with short delays between movement ticks but behaving weirdly
with delays larger than 8 ticks. Finally I realized that I was
being dumb and trying to write the delay in base-10 instead of
hex. #15
instead of #0f
for
example.
All this retro computing has me feeling nostalgic. When I was a kid, I picked up a preowned box-set of the Krynn series of Gold Box D&D games. I never got very far in any of them but they fascinated me. There wasn't enough space on the floppy disks for all of the game's prose, so it would often direct you to read numbered passages out of an included booklet. I love creative limitation like that. I'm sure it's beyond what I could accomplish with the Uxn but I'd like to make a game that evokes that same kind of feeling. Maybe I'll make something like that in Godot for the next Strawberry Jam.