Nadesican 
		
		YaBB Newbies
		 
		Offline 
		
		
		Posts: 3
		
		
		
		
 
	 
	
		
			
				Re: The moving origin?  
				Reply #4 -  Jan 30th , 2009, 10:40pm 
			 
			
				
	  
			 
		
		
			Wow, thanks. That DID help. I applied my own code to it and now I have a rotating ship that moves with the mouse. It rotates on the tip of the ship, which is kinda wierd, but acceptable.  I have a question though: I wrote up a laser function, basing the starting point of the laser at the tip of ship, and using calculations to fire along the ship's trajectory. Unfortunately...It seems to just travel from the original origin to the bottom right of the screen. What's wrong with this? int angle = 0; float lazcurX = mouseX; float lazcurY = mouseY; int i = 0; float traj = ((180 + angle)*3.14)/180 ; void setup(){   size(400,400);   smooth();   frameRate(23);   stroke(255);   noFill();   }  //This adjusts the angle of the ship  void keyPressed() {    if (key == CODED) {      if (keyCode == LEFT) {       rotate(radians(angle +5));      angle = angle +5;      }      if (keyCode == RIGHT) {        rotate(radians(angle -5));        angle = angle -5;      }}}   //The Laser Function   //The general Idea here is to add the slope, generated by the angle of the ship, to fire the lazer  // Currently, the laser is firing from the origin for some reason. Im assuming this is because Im translating the origin to the mouse pos.   void laser() {     //while (i<80){   stroke(222,255,90);       line(lazcurX, lazcurY, lazcurX + traj, lazcurY + traj);  lazcurX = lazcurX + traj; lazcurY = lazcurY + traj; //i = i + 5;   }   // Fire the laser  with a mouse click           void draw(){   background(0);  noCursor();    //Draws the ship, using push and pop matrix to adjust the origin for the ship alone  noFill();  stroke(255);   pushMatrix();     translate(mouseX,mouseY);   rotate(radians(angle));   beginShape();   vertex(-10,-20);   vertex(0,0);   vertex(+10,-20);   vertex(0,-15);   endShape(CLOSE);   popMatrix();  //Asteroids, Stationary for now  fill(177);  noStroke();  ellipse(30,040,20,20);   ellipse(200,100,40,40);   ellipse(30,200,30,30);   ellipse(100,400,20,20);   ellipse(150,300,20,20);   ellipse(300,300,20,20);   }  void mousePressed() {        laser();      }