Sunday, August 2, 2015

Writing a Game in Pure Javascript

Javascript is pretty cool. 
It's a game. In pure js.

Recently I've been using Raphael, an SVG graphics library, to write a game in JS. This has been an amazing hands-on exercise in learning how to write decent javascript. Translation: A lot of the game's code is not decent. It works, but it's not very modular, it's not very pretty, and it's not very best-practices-y.

Still, it's been great fun. I can't think of a way better than game programming to learn js. It's almost automatically test-driven, it's very visual, and you can share the results with non-coder friends without boring them to death.

Atom has been my text editor of choice for this project. Its smooth integration with Github is no joke. (This project has also provided a little basic practice for Github, which I desperately needed.)

Atom. Pretty colors.

As of now, the game logic is fully functional. A person can load up the page and play against the computer in 1v1, 2v2, or 3v3 format. The next step? Setting up server functionality and user-login system so that people can play PVP. A ranking system would be nice!

I find myself using the Raphael documentation naturally at this point, which is a great sign of progress. (Said documentation is absolutely beautiful, by the way.) I also find that I use the game as an escape from my homework, of which I suddenly have huge amounts, due to starting my Master's degree at U of Oregon in June. The accelerated 1-year program is stressful. Is it weird that I look forward to the times when I get to go home and just code?