Bawię się z biblioteką p5.js i próbuję utworzyć klasę, która będzie zawierać m.in Vector.
class Ball {
constructor() {
let height = 360;
let width = 640;
let location;
let velocity;
location = createVector(width/2, height/2);
velocity = createVector(1, 3);
}
update() {
location.add(this.velocity);
}
edges() {
if(location.x > width) location.x = 0;
if(location.x < 0) location.x = width;
if(location.y > height) location.y = 0;
if(location.y < 0) location.y = height;
}
display() {
stroke(0);
strokeWeight(2);
fill(127);
ellipse(location.x, location.y, 48, 48);
}
}
Niestety otrzymuję błąd: createVector is not defined. Próbowałem również new p5.Vector, ale też nie działa. Jak mógłbym to naprawić?