We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi all,
Im once again stuck with my code, if i may ask your help one more time with the following it would be lovely.
I have three rectangles in a for loop, there is a price under one of the rectangles assigned randomly. If a user clicks on a rectangle the program will remove one rectangle that does not have a price underneath it. After that the user can select one of the two remaining rectangles again, regardless if the user has selected a winning rectangle or not the program has to remove all the rectangles after the second click. If the price is under the selected rectangle the user will get a point, if not nothing will happen.
I think i have to make an array like this:
Right now i calculate on which rectangle the user has clicked with:
println(floor (mouseX/(width/rectangles)));
Im getting more confused by the minute on how i should calculate and write program as described above. Any help will be appreciated.
Answers
it depends on your skill level
Alternatives
in theory / later you could:
of course you could use parallel arrays visible and hasPrice instead
or a class RectangleWithPrice and an array of that
What you need to do
What you need to do to move on with my code above:
Now, when rect 1 is clicked, in
mousePressed()
youcheck hasPrice1 and
set visible1 to false.
In draw display only those rects where
or so
I will give it a shot, thanks for your clear answer :)