Mapping xpos to mouseX inside a class?
in
Programming Questions
•
1 year ago
I'm trying to create a series of rectangles that move from one xpos to another xpos as mouseX goes from 0 to width.
Each rectangle has a unique starting xpos and a unique final xpos so my initial attempt involved creating a separate float for each rectangle that mapped to mouseX: map(mouseX,0,width,initial,final). That works just fine, but as I get more and more complex and add more rectangles, it gets too complicated.
So for the next attempt I created a rectangle class (the rectangles are all the same size, they only move xpos) and then drew those to the screen. But I can't figure out how/where to incorporate the mapping of mouseX that I used in the initial attempt.
How can I feed data into a mapped function that can be reflected when I draw the class inside the display function?
THANKS SO MUCH!
1