I recently came across some cute videos about people making websites for their partners asking them to be their valentines. I decided it would be pretty simple and that I could do it myself, but I've come across some problems. The concept is that there will be a question prompt asking if my girlfriend wants to be my valentine, and then two buttons saying yes or no. If she presses no, the button will change to something like "are you sure?" and then if its pressed again it'll change into something funny. I have the buttons made and the website is running, but in my initial testing, I found that the button gets clicked multiple times even though you only click it once. Also, I'm not quite sure how to go about changing the "no" button into what I said above. If anyone could help that would be greatly appreciated!! I'll have a video attached of the problem with pictures of my code.
#Valentines day website in p5.js
19 messages · Page 1 of 1 (latest)
draw() is called many many times per second because it's used for animation. If you check whether the mouse is down inside the animation loop, it's going to do that many times before you move your mouse up unless you're quick. Since this is a web page, I would recommend using an HTML button element (p5 also has createButton() if you'd like to make it easier) instead. Unless you plan on animating the button in ways you don't know how to do using CSS. If you do, then I would use the p5 system function mouseClicked() {} to determine the mouse clicks instead.
Wait would I throw my collision code into the mouseClicked function?
And yea I don’t know much about css
Yes, you would
Ohhh okok
Also how would you go about the button changing? Could I just use booleans or something?
Yes! I would recommend using a boolean for an "active" condition. For example, uf you want the button to react to other actions like mouse hovering, you can also use function mouseMoved() {} and use the collision detection there instead
Happy to help!
so im not quite sure what i'm doing wrong
what happens is that is changes to are you sure
once you click the no button once
but then after that it doesnt change again
i would recommend having a "numClick" variable which will count how many times it has been clicked, instead of maintaining many boolean variables