Engineering a Paintbrush Made of Light: Day 4

Today was mostly spent learning more concepts about P5. I’m still not exactly sure of what I’m going to be doing for my project, but I’m sure I’ll be able to think of something. I mostly learned about motion of objects, using vectors and the PVector function. I haven’t learned exactly how to use this function, but I learned how to somewhat accurately simulate gravity. I still have a long way to go, but one step at a time. Below is my most recent code:


GBall a;
PImage img;
void setup() {
a=new GBall(250,250);
}
void draw() {
a.draw();
}
class GBall { //I converted this to a class simply for practice.
PVector l; //PVector is basically combining the x and y units into one function, so it's easier
PVector v;
float g = .1;
float a = .001;
GBall(int lx, int ly) { //arguments
size(480,320);
smooth();
l = new PVector (lx, ly);
v = new PVector (3,6);
}
void draw() {
rectMode(CENTER);
img=loadImage("pingpong.png"); //background image
image(img,0,0);
ellipse(l.x,l.y,10,10);
l.x=l.x+v.x;
l.y=l.y+v.y;
if(v.y<=5) { if(mousePressed) { g=-.1; v.y=v.y+g; } //de-activate gravity...? g=.1; v.y=v.y+g; } g=g+a; println(v); if(l.x>width||l.x<0) { v.x=-v.x; } if(l.y>height||l.y<0) {
v.y=-v.y;
}
}
}