I have made a sketch of a car moving up and down a road. The car starts at the top and when it reaches the bottom it moves to the other lane and drives upwards, and then down again in the other lane when it reaches the top..
What I'm trying to do now is that when the car, which is an image, reaches the bottom of the road the image should flip/rotate 180 degrees, and when it reaches the top it should then rotate back 180 degrees. I've played around with translate and rotate but have yet not found a way to do this. How can I manage this?
This is my code so far:
float y;
float x;
int speed;
PImage img;
void setup(){
size(800, 800);
y = -150; // Y start position car. Car starts outside window