This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.
  • Index
  •  » Miscellaneous
  •  » ANYONE. I MEAN ANYONE. Help me (3D math question with AS2 involved...)

#1 2010-10-22 07:50:50

juststickman
Scratcher
Registered: 2009-05-31
Posts: 1000+

ANYONE. I MEAN ANYONE. Help me (3D math question with AS2 involved...)

Code:

var zP;
var xP;
var yP;
var xC;
var yC;
var caX;
var caZ;
var caRH;
// camera rotation (horizontal) ^_^
var size;
var map = new Array();
map.push(new Array());
map.push(new Array());
map.push(new Array());
map[0].push("1");
map[0].push("1");
map[0].push("1");
map[0].push("1");
map[1].push("1");
map[1].push("1");
map[1].push("1");
map[2].push("1");
map[2].push("1");
map[2].push("1");
map[2].push("1");
map[2].push("1");
trace(map);
trace(map[0][0]);
trace(map[0][1]);
trace(map[1][1]);
trace(map[2][4])
trace(map[2][5])
trace("---");
//s = size
//ca = camera
function onLoad() {

    this.createEmptyMovieClip("cube",this.getNextHighestDepth());
    this.createEmptyMovieClip("cube",this.getNextHighestDepth());
    cube.lineStyle(1,0x00FF00,100,true,"none","round","miter",1);
    moveX = 0;
    moveZ = 0;
    size = 32;
    trace(map[0][1]);
}
function onEnterFrame() {
    cube.clear();
    cube.lineStyle(0.5,0x00FF00,100,true,"none","round","miter",1);
    if (Key.isDown(Key.UP)) {
        moveZ -= 1;
    }
    if (Key.isDown(Key.RIGHT)) {
        moveX -= 1;
    }
    if (Key.isDown(Key.DOWN)) {
        moveZ += 1;
    }
    if (Key.isDown(Key.LEFT)) {
        moveX += 1;
    }
    
    j = -1;
    while (j<map.length) {
        trace(i);
        j++
        trace(map[1][i]);
        i = 0
        while (i<map[j].length) {
            trace(i);
            if ((map[j][i] == 1) && (50+(16*j)+moveZ>1)) {
                xP = 0+(i*32)+moveX;
                yP = 50;
                zP = 50+(16*j)+moveZ;
                xP -= size/2;
                yP -= size/2;
                convert();
                cube.moveTo(xC,yC);
                xP += size;
                yP += 0;
                zP += 0;
                convert();
                cube.lineTo(xC,yC);
                xP += 0;
                yP += size;
                zP += 0;
                convert();
                cube.lineTo(xC,yC);
                xP -= size;
                yP += 0;
                zP += 0;
                convert();
                cube.lineTo(xC,yC);
                xP += 0;
                yP -= size;
                zP += 0;
                convert();
                cube.lineTo(xC,yC);
                xP += 0;
                yP += 0;
                zP += size/2;
                convert();
                cube.lineTo(xC,yC);
                //SECOND LAYER!
                convert();
                xP += size;
                yP += 0;
                zP += 0;
                convert();
                cube.lineTo(xC,yC);
                xP += 0;
                yP += size;
                zP += 0;
                convert();
                cube.lineTo(xC,yC);
                xP -= size;
                yP += 0;
                zP += 0;
                convert();
                cube.lineTo(xC,yC);
                xP += 0;
                yP -= size;
                zP += 0;
                convert();
                cube.lineTo(xC,yC);
                //*********************************************************
                yP += size;
                zP -= 0;
                convert();
                cube.moveTo(xC,yC);
                yP += 0;
                zP -= size/2;
                convert();
                cube.lineTo(xC,yC);
                yP += 0;
                xP += size;
                zP -= -size/2;
                convert();
                cube.moveTo(xC,yC);
                yP += 0;
                zP -= size/2;
                convert();
                cube.lineTo(xC,yC);
                yP -= size;
                xP += 0;
                zP -= -size/2;
                convert();
                cube.moveTo(xC,yC);
                yP += 0;
                zP -= size/2;
                convert();
                cube.lineTo(xC,yC);
                /*first cube done
                
                ^.^"
                
                
                
                
                */

            }
            i++;
        }
        
    }
    trace("done");


}
function convert() {
    xC = (xP*(200/zP))-(-300);
    yC = (yP*(200/zP))-(-200);
}

Yeah... I need help figuring out how to change camera rotation according to caRH (camera rotation horizontal). I've pretty much given up on trying, having a cold isn't helping.

Anyone know how to do this? Don't tell me to google it, that never helps...


http://is.gd/iBQi2 Add grob to your sig and help with world dominiation!http://is.gd/iBQ9Q                                                             Hey guys, we're seriously naming our team bob?

Offline

 

#2 2010-10-22 17:38:07

Subh
Scratcher
Registered: 2010-05-25
Posts: 100+

Re: ANYONE. I MEAN ANYONE. Help me (3D math question with AS2 involved...)

umm....... what programing language is it????

probably, you should convert the program into a scratch project, so that we can understand it better.  smile

if you need my help, just comment on any of my projects.  smile


http://wiki.scratch.mit.edu/skins/scratch/logo.png     I'M IN Scratch Wiki .... ARE YOU ????

Offline

 

#3 2010-10-22 17:38:58

BlazeAstro
Scratcher
Registered: 2009-11-29
Posts: 100+

Re: ANYONE. I MEAN ANYONE. Help me (3D math question with AS2 involved...)

gah this hurts my brain

Offline

 

#4 2010-10-22 17:41:09

juststickman
Scratcher
Registered: 2009-05-31
Posts: 1000+

Re: ANYONE. I MEAN ANYONE. Help me (3D math question with AS2 involved...)

Turn it into a scratch project... ROFL.

Ok first, give scratch 2D arrays.
Then, make loops actually work right.
After that, make saving.

And so much more...

Ok, here's the ONE thing I need:

I need a formula that takes...
-Original X position
-Original Z position

And according to camera rotation, changes the X and Z values...


http://is.gd/iBQi2 Add grob to your sig and help with world dominiation!http://is.gd/iBQ9Q                                                             Hey guys, we're seriously naming our team bob?

Offline

 

#5 2010-10-22 17:59:47

recycle49
Scratcher
Registered: 2009-12-21
Posts: 1000+

Re: ANYONE. I MEAN ANYONE. Help me (3D math question with AS2 involved...)

Good gosh, i say java script? lol ,im wrong


"Every challenge must be met, every battle must be won, and every story will end." -Me
Recycle49 December 09 - November 11 Goodbye

Offline

 

#6 2010-10-22 18:11:28

juststickman
Scratcher
Registered: 2009-05-31
Posts: 1000+

Re: ANYONE. I MEAN ANYONE. Help me (3D math question with AS2 involved...)

Actionscript 2.

Anyone look at the title?


http://is.gd/iBQi2 Add grob to your sig and help with world dominiation!http://is.gd/iBQ9Q                                                             Hey guys, we're seriously naming our team bob?

Offline

 
  • Index
  •  » Miscellaneous
  •  » ANYONE. I MEAN ANYONE. Help me (3D math question with AS2 involved...)

Board footer