I’ve been spending a few hours a week for the last few weeks working on a node.js game called WordPlay. I figured I’d jot down a few notes while I’m in the experimental stage to keep track of my progress and hopefully help others start to get into node.js. If you’d like to see the current state of the project, check out my github repository.
First, a description of WordPlay. I had an idea awhile ago while working in the Interactive Retail team at iQmetrix about creating a gaming experience that customers could easily engage with in a retail setting and not require any setup or installation. I eventually came up with a boggle-clone, but one where the first person to use a set of letters to spell a word would remove those letters from the game. It would be a web application, where a “main screen” would show the game host screen with letters, team scores, etc. and clients would play using a mobile web app on their handheld devices. For a client to join and play the game, all they would have to do is scan a QR code on the main screen.
I first started wordplay as a console app awhile ago, to do some proof of concept stuff. It was simply a socket server that accepted strings and sent the gamestate as a string back to all the clients. It mostly was a test of socket communication and game logic, and didn’t take long at all to get up and running. I even used terminal to test it out :) After I had that working, I got distracted by another project and abandoned the idea for awhile.
After attending the MoSoConf Code Camp in Saskatoon where Jordan Boesch gave a websockets demo with Socket.IO, I was reinspired and that evening started up the WordPlay github repository and got a quick POC up and running using Socket.IO and Node.js. I haven’t really worked on the UI much since that first POC, but have added a bunch of working features, and once I find a designer I’ll work on making it look nice :P
Working in Node.JS
Things I’ve noticed since starting my project in Node.js:
- There are a lot of helpful resources available for popular node.js libraries. I had no problem getting set up with socket.io, express, and node within a few hours mostly relying on posts on StackOverflow. I think it helps that those libraries are so easy to use that there’s not a lot of places where things can go wrong.
- My code looks like crap. As a side effect of everything “just working”, I haven’t spent a lot of time on refactoring or writing ‘clean code’. And the callback-nature of node.js lends to a lot of nested function definitions which aren’t easy to traverse through. Spagetti code piles up really quickly in node.js, and if you’re not aware of it it’s easy to get tangled up. Some things I’m planning on doing to address that include refactoring all the gamestate logic to its own module, and writing another module to handle the communication layer on top of Socket.IO, kind of like a controller.
- Heroku deployment is killer. I ran into a few small snags that had to do with my windows environment more than anything else, but deploying a node.js app to a free Heroku instance is spectacularly easy. I highly recommend using them for any node development you’re doing. (I haven’t tried a lot of other options, like nodester or azure, though)
- User-testing is awesome. More of a general software dev comment – my game is nowhere near a usable state, but showing what I have so far to various people has given me tons of valuable feedback and ideas to implement in the app.
I’m using my project’s readme.md file to keep track of the implemented and wishlist features, and will be updating that as more things get deployed. My goal is to have a fully featured app by mid-October. Feel fee to contribute!