Hello. I am still kind of new to processing. I have been trying to create a game with moving platform(I called it plank), balls which shoot down bricks. I am currently creating the platform and I want it to move on the x axis with my cursor when my mouse is pressed, but it does not. I would really appreciate help.
Plank myPlank;
void setup(){
size(500,500);
myPlank = new Plank();
}
void draw(){
background(0);
myPlank.display();
}
class Plank{
int xpos;
int ypos;
int l;
int w;
int col;
Plank(){
xpos = width/2;
ypos = height-(height*1/5);
l = width/10;
w = height/100;
col = 255;
}
void display() {
rectMode(CENTER);
fill(col);
rect(xpos,ypos,l,w);
}
void mousePressed(){
myPlank.move();
}
void move(){
xpos = mouseX;
if(xpos<0+l/2||xpos>width-l/2){
xpos+=l/2;
}
}
}