Maybe too many > characters?

Hi, I’m a noob to Processing and I was trying to create a simple circle bouncing around a screen. I got part way through to the point where I wanted it to detect when the circle got close to the edge. I started with when it got to the edge on the y-axis. I have commented out any things that are incomplete or I was using for debugging. I tried to run it to see if it would return false to see if it could tell if I hit the edge and I got this error message. here is my code:

//initalize variables
float yEdgeLocation;
float xEdgeLocation;
float circleX;
float circleY;
float circleSize;
float circleSpeed;
float yCollisionFar;
float yCollisionClose;
int windowWidth;
int windowHeight;
boolean xCheck;
boolean yCheck;

void setup() {
  //give variables start up values
  circleX = 50;
  circleY = 50;
  circleSize = 12;
  circleSpeed = 3;
  windowWidth = 640;
  windowHeight = 360;
  yEdgeLocation = circleY + circleSize;
  xEdgeLocation = circleX + circleSize;
  yCheck = true;
  xCheck = true;
  yCollisionFar = windowHeight + circleSpeed;
  yCollisionClose = windowHeight - circleSpeed;
    //set the size of the window
  size(windowWidth, windowHeight);
  //set the mode of the ellipse
  ellipseMode(RADIUS);
}

void draw() {
  //Inital movement drawing to screen
  background(50);  
  fill(225);
  ellipse(circleX, circleY, circleSize, circleSize);
  //circleX = circleX + circleSpeed;
  circleY = circleY + circleSpeed;
  //if (circleX + circleSize == windowWidth) {
    //boolean xCheck = false;
  //}
  //check collision with edge on the wall
  if (yCollisionClose =< yEdgeLocation) {
    boolean yCheck = false;
  }
  if (yEdgeLocation =< yCollisionFar) {
    boolean yCheck = false;
  }
  
  //stuff to debug
  //println("collision close", yCollisionClose, "Edgelocation", yEdgeLocation, "Collision far", yCollisionFar);
  //println("xCheck= ", xCheck);
  //println("yCheck= ", yCheck);
}

It is also important to note that I am using processing 2.2.1

1 Like

for smaller than use <= (not =<)

you need to have this
yEdgeLocation = circleY + circleSize;
xEdgeLocation = circleX + circleSize;

in draw, not in setup, because you want this to be updated when the ball moves.

When it’s in setup it’s not updated, since setup runs only once (whereas draw runs 60 times per second)

1 Like

Ok thank you so much!