Class Time!
Tonight is the first lab session for our series on learning how to program in study of games with JavaScript. Can’t wait to see everyone here in just a few hours!
Additionally, for anyone who couldn’t make the weeknight-at-7pm time slot, I’ve cleared some time this Sunday to do a repeat/additional session–Sunday, August 12th, at 3pm. You can get tickets here: https://www.wepay.com/events/intro-to-game-programming-with-javascript-weekend-edition
Or hell, just click the button:
Sunday, August 12th, 3pm – 5pm, @ Hive76 Register
Pong!
The first game is, as promised, Pong. You can see the game in action here: http://wedusc.com/games/pong.html
And you can read the source code online in my GitHub repository here: https://github.com/capnmidnight/JS_Game_Programming_Class/blob/master/pong.html
I’ll have printouts for everyone when you get here. If this is your first time trying to read code, try not to cross your eyes too much. We’ll cover how to read code along the way.
Though this game is pretty simple, it has a few interesting features…
Features!
- Stupid AI: There is a really basic AI running the second paddle. It’s pretty dumb, but the astute reader should be able to figure out how to make it tougher.
- Cross Platform: it runs in all of the latest versions of Internet Explorer, Chrome, Safari, Firefox, and Opera on Windows 7, as well as Safari on the iPad 2 and the default Web browser in Android 2.3. There is a small amount of browser-specific code to handle the difference between mouse events on desktops and touch events on mobile devices. I suspect it will run exactly the same on all of the other operating systems that these browsers run on.
- Comments: there are more comments than code in this file. Hopefully, someone reading it will get an idea of why I did many things as I did.
- Single File: everything in the game is in that file. Normally, one would split such a thing up into multiple files, but as a learning tool, I think it’s better to have everything in one file.
Wow, was surprised to find the source in pure javascript, and then realized that I’ve spent so much time using jQuery and Mootools, that my knowledge of pure js is pretty shaky. Time for me to brush up, thanks for sharing your code!