I normally code in python, but I decided to branch out to p5.js. I have a background. After ~4 hours, I had the semi-working model that is on github under user vraneb, repo PowerGrid. A bug occurs under situation I can’t quite figure out. The controls are as follows:
1: create a new node at the mouse, except when hovering over another, then select or connect it.
2: create a new power station at the mouse, except when hovering over another, then select or connect it.
d: delete the selected site (node or station) if selected, otherwise select the site hovered over. This is where the bug is occurring.
Any other key: select a site hovered over, or connect to the site hovered over if there is already on selected.
GitHub
The bug is a connection remaining to a nonexistent site, and disappears when the offending site is deleted.