The making of Plasma Arena

https://ldjam.com/events/ludum-dare/39/plasma-arena plasmashot2.png

The challenge

To create a game in only C code!

The Idea

This is one of my favorite ludum dare themes ever! The Idea came immediately! I had been playing a lot of quake 3 (one of my favorite games) and had the sound of the plasma gun stuck in my head. I imagined gameplay focusing around the constant collection of ammo and a never ending barrage of skulls.

Day 1

First, I set about implementing quake 3 movement into my engine. I found the original quake 3 source code on github and copy-pasted it into the engine with a few tweaks to make it work. Air strafing and strafe jumping seemed to work, so it was time to move onto the weapon. I implemented the plasma ball as a physics object with height velocity and used sweeping collision detection to make it function correctly. I made it instanced with the size of the instance buffer object remaining static, but the contents of it changing. I was working in pure C so I had no std::vector to work with, so i opted for a solution where I allocate a fixed amount of memory for the plasma ball instances and keep a count of which ones are begin used. Then when I wanted to create a plasma ball I just upped the count variable and put the mat4 for the new instance into the next location in the array. When the max amount of plasma balls had been hit, the buffer index counter would return to zero, essentially beginning to refill the array with new values and not actually allocating any new memory. This made it extremely fast due to the lack of constant memory allocation.

Day 2

Now it was time to setup the enemies! I created a skull sprite by downloading a picture of a skull, used tools in gimp to get only the skull from the image, and then reduced the resolution of the image to make it pix elated. The final touch was to reduce the number of unique colors to make it more simplistic. I then quickly implemented a vertex shader to make the skull sprite always face the player in the 3d world. The use of sprites saved a lot on performance and allowed the use of up to 500 skulls being drawn and simulated at once (could probably simulate more if I added octree optimization for collision detection). I did the same technique of a preallocated array to create the array of mat4s for the instance buffer.