Text() overlaps itself every time draw() is called no matter what

I am trying to make Conway’s Game Of Life in Processing and everything works, but I want to have a textbox that shows how many generations have passed. I opted to use the text() command, which looks as follows:

fill(255);
textSize(16);
text("Generation " + generations, 20, height - 15);
fill(0);

This does make the “Generations: x” text, but it doesn’t dissapear frame to frame, making it look like this by the ~10th frame:

image

I tried clear() and setting the background to 0 at the start of each frame and that didn’t work. I even tried to draw a black rectangle over it before drawing the most recent text and that also didn’t work. I was thinking maybe it’s a text object, but that also doesn’t make sense. Any suggestions?

when you have background to 0 at the start of draw() we shouldn’t see this.

Only when you have a for loop inside draw in which the text() statement appears?

1 Like

I honestly don’t know what quirk of code made that happen but moving it to right before the background command fixed it.

Growing pains… I have gone through all of this with Processing and coding in general.

I keep notes now and have a personal repository of simple, working examples.

Another tip for future reference (it may come up one day):
Blurry Text Solution

:)

1 Like