Hello everyone! I have a little battle arena game to show you guys:
Download links can be found here
Below is a tech write-up that I posted to the gamedev subreddit:
In 11 months and 500 cups of coffee I was able to take this (http://www.youtube.com/watch?v=iaxQhRuu9rc
) single-player world and graphics demo of mine and turn it into something like what you see up above. It's not the prettiest nor the most difficult-to-create game, but I created something that I find to be fun to play, and I learned a whole lot along the way. Also, it has just reached what I consider to be alpha, so there's still a lot of content to be added. This'll be a little post detailing the pitfalls I ran into, the little stories along the way, and why I used the stuff that I did.Programming Language
This was an easy choice for me: Java. The Computer Science classes that I took when I was in highschool 2-3 years back were the first nudge in this direction, but I didn't end up learning a whole lot from them. My previous programming experience lies mainly in Minecraft plugin development. I learned a good bit about Java while creating these plugins, so it was only a matter of time before I branched out and did my own thing. Since I didn't know any other language quite as well, Java it was.Graphics
I set out on Google to find a decent 2D library, because I sure as hell wasn't going to do 3D with the lack of knowledge that I possessed. I stumbled upon Slick2D (http://slick.ninjacave.com/
) (a library wrapped around lwjgl (http://lwjgl.org/
)), downloaded it, and stuck with it. It wasn't long before I needed UI components, and Slick wasn't much of a help in that department. It seemed that a lot of the UI libraries that I came across needed XML files to function or didn't fit what I needed, and I was stubborn about not changing my ways for them, so I set forth and created my own UI code integrated into Slick's state system.
But what of the game's aesthetic? I eventually decided on spritesheet-based ground and wall tiles and a polygonish/vectorish style for everything else. And I knew that I wanted it to be pretty colorful. Since I can't create realistic art and since polygon-drawing code isn't out of reach of my abilities, that became the plan.
RAM usage was ridiculous after I implemented the color-changing background. It wasn't too high, but it fluctuated very wildly very quickly. Through the use of a profiler and digging through Slick's code, it became apparent that Slick creates a new Color object (float red, float green, float blue, float alpha) every time you call the setColor() method. Every. Time. You know, this wouldn't have been a problem if I didn't set the color thousands of times a second to render the background. At least the fix was easy: have two static Color objects, and whenever the setColor method is called, set the floats of one of the colors, then on the next call, toggle a boolean to set the floats of the other. And back and forth and back and forth. Done and done.
On the topic of the background, I could spend a bit of time explaining how it functions. All of the little background squares are just that, opengl batched and drawn square quads. Their three color values, red/green/blue, are each determined by their own two-octave perlin noise generator. A forth two-octave generator adds some random dark spots. The red is slowly shifted down, the blue left, and the green right. The 3D looking "height" of the squares is determined by adding the red+green+blue values, and since the colors shift in different directions, a wavelike effect (http://www.youtube.com/watch?v=Gdu3b5vjTpA
) is created. The same generators are used to slightly alter the color of ground tiles. As with tiles and walls, this is a pseudo 3D effect.
) and Paint.NET (http://www.getpaint.net/
) were my very best friends.Networking
) became my library of choice, and there's not too much to say about it. It's a really nice little library that handles the dirty packet bits and bytes for you. You can register classes as packet classes, call some methods, and send objects of these classes over the net.
Player (and some spell) positions, rotations, and cooldowns are sent as UDP packets, and everything else is sent by TCP.
For months I had an issue where the client wouldn't receive UDP packets for about 20 seconds after they received ~8000-9000 of them, and this was nearly always replicatable. I had no luck trying to find errors in kryonet though, so I had the client tell the server "yo, I haven't had a position packet in a while, give me them in TCP", and this worked, but I hated doing this for obvious reasons. I updated the version of lwjgl bundled with the game the other day, and since then, I haven't had this issue. I don't know if that's the reason or if something else is, so here's to hoping it doesn't come back!Physics
I learned the ins and outs of JBox2D (http://www.jbox2d.org/
) to get physics up and running. To make sure people walk at the speed they're supposed to even with all these forces acting upon them by spells, I created a Pseudo-Force system. Every update, the player's velocity is zeroed by putting a force on him in the opposite direction of his current velocity. Then, I apply the movement speed velocity. Then, the pseudo-forces are added. Then the pseudo velocity vectors themselves are lowered to get ready for the next update. It feels kinda hacky, but it works really well and easily allows for things like removing enemy forces on you.Sound
All of my music came from Lucky Lion Studios (http://luckylionstudios.com/
). The tracks average about a minute to a minute in a half in length, so I play each one twice before moving on to the next. The main menu has its own theme, battling has faster music, and the map editor features more chill music.
I created the rest of the sound effects by making weird noises into a microphone and editing them in Audacity (http://audacity.sourceforge.net/
Warlock, a custom map for Warcraft III (http://www.youtube.com/watch?v=v2uOGQegj2c
), was the biggest inspiration of mine. It was a battle arena game that didn't have cooldowns or creeps or lanes or farming or anything, and it proved to be a big hit at LAN parties. I wanted to create something that is fun to play with friends, and the idea of a physics-based battle arena game stuck with me.Thanks!
Thank you for reading! I don't expect anyone to read this far, but it felt nice getting my story out there. Happy new year!