Skip to content

Conversation

RetiredWizard
Copy link
Contributor

@RetiredWizard RetiredWizard commented Sep 29, 2025

@makermelissa This adds the mouse "chording" (both keys pressed) feature we discussed briefly on an earlier PR.

I believe in the Microsoft version the highlighted tiles used the OPEN [ 0] sprite but I'm using the MINE_QUESTION_OPEN [15] sprite because it's not being used anywhere else and therefore I don't need to set up a separate tracking array for the highlighted cells. I could update the sprite sheet to replace the question mark with a blank open cell but I think the question mark works fine.

@RetiredWizard
Copy link
Contributor Author

This update does require adafruit/Adafruit_CircuitPython_USB_Host_Mouse#11 which was just merged so if you're testing before the new library is published you may need to grab the source from github.

@RetiredWizard
Copy link
Contributor Author

RetiredWizard commented Sep 29, 2025

I added dx, dy to _get_board because pylint didn't like the number of if statements in my new methods. Calling _get_board without the dx,dy parameters results in the method behaving exactly as it did before so there should be no further changes required.

That being said, I could also update all the existing calls to _get_board to use the new parameters reducing the number of if statements in other methods. This would result in the _get_board function being called more often which probably is not quite as speed efficient. If you like this idea, I could also update _set_board in the same way although the only place it would impact is the new square_chord_highlight method.

I could also restore the _get_board function as you originally had it and just disable the pylint too many branches check.

@RetiredWizard
Copy link
Contributor Author

Out of curiosity I asked chatgpt to help with resolving the pylint too many branches issue and it came up with this approach which I liked.

While testing I also noticed that clicking outside the game board and then moving the mouse to the board without releasing the mouse button was causing a crash so I added some tests to check for out of board clicks.

Copy link
Collaborator

@makermelissa makermelissa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Tested and works great.

@makermelissa makermelissa merged commit ad3f5a6 into adafruit:main Oct 1, 2025
4 checks passed
@RetiredWizard RetiredWizard deleted the minesweepchord branch October 1, 2025 18:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants