SuperDuffMan
YaBB Newbies
Offline
Posts: 8
3D Navigation in Game!
Nov 2nd , 2006, 12:19am
Hi All, Im starting a wolf3D type game ;) BUT im trying to get my guy to move around. I want to move the guy forward then rotate around his center to face a new direction and then to move forward that way. please see my code... //=====================================================- int boxSize; float _LR,_FB,_round; void setup() { size(500, 500, P3D); frameRate(30); _LR = 0.0; _FB = 0.0; _round = 0.0; boxSize = 20; } void draw() {background(200); camera(280.29, 197.79, 48.80, 256.60, 247.29, 0.0, 0.0, 1.0, 0.0); translate(width/2,height/2,0); fill(0,125,255); box(2,2,2);//Blue pushMatrix(); //rotateY(_round); //Rotate aroune the center of the world But move from the guy translate(_LR, 0, _FB); rotateY(_round); //Rotate aroune the guy But move from the center of the world fill(50); box(2,2,3); pushMatrix(); translate(0,0,3); fill(255); box(2,2,3); popMatrix(); popMatrix(); walls(); } void keyPressed() { if (keyCode == LEFT) { _LR +=0.3; } else if (keyCode == RIGHT) { _LR -=0.3; } if (keyCode == DOWN) { _FB -=0.3; } else if (keyCode == UP) { _FB +=0.3; } if(key == '1') { _round +=0.1; } else if(key == '2') { _round -=0.1; } } void walls() { dispalyWalls(); pushMatrix(); translate(boxSize,0,0+boxSize); rotateY(-1.6); dispalyWalls(); popMatrix(); } void dispalyWalls() { pushMatrix(); fill(255,0,0); translate(0,0,-(boxSize/2)); box(boxSize,boxSize,2); popMatrix(); pushMatrix(); fill(0,255,0); translate(-(boxSize/2),0,0); rotateY(1.6); box(boxSize,boxSize,2); popMatrix(); pushMatrix(); fill(0,0,255); translate((boxSize/2),0,0); rotateY(1.6); box(boxSize,boxSize,2); popMatrix(); } //=================================================- Thanks for any help.