Latest Posts

Game Development, JavaScript and Codility

By
August 19, 2016

I sat down with Rafał to see what he knows about building games in JavaScript.

Rafał Ruciński (aka Fatfisz) is a recent js13k 2015 participant and Software Engineer at Codility. Js13kGames is a JavaScript coding competition for HTML5 Game Developers. The fun part of the contest is the file size limit set to 13 kilobytes.

Kos: Hey Rafał! For starters, let me ask you: what got you interested in coding games in JavaScript? What's so special about this language, why choose it over the others?

Rafał: Games and JavaScript are things I both enjoy, so it's natural for me to write games in JS. Also JavaScript is the language of the browser and the browser makes it easy to build great visuals.

JavaScript in the browser has this nice thing called `requestAnimationFrame` which other environments usually don’t have. If you want to paint something in one frame, not across multiple frames, you have to go much deeper, into the assembly language, and play with interrupts, switching buffers, and so on. And the last thing - the canvas API is simple, but still quite powerful.

Kos: Have you built many games in JavaScript before last year's js13k?

Rafał: Nope! Actually the games I submitted for the contest were the first games I’ve ever completed.

Kos: ...But not the first you’d ever started?

Rafał: Yeah... *haha* I don’t count the game I made for an assignment for a web development course. It was about connecting pairs of dots on a grid, and the lines couldn't intersect. The logic was quite fun to code. But those were my first steps, I was using jQuery and the whole thing was horrible...

Kos: SSSH, don't say that to the microphone!

Rafał: *haha* Okay, jQuery is wonderful, everyone knows it!

Kos: :-)

Rafał: Later, JavaScript game development for me was always connected with experimentation. One time I wanted to play with web workers and communication, so I started building a game where players were driving tanks; it was supposed to be a RecWar look-alike. The server was actually running in the browser and communicated over WebRTC. I worked on this about 2 years ago, and it was quite fun. Then I decided to make an RPG game, a big project that is, of course, impossible to finish...

Kos: Everyone likes starting RPG games!

Rafał: Of course! This was a team effort and the server was supposed to be written in C++. But somewhere in the middle we got a bit stuck and I started rewriting the server in Node. As I found out, there was a nice package for 2-dimensional physics that I used for collision detection. It worked very fine, I liked that I could very easily add the package and use it without trouble. You could connect to the server using websockets - because WebRTC didn't have good support in Node at the time. Then you could walk around with your character; there were some blocks and stuff that you couldn’t pass through, and you also couldn't pass through other players. The game was never finished but it was a fun experience. I’ve loved playing games since I was a kid, and I’ve wanted to create a game for almost as long as I’ve been playing them.

Kos: Was it why you ended up coding two games for one competition?

Rafał: Yes, that was the plan from the start! I wanted to quickly build small things that would be complete "products", so to say. The only problem I had was that I started two weeks late, so I had a little less time. Still, the ideas for the games were quite simple and I managed to fit exactly in the remaining time. If I had the whole month, it wouldn't be hard at all. So if you have some spare time, I encourage you to make two games instead of one, because it's twice as fun!

Kos: Did you have the ideas for both games at the beginning, or did the second idea only appear halfway into building the first game?

Rafał: I wasn't actually the author of the first idea -- it was my good friend, Bartosz Gąsowski, who thought of the reversed Sokoban. I came up with the idea for the second game right after finishing the first one, but it wasn’t complete until the end - the game was evolving while I was working on it. I’ve only gotten the idea for the Chaos meter a day before the time limit and I think it was one of the most important parts of the gameplay, as it added meaning to the game. Thanks to the Chaos meter you get a chance to redeem yourself - when you make a mistake you can learn from that, continue to play and be more careful.

Kos: What was it like after the contest? Was the hello e-mail from Codility a big surprise for you?

Rafał: It was surprising because it arrived 3 months after the contest has finished. Also it surprised me that someone could get interested in me because of the games I’ve made, especially since Codility is not even close to game development! But aside from that I was very happy because I had already heard about Codility a few years back and was already interested in working here.

While I didn't have a job during js13k - that's also why I could make two games *haha* - last September someone had finally responded positively to one of my applications, so when Codility reached out to me, I’d already landed a job as a programmer at Flow XO - a remote job, very nice people, very pleasant memories. So while I was extremely happy with the offer, at the same time I was a little tied down and decided to continue working with Flow XO.

Kos: Codility was at a particularly tight spot at that time. We really needed front-end engineers onboard, and the recruitment wasn't progressing very quickly, so we decided to attempt something new and reached out to a few js13k applicants. Some games from the contest stuck to my mind, so I went through the authors' profiles and you stood out.  I had both of your games "highlighted", one because it had this super cool time bending idea, and the other one because I was a fan of Sokoban :-) You also stood out because your GitHub profile was full of contributions to frontend projects, like Grunt plugins, but also some more nerdy things that a stereotypical Codility dev could hack on in their spare time, such as the PEG parser library. Then I thought, since you were in Warsaw, maybe you'd like to meet up here in Codility?

Rafał: Yeah, a fated meeting! But then we actually didn't meet...

Kos: *awkward silence* ... Yeah, attribute that to my inbox skills!

Rafał: Though I still had that offer in mind when I ended my little adventure in Flow XO. The last push was the Scandium Codility challenge in April. I noticed the message about hiring frontend devs in the DevTools console, so I decided to try.

Kos: So what can you say about the experience of applying to Codility? Was it as you expected, or rather something completely different?

Rafał: It was a one of a kind experience, I'd say! I haven't even heard about a screening process that would involve talking to four different people about four completely different things for an hour each. I was able to get to know Codility from a few different standpoints, not only from the technical ones, and that was a very nice experience. It also felt more humane than, say, talking about manhole covers.

Kos: That's great to hear! And what would you say about the codebase that you encountered upon your arrival? What was your first impression? Typical startup code, or...?

Rafał: *haha* It's difficult to say, because Codility is quite complex, and this complexity is necessary, because the product consists of many parts: the part facing the prospective users, the part for our customers, the part for programmers who are taking tests... Let me say it was one of the best I've ever worked with. Codility not only cares about other companies having the best coders, it also has the best coders itself. People at Codility are very enthusiastic about keeping the codebase modern and tidy, and I'm excited to be part of such a team. During the short time I've been here, we've managed to move the whole JavaScript codebase into ES6, started using modules...

Kos: I can say that together with Mohammed you actually started a crusade in Codility to make us write JavaScript in an improved way! The results, I must say, are quite astounding.

Rafał: Thanks! JavaScript is one of the most underestimated languages. There's a legacy that it will carry on for a few more years, before more people actually get to know it better. That's the problem with JavaScript, I think: most programmers who have experience with other languages come to JavaScript and they don't really learn it as a separate language. They bring patterns from other languages and the result is not that good. This recently has started to change for the better - mostly because of Node.js - and it makes me very happy. I'm also glad that Codility was welcome to the idea of adapting our code to these changes.

Kos: One last question: What would be your advice for a JavaScript developer who's thinking about taking part in this js13k?

Rafał: Just Do It! If you don't have an idea, ask a friend. Try to use the theme of the competition - don't think of it as a constraint, but as a helper, because it lets you rule out some ideas and helps to guide you to ones that are worth trying. Don't be afraid!

We're always interested in meeting talented developers who are doing cool things, like Rafał. Check out our open positions and show us what you can do!