I am a beginner coder and am trying to create a p5.js for an assessment piece. I have created this car shape using the vertex() function and have placed a mask over it. I would like to have the car move across the x-axis as though it is driving across the screen. How do I go about doing this?
Here is the link to my sketch: https://editor.p5js.org/viviannaleman/sketches/XmeMeOq_Y
I have tried to update the x-position of the car's vertices using an If statement (if x > width, x =+ 1) (Here is a link to an example of what I'm trying to achieve: https://editor.p5js.org/ri1/sketches/Hk5piJg14). However it appears to not work because of the mask I've placed on top of the object.
Is there a way around this?
Thank you in advance!
as u use in the class of car some constructor and show of the car I suggest you use a new method called update which moves the car by updating its cordinates (by little) and then show the car again. And you shoud call updateCar inside your draw code