Bookmark this on Hatena Bookmark
Hatena Bookmark - Nothing Beats HTML5/JavaScript Game Development for Learning to Program
Share on Facebook
Post to Google Buzz
Bookmark this on Yahoo Bookmark
Bookmark this on Livedoor Clip
Share on FriendFeed

Greetings! Alan here.

If you want to learn programming, HTML5 and JavaScript game development is your best bet for getting started.

Why? Because you can pick up object orientation…a particularly dull aspect of programming…with startling ease. Consider the game “Aegis Commander.”

In this game you attempt to shoot down missiles from the decks of the Aegis.

Everything you see displayed on this screen is an object.

What’s more, it’s ridiculously easy to write a program that uses these objects.

For instance, smoke appears behind intercepted missiles. Here’s how that smoke class is defined.

Smoke = enchant.Class.create(enchant.Sprite,{ //Belongs to Sprite class
initialize:function(x,y){
enchant.Sprite.call(this,16,16); //Initializes Sprite at 16x16
this.image = game.assets['smoke.png']; //Sets image file
stage.addChild(this); //Brings up smoke on stage
this.x = x-6; //Sets initial coordinates
this.y = y-4;
this.scaleX=0.25; //Displays smoke smaller than actual size
this.scaleY=0.25;
this.addEventListener('enterframe',this.move); //Animates every other frame with move method
this.cnt=0; //Resets countdown
},
move:function(){
this.cnt++; //Updates countdown
if(this.cnt%4==0){ //Animates smoke only once in 4 frames
this.frame++;
}
if(this.cnt>16){ //After 16 frames, self-destructs and removes this object
this.removeEventListener('enterframe',this.move);
stage.removeChild(this);
delete this;
}
}
});

And that’s it.

This was thrown together in just about 2 hours to make it in time for a weekly publication. As a result, there was no refactoring, etc…and yet we still ended up with this wonderfully simple expression.

It wasn’t long ago that it was well nigh impossible to simply program something like smoke puffing up behind a missile.

Truth be told, I’d be too chicken to try something like this in C++. I know what can happen with malloc and free cost, and the resulting fragmentation.

However, you don’t need to worry about any of that with today’s JavaScript. Elaborate care is taken to ensure storage of memory on potential user devices, and whereas in the past it was all but essential to write memory control to avoid compromising performance, in JavaScript there’s no need to stress about hardware issues. It will perform just as you wrote it.

Keio University SFC professor Toshiyuki Masui called this hardware-worry-free programming style “Luxury Programming.”

With JavaScript and HTML5, this sort of “Luxury Programming” is even possible on cell phones. I’ve been programming for a long time, and this amazes me.

In the old days programmers were locked in a constant battle with hardware, and the ability to use a machine to its limits was a sign of skill.

enchant.js was created to easily develop games using HTML5 and JavaScript along the lines of simple BASIC games. However, because web browsers and hardware have evolved so much, you can now easily write without worrying about the processing that would have been hell on BASIC.

Of course, this doesn’t mean that we’re completely free of limits. But up until now it was practically impossible to experience the process of creating a complicated, object oriented game like this.

For example, if trying to learn object orientation with Ruby or Python, the “object” in object orientation didn’t feel like a box with numbers in it or a vessel to put a method in.

At its heart object orientation was born from an image of objects exchanging messages and in the process acting harmoniously.

What we call methods today used to be called “messages,” and were born from an image of messages sent between objects.

The connection between words and images is particularly important for beginners. It is far easier to understand “objects” as things like explosions and missiles, rather than something intangible.

Class succession and polymorphism, duck typing, and other difficult-to-grasp concepts become clearer in games.

Moreover, without any particular trickery, the code you write becomes the image you see. “It turned out just as I expected.” This is exactly the experience we want beginners to have.

A game programmer can be born in just half a day, and his or her skills can grown from there. Think of this as the fast lane towards becoming an HTML5/JavaScript programmer.

Here at ARC, we’ve seen complete amateurs able to write programs that functioned just as they hoped after less than a day of studying JavaScript programming.

The act of turning programming into a puzzle, a fun riddle to be solved, allowed them to make programming their own.

We’re currently investigating the possibility of creating educational programs to help beginners learn programming basics through enchant.js.

We’ll give an educational event or two a try. If it goes well, we’ll open the program up so that anyone can host an event for their friends and coworkers in their hometown.

In any event, JavaScript is super easy and fun. That much is clear.