Early Gish hacking

Add comment!

June 5th, 2010

Shortly after Alex Austin released Gish's source code, Gish got its first new public feature courtesy of FrozenCow. I find these "zero day open source contributions" really interesting. It reminds me of the immediate rush to crack DRM or to exploit a newly disclosed vulnerability, but this is unequivocally awesome, feels good, and is only motivated by positively helping the community.

With this new patch, Gish can increase or decrease its size by pressing the M and N keys, which should lead to some awesome physics based scenarios. Here's an initial YouTube video demoing it:


Early Gish hack (Watch on YouTube)

This has been merged with Sebastian Morr's GitHub fork here.

I reached out to FrozenCow and asked him if he could share any tips for would-be Gish hackers or if he could say a few words about his patches:

I had already been waiting for some time for the code to be released. So it was a great joy to finally see the post appear on Cryptic Sea's blog. On top of that, it was a great surpise to find out that someone (Sebastian) had already put the code on GitHub, which is a great site for sharing and collaborating with (open-source) code by using git as the version control system. I only had a little bit of experience with the site, so it was nice to have another 'guinea pig project' to try it out some more. Also, any change I would make could be easily used by anyone else.

Compiling in Windows

Sebastian had already done some work to make it easily compilable in Linux, but since I like my Windows development-environment better I made a project-file for Visual Studio which can be used to compile Gish in Windows. It did require me to figure out which libraries Gish uses and where I could download the right ones, but in the end that all worked out pretty well.

Workings of Gish

To describe what I've changed to the code I need to give some background of how the Gish-body, called 'Tarboy' in code, works. I know Tarboy is officially called Gish, but to get a better distinction between the game and the character, I'm going to use Tarboy to refer to the character from here. Tarboy consists of 16 particles. A particle is a point that can collide with the objects in the game and therefore has a position, velocity (speed with direction) and mass. Pairs of particles within Tarboy are held together by 'bonds'. There are different kinds of bonds used within the whole game, but you can compare the bonds within Tarboy to springs.

Gish physics illustrated
Tarboy springs illustrated.

I've enabled test-mode in Gish and made the screenshot above to illustrate how the bonds connect to the particles. You can see that each particle has 5 bonds: 1 to the opposite particle, 2 to it's neighboring particles and 2 to it's neighbor's neighbor (if you get what I mean :P). I think the bonds between "neighbor's neighbors" were needed to give Tarboy some more stability so that it doesn't collapse upon itself.

The changes

So now that you know how this works, my changes are rather simple. I decrease and increase the 'desired' size of all bonds (read springs), so that it pulls the particles inward or pushes them outward respectively. After doing so, Tarboy could grow and shrink, which was already really cool. What it didn't do though was crushing enemies more easily when Tarboy was bigger, you'd presume it would also be heavier. For this I've also changed the mass of the particles the same way as I did for the sizes of the bonds. Setting these values did not work all that well: when you changed size and pressed the 'heavy-button' the values would be overwritten. So I've added a gravityscale and used that in the physics-simulation, a somewhat dirty solution, but I had no intention of doing it the 'clean' way.

All in all the changes were only around 30 lines of code. The hardest part was getting to know the code to find where and what to change to get the behaviour I wanted. Many thanks to Cryptic Sea for opensourcing Gish and many thanks to Sebastian for putting it on Github and starting a collaborative community around the code!

You can get the binaries for Windows here to play with this hack yourself. Linux users can get the code and use 'make'.