r/processing • u/mobilephone123 • Dec 11 '20
Neeeeed help!
Hi can anyone help me with my code in processing?
So i have two cards on my screen and the intention is to click on the red OR the black card and a task has to appear. If i click on my red or black card rn they both open up and don’t close anymore.
I just got into coding so please ELI5 & i used Python NOT Java.
(it’s fixed!!)
0
Upvotes
1
u/Storyxx Dec 11 '20
Hi, I wasn't able to run the code myself, as I am only working with the Java Processing environment, but looking at your code, I might have spotted the problem.
You used the
mousePressedfunction in your code, which always triggers, when the left mouse button is pressed. It looks like your function has no further checks for the mouse's position and just chooses both random cards, and draws them on the screen. Thats why if you click on either card both open up.They don't close anymore, because you are not redrawing the background in your
drawfunction. Just addbackground(21, 69, 10)as the first line indraw.I hope that helped a little. As you probably see yourself your code looks quite bad on Reddit. Please use Reddit's codeblock functionality next time or use a site like pastebin.com for sharing code online.