Text bounce bounding box?

I tried a bunch of things but its still not working. I can’t seem to mix ints and floats so it’s I’ve tried both. The text is there but the animation is gone

String mytext = "this is a test";
float x1;
float x=x1, y=10, w=width, h=height;

float xPos = random(0, 500);
float xspeed = 10;
float direction = 1;
PFont font1;
float textStr;



void setup() {
  x1=random(0, 500);
size (350, 500);
  textStr = random(10, 20);
  
} 


void draw() {
  background (0);
  textSize(textStr);

  fill(255);
  textAlign(LEFT);
  xPos = xPos + direction*xspeed;
  text("this is a test", x, y, w, h);
  if (xPos > width) direction = -1;
  if (xPos < 0) direction = 1;
  if (xPos < 0)
    textStr = random(10, 20);
  if (xPos > width)
    textStr = random(10, 20);
} 
1 Like