rotate and move to a point
in
Programming Questions
•
1 year ago
Hi, I've been looking through the examples and the forums, but just can't seem to figure out to do this.
Basically, My game is an overhead perspective, where the user controls a man.
I want to man to rotate properly and move towards where the user clicks.
Earlier
Earlier
In the program, the targetX variable of the object is set to mouseX and targetY = mouseY.
- void draw() {
pushMatrix();
translate(width/2, height/2);
rotate(angle);
image(imgPlayer,x,y);
popMatrix();
}
void move() {
if ((targetX > 0) && (targetY > 0)) {
angle = atan2(targetY - y, targetX - x);
x += cos(angle)*1;
y+= sin(angle)*1;
}
}
1