I started this project a little late in the month. Initial plan was to use the Team Dogpit Jam for the February activity, but that’s been postponed because of weather troubles and power outages in Texas. My substitute project is a small scriptable text tool.
A few times a week I find myself needing to decode something in base64, wanting to pick apart a JWT token, or needing to nicely format some JSON. Sure, I can post each of these into an untrusted website or, in the base64 case, throw pbpaste | base64 --decode | pbcopy into the terminal, but I’d like something that’s fairly low resource, extensible, and serves the singular purpose of running tiny scripts on text inputs.
The proposed text tool has two fields: one for running a plugin (with autocomplete and suggestions) and another area which takes a big block of text and gets replaced with another block of text. Support for multiple scripting languages is great, but ultimately not worth it if it pushes the project past the time limit. There should be a clean, minimal UI with friendly features like autocomplete (suggest) and keyboard shortcuts for copy/paste into specific command areas.
Update: Despite the late start, I was able to wrap up this project. It’s not quite where I want it to be, but when is it ever? The full source is available on my GitHub page at https://github.com/JosephCatrambone/TextUtil . It needs a documentation pass and a lot of code cleanup, but it works. Here’s a demo of me invoking the base64 decode plugin, using a keyboard shortcut to jump back to the command entry, and invoking the ‘hello_world’ plugin.
tldr: Pitch: A physics based (soft body) sim where you drag and fling a floppy cat, Angry Birds style, through a series of levels like Sonic.
Ideation Phase: I was thinking of something roguelike, but I’m worried I’d spend too much time endlessly tweaking the procedural generation stuff and not enough time making a shippable game. I would also like to be doing this in Rust, but since it’s too hard to throw things online and deploy to mobile, I’m thinking that Godot makes the most sense. Something simple and physics based with one-finger inputs would be satisfying and approachable by my friends and family. Perhaps Pikuniku meets JellyCar.
Day 3 (Workday 1):
I spent a little too much time fiddling with verlet integration for the soft-body physics stuff. The simulation is unstable for reasons that aren’t clear and it also doesn’t really add to gameplay. It’s not a goal or even a mechanic — it’s a distraction.
Backing out, I think I’d like to use SmartShape2D with RigidBody physics, but it’s not available for Godot 4 yet, so I’ll probably do a tileset with some clever shapes. I think it might be better to have a simplified set of angles, too. It lets people predict their shots more easily.
Possible assistive features: slow down time and/or project the angles? Hmm.
Design Question: when a player drags on the cat, should the impulse applied always be central, or does it make sense to apply a torque when they grab off center? Or should there be a sweet spot where it’s “central torque” and everywhere else applies spin?
First enemy in the game was “Psychophant”, the psychotic elephant. I added a component called “rb_damage” which listens for contacts between RigidBodies. I had originally used a CharacterBody because it made sense for something that was kinematic, but there wasn’t a good way to register impacts (with velocity) on the body. After a lot of futzing there was just no convincing way to get the impacts. The get_slide_collision on CharacterBody only returns the physics objects encountered along the path of movement, so if the player bonks an enemy from behind we don’t register a hit. I gave up and said that all enemies have to be RigidBodies, then I added a meme explosion sprite on death.
I only had time to make a camera component which followed the player and the player’s direction of movement. At this point, I’m really avoiding making level geometry and more enemies because I neither want to use tilemap nor have to deal with converting Polygon2D maps to collision geometry. SmartShape2D is sadly not available for Godot 4 yet.
I finally broke down and created levels. I spent a lot of time automatically generating collision shapes from polygons so that I can remove the debug rendering. Offsets were ruining what was otherwise a fairly straightforward creation of one collision polygon per polygon2d. Ultimately, I gave up and threw a warning when the polygon had nonzero offset.
It looks like a game, at least. I added time slowing when the player taps, and it feels pretty good! However, a new problem has shown itself: Dragging the player adds an impulse, rather than explicitly setting linear velocity. This seemed like a nicer and more physics based way to do things. The problem is that when the player is in free-fall, applying a big force just brings the player to a standstill, rather than setting the linear velocity. This doesn’t feel really great, so I’m wondering if there are better choices. I could set linear velocity and let the player pivot in the air, but it’s mostly a matter of experimentation now.
I ended up setting the linear velocity if the angle was outside of some threshold. If you are travelling forward and slingshot floppy cat in the same direction, the velocities add. If you apply a linear velocity in the opposite direction, the velocity gets set. This feels pretty good, anecdotally.
I spent a while working on the title screen and level select. I’m starting to feel some hacks coming in from the UI because of how ‘main game’ is a standalone scene which does level loading. After the MainGame screen gets loaded, I don’t have a way of signaling from the level select screen that “Level 1” should be loaded, so instead I set a global variable “map to load” and then main game checks if it’s set, loads the level provided, and clears the value. Gross. Hacky. Functional.
And that leads us most of the way to a complete game. I have kill boxes to return the player to the last checkpoint, a ‘level complete’ marker at the end which will trigger the end of level sequence, and now all that remains is adding three more levels and doing a bunch of playtesting.
After hastily throwing together a bunch of levels and wiring up menus as best I could, the game is ready to ship, or at least “done sufficiently for the time provided”. It’s up and running on itch.io at https://xoana.itch.io/floppy-cat-saves-the-world . Making the last levels feel fun was a challenge, both because of the way that they were structured (using polygons) and because of viewport limitations in Godot itself. I found that I couldn’t scroll past +4000 in either direction, which, when your viewport is 1k by 1k, makes for a bit of a tricky cap. I think if I had to do it again I’d shrink the viewport significantly and do scaling. This would help with the texturing, too, as all of them ended up looking really tiny in the final shipped product. I also didn’t finish the ending cinematic or hidden ending in time, but I’m glad I got something out of the door.
Mhess is a stupid messy chess game about giving your pieces superpowers and fighting robot masters. It’s been the center of my attention for the past month or so, and it seemed fitting to share a few of the things I’m learning about the good, the bad, and the ugly of chess engine programming.
As a caveat, I deliberately did not look at any existing implementations. I was hoping that avoiding them would prevent having any pre-conceived notions about the best approach and would lead to a more novel, interesting implementation. If you’re interested in writing your own chess game, I would recommend looking at The Chess Programming Wiki.
Implementing a chess game and a chess engine are very different problems, though a chess game needs a chess engine, the design rules for a fully functional game are slightly different than those of a pure chess engine. For starters, something I had not thought about when building out the engine component was how difficult keeping the internal board representation and external board representation in sync would be. I spent a significant amount of time debugging why things in the game world would disappear or refuse to move. This challenge was compounded, or perhaps made more subtle by what I think are, in hindsight, bad decisions.
Bad Decision 1: Game State representation.
I use the following to represent a game state. It’s designed to be light weight and quick to clone so that when we start looking at trees of depth 14 we don’t blow out our compute time.
The board_state is worth highlighting. I had started with a vector of tuples of u16,Piece. That proved to be an unnecessary optimization since we always immediately converted the idx into x,y. Note that there’s a deliberate choice to have x,y in the board state and NOT inside the piece. This is done to make cloning the board state a shallow operation and really fast. Generating 11 million moves takes less than 700ms in debug mode.
A piece does not know its position in the world. Instead, a move generator takes a game state and produces a bunch of “gamemove” items. A gamemove item takes a gamestate and produces from it a new state. If this whole thing seems roundabout, that’s because it is. Complexity of defining moves is generally localized to the gamemove.rs code, but there’s a LOT of complexity to be localized. Implementing castling has been a mess because checking whether pieces are being attacked involves generating all of the possible moves for the next state. Similarly, checking for checkmate (or check) involves basically first generating the next moves and then determining which result in the king being able to be captured. This is not a great solution.
The next experiment will be a lengthy one and will probably involve trying to switch from the current gamestate + move generator to a gamestate + heavy piece system. If that works out, or if it doesn’t, I’ll be sure to post an update here.