Archive

Game

HuggingFace Jam 2023 happened to coincide with this month’s project. While I’d always intended to have the plan in place by the third day so I can work on it, practicality beats purity.

The theme of the jam is “expand”, which I’m going to take to mean “expand your skills”. A long time ago I wrote “The Rage of Painting” and I’m still proud of what I’ve done there. I’d like to rebuild that game to run on mobile and web platforms, and to use more of the latest advancements in computer vision.

The jam is 48 hours long, but 16 of that will be sleeping for me, at least, then add 12 hours for everything else I have to do. 20 hours of time budget.

4 hours: get a screen in Godot with the ability to draw to it and a variety of colors.

4 hours: get a text UI up and have the tutor give the prompts. (No judging yet.)

4 hours: polish the assets and work off the rough edges. Playable build uploaded to itch.io.

4 hours: try and run uploads of the image to a service for ‘judging’.

That’s 16 hours. The remaining 4 I’m going to write off as buffer.

Let’s gooooo.

Hour 1:

My first big decision is how to actually draw the points to the screen. While I’ve historically used a TextureRect and set pixels based on user mouse coordinates, I’m wondering if I should perhaps try and use a shader here to be faster and more memory efficient. I’m going to spend 30 minutes trying to figure it out before I fall back to the dumb solution (since I have some afternoon obligations).

Hour 2-3:

Unfortunately, using a shader to do the drawing was a no-go. I can’t write to the texture buffer from the shader unless I use a compute shader, and the web build doesn’t support compute shaders. Fortunately, using Image and blitting a brush works fairly well. I’m trying not to overengineer the brushes by adding support for movement speed, brush dynamics, etc. Perhaps I’ll come back and add that.

Hour 4:

I did end up adding some interpolation to the brush to help with smoothness. I thought there might be an issue with the number of substeps, but it still performs okay. I did a build and uploaded it to itch.io to make sure everything was fine on the web and it works even better there.

Hours 5-48:

Things have developed, not necessarily for the better. A planned visit to scout a new apartment and short stay at a birthday party turned into a full day and a half adventure. My Sundays are spoken for already, leaving no time to complete most anything. This was perhaps a complete failure.

I found myself also unable to get motivated enough to carry on with the project through the rest of the month, between disenchantment, apartment hunting, and life in general. I’m going to call July a failure and start again.

The Team DogPit 2023 Jam kicked off this month! It remains my favorite annual jam, though this year I had to scale back the planned game because I was out on a trip for the first half. I ended up submitted a game called “Odd Soul” which you can play here: https://xoana.itch.io/odd-soul

The theme was, “The Odds are Good,” and while I had initially planned a game where you have to DM for a bunch of players who keep rolling terribly, the game seemed too far removed and complicated to execute.

I pivoted to something of a visual novel, planning to make a game with multiple endings whose story junctions depended not just on text but also games of Rock, Paper, Scissors. The mechanics for Rock, Paper, Scissors I stole from someone I saw on Twitter:

The gameplay turned out to be too hard to manage. There’s too much visual noise for the player to really figure out what they’re doing and the action can either be too fast-paced or too boring. There wasn’t really an in-between I found.

Nonetheless, I kept with the visual novel system and, after struggling with a story that was ENTIRELY too complicated and serious for a fun game, I stumbled upon the idea of playing Death for your eternal soul. Mild spoiler: Death plays perfectly for most rounds of the game, but every so often there’s a small chance that it will make a mistake. One-shot, your odds of winning a game are in the tens of thousands, but play often enough and you’re basically guaranteed to win.

When I got tired of working on minigames I went back to writing story and bumbling through possible endings. It’s far from the finest bit of writing, but it works well enough for the game and expected playtime.

I am slightly pleased with how robust the visual novel format is. A user can create an arbitrary story as a JSON file and the application will detect and run that, so new stories can be made (with new visual assets) with no code.

The story JSON is fairly simple: { "scenes": { ... all scenes ... }, "assets": { ... all assets ...}

With the average scene looking like this:

"goto_apartment": {
	"background": "apartment",
	"actors": ["dog", "cat", "death"],
	"text": "[death:eyes_closed]One moment.  [death]There we are.\n[dog]Dog: *bark*\n[cat]Cat: *meow*\n[death]Oh!\nOh wow. <truncated>\n",
	"prompt": "Yeah.",
	"options": {
		"They're hungry.": "hungry",
		"They're my reason for living.  Or they were.": "reason_for_living"
	},
	"next": "",
	"on_enter": "fade_in",
	"minigame": "",
	"minigame_outcome": {

	}
},

And the average asset looking something like this:

"assets": {
	"characters": {
		"reaper": {
			"default": "png:<a base64 encoded PNG>",
			"angry": "file:path/to/a/png/alternative.png",
		}, // More characters
	},
	"backgrounds": { ... like above ... }
}

Let’s break down a scene:

The “actors” array determines the order of the portraits to be shown. In the above example, we have a scene like this:

Is it a good idea to show Death your apartment? Maybe!

The ‘text’ area then can/will highlight actors. When an actor is not speaking, they’re faded slightly and made transparent. An actor can have different emotes inline. [death:happy] will, for example, look for an image in the Death asset named “happy” and will display that where Death is. All actors need a “default” image. Convention over configuration. One additional key about the text is that switching expressions will not pause the dialog for user input. User input is only required when a newline appears in the text, so in theory we could chain several emotes together for an animation (this happens once in the story) or several scenes together to trigger actions (this also happens in the story).

The last piece to consider is how to branch. The branching will trigger after all the text is finished displaying. “options” specifies an associative array (dictionary) with the text of the choice mapping to the name of the scene. In the above, the user will see two buttons, “They’re hungry.” and “They’re my reason for living…”. Clicking “They’re hungry” will bring us to the scene named “hungry”. Another possible way to branch is to trigger a minigame by setting the “minigame” field. I have four implemented (“tictactoe”, “pong”, “random”, and “rockpaperscissors”), but only two appear in the story. (I’d meant to make more, but timing is hard.) Each minigame has to emit a signal on completion with the status: GameOutcome.WIN, GameOutcome.LOSE, or GameOutcome.DRAW. And the “minigame_outcome” has to map “win”, “lose”, and “draw” to the scenes.

I am slightly proud of the “random” game, since that starts up a minigame which immediately returns one of the outcomes and is a way to make a story branch randomly. If there’s no “text”, the scene starts up, finishes, and branches in a single frame.

If there’s no “prompt” and no “minigame”, then “next” is the scene to which we jump when the dialog is complete.

Finally, “on_enter”. This is the part I’m least fond of. “on_enter” is the name of a function to be called as soon as the scene is done loading. I’ve used it to fade_in and trigger returns to the menu, but I think these uses could be better served by inlining them. That way we don’t need separate scenes for returning to the menu or jumping to endings, and opens the possibility of setting multiple flags in the same scene.

All things told, I’m not proud of the gameplay or the art or any of it, but it’s done and I find relief in this and satisfaction in having completed another jam. The entire project is open source and available for review here: https://github.com/JosephCatrambone/DogpitJam2023

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.

Development Stream:

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?

Workday 2:

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.

Workday 3:

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.

Workday 4:

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.

Workday 5:

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.

Next Week:

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.

Final Week:

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.