Hi, i’m having a problem with the displaying of the x & z axes coordinates. it seems that when i am in postive x & z the always have negitive coordinates displaying.
it seem that the whole x n z axes have a wrong coordinates…
is there any way to solve the problem to the following code? or are there ways easier to rewrite the code?
onClipEvent (load) {
// position of origin
origin_x = 300;
origin_y = 200;
// used for perspective - distance from the viewer to the screen
D = 600;
// translation across the x- and z-axes and rotation on y-axes
var translation_x = 0;
var translation_z = 0;
var rotation_y = 0;
//set an absolute point on X- and Z-axes
var abs_x = 0, abs_y = 0;
var vmove = 0;
var x1 = 0, y1 = 0, x2 = 0, y2 = 0;
var flag = 0, flag2 = 0;
var rmove = 0;
}
onClipEvent (enterFrame)
{
if(Key.isDown(Key.DOWN))
{
// change the x- and z-axis translation of the objects according to which keys are pressed
translation_z = Key.isDown(Key.DOWN)*1-Key.isDown(Key.UP)*1;
vmove -= translation_z;
flag = 1;
}
if(Key.isDown(Key.UP))
{
// change the x- and z-axis translation of the objects according to which keys are pressed
translation_z = Key.isDown(Key.DOWN)*1-Key.isDown(Key.UP)*1;
vmove += -translation_z;
flag = 1;
}
if(Key.isDown(Key.LEFT))
{
if(vmove > 0)
{
vmove = 0;
rmove = 0;
flag = 0;
flag2 = 0;
}
// change the y-axis rotation angle according to which keys are pressed
rotation_y = Key.isDown(Key.RIGHT)*0.5-Key.isDown(Key.LEFT)*0.5;
rmove += rotation_y;
flag2 = 2;
}
if(Key.isDown(Key.RIGHT))
{
if(vmove > 0)
{
vmove = 0;
rmove = 0;
flag = 0;
flag2 = 0;
}
// change the y-axis rotation angle according to which keys are pressed
rotation_y = Key.isDown(Key.RIGHT)*0.5-Key.isDown(Key.LEFT)*0.5;
rmove += rotation_y;
flag2 = 2;
}
if(flag == 1 && flag2 == 2)
{
abs_x = translation_z * Math.sin(rmove * Math.PI/180);
abs_y = vmove * Math.cos(rmove * Math.PI/180);
x2 += abs_x;
y2 += abs_y;
flag = 0;
}
else if(flag == 1 && flag2 == 0)
{
abs_x = -translation_z * Math.sin(rmove* Math.PI/180);
abs_y = -translation_z * Math.cos(rmove * Math.PI/180);
x2 += abs_x;
y2 += abs_y;
flag = 0;
}
trace("FLAG: " + flag);
trace("FLAG2: " + flag2);
trace(x2);
trace(y2);
trace("abs_x: " + abs_x);
trace("abs_y: " + abs_y);
trace ("degree: " + (rmove * Math.PI/180));
trace("rotation: " + rmove);
trace("Movement: " + vmove);
}
thanks in advance! :tie: