I implemented clicking and dragging! This was somewhat more complicated than I thought it would be, but not hard in retrospect.
The clicking itself was quite easy. It was just a matter of listening for the click event, and then I implemented a function to find the position of the cell under the mouse position and toggle it.
The dragging was a bit harder, though. When I first got it working (shown in the second video), it was choppy. The main issues that I saw were:
- I can drag but it’s generally interrupted;
- dragging just a little bit repeatedly toggles the cell;
- and I can move my cursor off the window and, it will still toggle the cells but sort of wrapped around.
Interestingly, the last one only seemed to happen when I was dragging my cursor and then moved the mouse out of the window but only on the right side.
I ended up solving the issue by adding some checks and making dragging only make the cells alive. This resulted in the first video, which is much cleaner.
I like how this is turning out!
Comments 1
son
Sign in to join the conversation.