Dijkstra Algorithm view (Node, Edges)

librakl didn’t have background(); at start of draw(), so it looked like it worked. Because the drawing in the constructor just stayed on the screen.

  • But quark is right of course: never drawing in the constructor.

  • I would argue the second statement (never process mouse input in the constructor) though, because when he wants to generate a new node on mouse input he needs the mouse position in the constructor (or at least pass the mouse position to the constructor).

void mousePressed() {
   nodes.add(new Node(mouseX,mouseY));
}

Chrisir

1 Like