CodingTrain / CodingTrain/Suggestion-Box
7.6 Clicking on Objects and 51.1 A* Pathfinding algorithm
- Dominant language
- No language data
- Stars
- 570
- Forks
- 85
- PR merge metrics
- No merged PRs in 30d
Description

Hi, my question is how do you click on a single cell in a say 120 x 160 grid?
I have 2 functions. One is activated when clicking on the grid:
```
function mousePressed(){
for (var i = 0; i < cols; i++) {
for (var j = 0; j < rows; j++) {
grid[i][j].clicked();
}
}
}
```
The other function activates for each cell:
```
this.clicked = function() {
var d = dist(mouseX, mouseY, this.i, this.j);
if(d < 1){
console.log("f", this.f);
}
}
```
Is there an efficient way to go about this? I can't wrap my head around how to solve this.. I'd appreciate any feedback, please. Thank you.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.