The Metroid HTML5 remake is written in ES6/ES2015 and transpiled to ES5. It’s less advanced than it might sound, especially when you can find boilerplates with task/build runners on Github doing all the work for you so that you can focus on your project. I’m using this excellent Phaser ES6 Boilerplate but there are a few to choose between. It comes with a Gulp-script that will listen to changes and build transpiled and concated versions of your code while working, plus serve it in a local server.

This is my first tutorial. If it’s appreciated I will add more posts on different topics I think of while working on my Metroid remake. First up is how I decided code the enemies by creating a generic enemy class that extends Phaser.Sprite, and then add actual enemies as extensions of that class. This approach allows me to reuse code and to add new enemy types with limited effort focusing only on their uniqueness. I don’t want to clutter this page with full-length code from the game, but rather explain with stripped down and altered versions of the code. This is a tutorial focusing the topic in the tile, not on JavaScript (ES6/ES2015 or not) per se.

Continue reading