Help-a-noob: Constructor undefined
in
Programming Questions
•
1 year ago
heyhey,
I'm working on a project, the purpose is to have some ellipses follow the mouse and bounce off black objects.
The background is in black and white to make it simple.
But I get this error: The constructor PVector(int,int) is undefined..
Here is my code:
- class Agent {
- PVector location;
- PVector acceleration;
- Agent() {
- location = new PVector(90,70);
- acceleration = new PVector(1,1);
- }
- void run() {
- display();
- update();
- followMouse();
- }
- void followMouse() {
- PVector target = new PVector(mouseX, mouseY);
- PVector dif = PVector.sub(target,loc);
- float distance = dif.mag();
- dif.normalize();
- dif.div(100);
- acc.add(dif);
- }
- void update() {
- vel.add(acc);
- vel.limit(7);
- loc.add(vel);
- acc = new PVector();
- }
- void display() {
- stroke(0);
- fill(255);
- ellipse(loc.x, loc.y, 10, 10);
- }
- // void botsen() {
- // if ((loc.x == 622) || (loc.x == 25))
- // {
- // vel = vel*-1; This is unimportant, thats why it has the // 's
- // }
- // }
- }
and this:
- Agent a;
- void setup() {
- size (647, 694);
- PImage img1;
- smooth();
- img1 = loadImage("Klembord01.gif");
- a = new Agent();
- }
- void draw() {
- fill(255, 10);
- PImage img1;
- img1 = loadImage("Klembord01.gif");
- image(img1, 0, 0);
- a.run();
- }
Any idea of how I can fix it?
I do not understand what it means.
1