Today we'd like to announce a new interview section on JSter. We will ask professional JS developers (and open-source) contributors to share their experience, ask for sources of their motivation.
Our guest, @borbit, has taken minesweeper the game to a completely new level. He recreated it in HTML5, making it a complete MMO game. That's right. You can play it with your friends now.
Traditionally developing this sort of games has been an arduous process. These days HTML5 based technologies have provided new alternatives as mienfield.com proves.
What is it like to build HTML5 games? Are the technologies really ready for that? In this interview @borbit shares his experience.
Hi, @borbit. How did you end up developing a MMO version of minesweeper? Can you describe the history of the project?
Hi, @bebraw. I was really inspired by guys from Massively FUN. They created an awesome game called Word2 (wordsquared.com). I liked the idea of an endless puzzle, so I've decided to build something similar. Since I am a big fan of original minesweeper game, the idea immediately came to my mind.
At the beginning, it was a "just for fun" project where I could gain some experience in modern web technologies. My friends and colleagues really liked the idea, they saw a potential in it, so that was huge motivation for me to continue working on Minefield.
What kind of technology do you use? What difficulties have you had during development and how did you solve them?
The biggest challenge for me was implementation of robust server logic. Since it was endless and multiplayer I had to care about fast field generation and preventing of race conditions. The solution to make generation fast was cutting the whole field on certain tiles with specified size (20x20 cells). This approach gave a possibility to "lazy" generate the field only where people were playing. Race conditions are being resolved on the database layer by means of compare-and-swap methodology.
On server side I use Node.js. It is a big, fast-growing platform with fantastic community behind it. Big number of rich, well tested modules let me entirely concentrate on the game implementation. It had almost everything I wanted for implementing Minefield. Also, I am very happy with choice of Redis as a database. It is lightning-fast, advanced key-value store with support of various data structures for all occasions.
On client side I had a few difficulties with graphics implementation. I had to care about speed of field rendering and animations. The whole field is represented as a grid of tiles. Since I coudn't find any suitable library for this kind of UI, I started developing Tiler. Each tile contains three Canvas elements: background layer, foreground layer and animation layer. This is a quite standard approach to canvas drawing optimization, it is being used to avoid unnecessary canvas state changes.
Where did you find the free time for this project? ;)
I've been working on Minefield at my spare time and unfortunately there is always not enough of it. I wish I had more (dreaming about full time job on HTML5 games).
What advice would you give to other JS developers thinking of building their own games?
Let's build awesome multiplayer games! You will definitely get lots of fun developing it!
Library for working with infinite grid of tiles.
A composite application framework and infrastructure for Backbone. Make your Backbone applications dance!
A Conditional Script Loader For Your Polyfills, or Regressive Enhancement With Style. A small script loader to help use feature detection to load exactly the scripts that your user needs, not just all the scripts that you think they might need.
CSS animations with a soul. With Anima it's easy to animate over a hundred objects at a time. And it's only 5k when gzipped.
A drop-in replacement for Underscore.js delivering performance, bug fixes, and additional features.