Making a class move

From the code snippet you’ve submitted, there doesn’t seem to be any movement function created inside the class at all. The class object player won’t move on its own as no instructions to move anywhere have been given.

What I’d recommend doing:

class Player {
  int xLoc;
  int yLoc;
  int playerSize;
  int speed = 25;
  Player(int tempX, int tempY)
//Constructor
     {
        xLoc = tempX;
        yLoc = tempY;
}

void drawPlayer() {
fill(120, 200, 255);
ellipse(xLoc, yLoc, 100, 100);
//draws the player at the current position.
}
void move(destinationX,destinationY){
     if(xLoc > destinationX){
         xLoc-=speed;
     } else{
         xLoc+=speed;
     }
     if(yLoc > destinationY){
         yLoc-=speed;
     } else{
         yLoc+=speed;
     }
//Check if greater than or lower than destination position, and moves towards it. 
}

}

All I’m saying is that you need to have a function inside of the class to tell it how and ‘where’ to move.

Another thing I noticed, is that you are constantly calling the position of the class inside of the draw loop. It won’t move anywhere since it is basically just being told to go to 350, 350.

Create the player object outside of the draw loop, create a movement function, and stop telling it to go to 350,350 over and over again.