4th of May 2025
Whew last week was BUSY. But my goodness did it end with a bang! Over the weekend I participated in the PB&Jam GameJam as part of the New Zealand Games Festival. This little jam is a desperate race to create some semblance of a video game in 48 hours. I was participating with two good friends: Ben Kelly on Audio, whose work you can find here; and Charlie Jones on visuals, whose work you can find here.
The inspiration/theme for the Jam was “Spark”. Our initial brainstorming led us in all kinds of wild directions, (including a video game titled: Super Pets Ark, i.e., S.P.ARK) before we settled on making a space game centred around a star that is moving around to swallow up planets and smaller stars.
This was… an ambitious idea to say the least. While the gameplay itself was “simple”, we had to setup or in some way simulate gravity and the orbital movement of planets and stars in space. In addition, we had to have some system for spawning in stars and planets for the player to interact with. These were an absolute nightmare to get going in the timeframe that we had, and I spent the vast majority of our time on these two things.
For those interested in the gamedev aspects of this, the next two paragraphs outline some of the solutions we arrived at. For those uninterested, feel free to skip these next two paragraphs. For those SUPER interested feel free to check out the source code on Github.
Challenge #1. Gravity and orbital mechanics.
Gravity is simple right? There’s built in stuff in game engines that does that for you! Well… yes, there is, but these systems generally assume that gravity = down. Things fall towards the floor. They are not necessarily built for a game set in space. So, we had to calculate gravity ourselves. This requires two things – a list of the celestial objects that are pulling on each other, and to apply the force of gravity from every celestial body to every celestial body (proportional to mass). To do this, written into the code of EVERY SINGLE OBJECT IN THE GAME, is a function that checks the distance from this object to EVERY OTHER OBJECT, and then applies a force to it in that direction using the gravity equation ((G*M*m)/r^2). This worked really well! Until I tried to give planets stable orbits around stars… Turns out, there’s some slight inaccuracies with godot that make this extremely difficult. Instead, we faked it. Planets just move around stars in a set path, UNTIL the player gets close enough. When that occurs, the planet is now “destabilised”, and the gravity settings apply as normal. This works relatively well but can still cause some jankiness at times that I didn’t have the time to fix.
Challenge #2. Random generation.
We wanted the game to feel like an infinite universe (spoiler alert, we did NOT have time to do this). In order to establish some kind of random generation, we implemented a kind of cascading spawn system using godot’s nodes. The way this works is as follows: Every planet has a parent star/solar system. When the game loads, it spawns in 20 solar systems at a random distance and direction from the starting spawn. These solar system nodes each spawn a star with random amounts of heat and mass, and the stars spawn a random number of planets at a random position in orbit around them. In theory, this system could be used nearly infinitely to continue generating solar systems with new and interesting planets within them.
Despite running out of time to implement several things we initially had planned, we managed to get the thing over the line (plus some final second tweaks). You can find it, or any of the other games submitted to the PB&Jam here. Our game is Rogue Star (please read the description if you play it, some things are… unfinished).
We intend to do a little more work tweaking the game and making it feel a little bit more like… well, a game, so lookout for some further updates on that here in the future.