Fun MouseY Dilemma!

4 views
Skip to first unread message

Zach Grafton

unread,
May 2, 2018, 5:00:38 PM5/2/18
to Processing.js
Hi all, first time begging for programming advice from strangers EVER, but I'm sure we'll all be family soon.

I'm doing one of the Coding Train challenges - Minesweeper, but I've hit a wall where when I click on a box in-game, the mouse seems to click on the box above it (in Chrome and IE). I assume this is related to MouseY? Anyone know how to fix this?

At this point, my code is identical to the original code here - https://github.com/CodingTrain/website/tree/master/CodingChallenges/CC_71_minesweeper

Thanks in advance!

Lee Brunjes

unread,
May 2, 2018, 5:15:23 PM5/2/18
to proces...@googlegroups.com
So, typically this is caused by an off by one error in your code. The above linked code seems good on first glance.

I haven't done a bunch of p5.js work but my guess is that their mouseY is probably correct.

The easy debug step is to draw a rectangle at mouseX, mouseY as well as the coords. If it shows up not under the mouse something bad is happening. If it shows up right check your logic in the cell.js contains method and the mouse event loops.

Hope that helps a bit.
Lee


--
You received this message because you are subscribed to the Google Groups "Processing.js" group.
To unsubscribe from this group and stop receiving emails from it, send an email to processingjs...@googlegroups.com.
To post to this group, send email to proces...@googlegroups.com.
Visit this group at https://groups.google.com/group/processingjs.
For more options, visit https://groups.google.com/d/optout.

Zach Grafton

unread,
May 2, 2018, 8:39:01 PM5/2/18
to Processing.js
Thank you so much! I had a tiny error in my contains method and you pointed me right toward it. You're a hero and the world needs more of you.
Reply all
Reply to author
Forward
0 new messages