As an exercise in making classes in p5.js, I used a piece of code from Dan Shiffman (2D Ray Casting …).
Something strange happens : when I use the code ->
class Boundary{
constructor(x1, y1, x2, y2) {
this.a =createVector(x1,y1);
this.b =createVector(x2,y2);
}
show() {
stroke(255);
line(this.a.x, this.a.y, this.b.x, this.b.y);
}
}
it generates an error : Uncaught SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode
But only when executed locally.
When used in “web editor” it runs fine !
To make it run local I have to declare it as “function” and do the declaration accordingly.
I have searched trough the forum but dit not find any working solution …
I also downloaded latest version of P5.js with no result…
Thanks for any help !
Rolembeek