Isometric
Transformations - IV
        by Danko Kozar : 18 November 2004

Let's move! We need an object, some controls, and our transformation equations.

step = 2;
// --- initialization of the object-------------------
init = function () {
this.attachMovie("box", "character", 1000);
};
init();
// --- main ------------------------------------------
character.onEnterFrame = function() {
this.x += this.dirx*step;
this.y += this.diry*step;
this.z += this.dirz*step;
if (this.x<0) {
this.x = 0;
}
if (this.y<0) {
this.y = 0;
}
if (this.z<0) {
this.z = 0;
}
this._x = xFla(this.x, this.y, this.z);
this._y = yFla(this.x, this.y, this.z);
};

The object is a movie clip attached from a library. We name it's instance a "character" and give it some level (1000) - this is done with init() function.

The buttons are changing the values of X, Y and Z isometric coordinates. They set dirx, diry and dirz properties of the character to values -1, 0 and 1, using the following action (this is the action added to +X button):

on (press) {
_root.character.dirx = 1;
}
on (release, releaseOutside) {
_root.character.dirx = 0;
}
In the main program loop isometric coordinates are being transformed into plain screen coordinates and the _x and _y properties of the object are set.

[ moving objects in isometric: press the gray buttons above ]
 
Download ZIP

In the next tutorial I'll explain performing hit tests without a hitTest function, because obviously we cannot use it for hit testing in isometric projection.

Recommendation

If you like to explore the theory of arcade games, I recommend an excellent Tile based games tutorial.

Cheers!

Danko
DKOZAR.COM

page 4 of 4

 

 




SUPPORTERS:

kirupa.com's fast and reliable hosting provided by Media Temple.