|
-
file not found
Ugh, I always do this. Solved my own problem fairly shortly after posting. But thanks for your reply Pazil!
Apparently my problem was in try to calculate the x and y positions using the same functions. I'm guessing I only have to deal with the z-axis once, and my old code dealt with it twice, causing the errors.
So my new code has separate function for finding the x and y positions. Now, I have have no idea how flawed this attempt may or may not be, but here's the code form my latest version for those interested:
PHP Code:
var magic = 180/Math.PI; function getA(x1,y1,z1,x2,y2,z2) { var d = Math.sqrt((x2-x1)*(x2-x1)+(z2-z1)*(z2-z1)); var yd = y2-y1; var r = Math.atan2(yd,d)*magic; return r; }
function getAX(x1,z1,x2,z2) { var zd = z2-z1; var xd = x2-x1; var r = Math.atan2(xd,zd)*magic; return r; }
p0 = [-50,-50,-50]; p1 = [-50,50,-50]; p2 = [-50,-50,50]; p3 = [-50,50,50]; p4 = [50,-50,-50]; p5 = [50,50,-50]; p6 = [50,-50,50]; p7 = [50,50,50]; p8 = [0,0,0];
var x = 50; var y = 0; var z = -50;
var xa = 0; var ya = 0;
for (var n=0; _root["p"+n]; n++) { _root["p"+n][3] = "0x"+random(10)+random(10)+random(10)+random(10)+random(10)+random(10); }
onEnterFrame = function() { removeMovieClip(s); createEmptyMovieClip("s",1); z = _ymouse-180; x = _xmouse-180; if (Key.isDown(Key.UP)) y++; if (Key.isDown(Key.DOWN)) y--; if (Key.isDown(Key.LEFT)) x++; if (Key.isDown(Key.RIGHT)) x--; if (xa >= 360) xa = 0; else if (xa < 0) xa = 359; for (var n=0; _root["p"+n]; n++) { p = _root["p"+n]; s.attachMovie("a","a"+n,n); o = s["a"+n]; var c = new Color(o); c.setRGB(p[3]); x2 = getAX(x,z,p[0],p[2])+180; y2 = getA(x,y,z,p[0],p[1],p[2])+180; o._x = x2; o._y = y2; } }
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|