InitGraph(); ScaleWindow(-2.7, -2, 2.7, 2); Colour(Red); Label("a, A, s, S, d, D to rotate",-2,2); showcube(Black); //draw cube in black StepModel(); //Start the model running
//function StepModel() if(x!= "") { showcube(Cream); //Draw cube in cream to rub out old switch(x){ //Which button has been pressed? case "a": rotate(1, 2); //Rotate about the 0 axis break; case "A": rotate(2, 1); //Reverse rotate about the 0 axis break; case "s": rotate(2, 0); break; case "S": rotate(0, 2); break; case "d": rotate(0, 1); break; case "D": rotate(1, 0); break; case "z": //Zoom - reduce the distance r r = r - .1; break; case "Z": r = r + .1; break; } showcube(Black); } if (x!="q"){ setTimeout('StepModel()',40); }else{Label('Stopped',2,2);};