You’ve got the right idea by putting your logic into the drawItem()
function. Basically you want to create a function that takes a position as an argument, and then you want to draw all of your shapes relative to that.
I think one thing that might be confusing you is that you have a bunch of logic at the top of your sketch. Keep in mind that this code only gets executed once, so variables like quadX1
and quadX2
are never recalculated. I think what you want to do is move that logic inside your function, so it’s recalculated each frame.
What I recommend is starting smaller. Get a function working that just draws a single point or line. Then add the next point or line. Get that working perfectly before moving on. Good luck!