We are about to switch to a new forum software. Until then we have removed the registration on this forum.
So I haven't been using processing in a while now, but I need to use it for a project and I was trying to use processing with the porclipsing plugin but I get errors when running my sketch!
This is my Main:
package VectorsClass;
import processing.core.*;
public class VectorMain extends PApplet {
public static void main(String[] args) {
PApplet.main(VectorMain.class.getName());
}
public Ball ball = new Ball();
public void settings(){
size(200,200);
smooth();
}
public void setup(){
}
public void draw(){
background(0,0,0);
ball.move();
ball.bounce();
ball.draw();
}
}
This is a class I made
package VectorsClass;
import processing.core.*;
public class Ball extends PApplet {
private PVector location;
private PVector velocity;
public Ball() {
location = new PVector(width/2,height/2);
velocity = new PVector(2.5f,-2);
}
public void move(){
location.add(velocity);
}
public void bounce(){
if((location.x > width) || (location.x < 0)) {velocity.x = velocity.x * -1;}
if((location.y > height) || (location.y < 0)) {velocity.y = velocity.y * -1;}
}
public void draw(){
stroke(127);
strokeWeight(2);
fill(127);
ellipse(location.x, location.y, 48, 48);
}
}
These are the errors: Exception in thread "Animation Thread" java.lang.NullPointerException at processing.core.PApplet.stroke(PApplet.java:13758) at VectorsClass.Ball.draw(Ball.java:24) at VectorsClass.VectorMain.draw(VectorMain.java:23) at processing.core.PApplet.handleDraw(PApplet.java:2402) at processing.awt.PSurfaceAWT$12.callDraw(PSurfaceAWT.java:1527) at processing.core.PSurfaceNone$AnimationThread.run(PSurfaceNone.java:316)
Thank you for any help! I made this little sketch to see if I set everything up properly but it dose not seem to work.
Answers
I fixed it! thank you anyways!
====