Hey forum, sometimes when I’m working on a particularly graphics oriented sketch it will all of a sudden start to behave very strange with no apparent cause.
Has this ever happened to anyone else? I have a sketch that’s doing it right now. I can link a github to it if anyone wants to try to see what’s wrong. I haven’t been able to figure it out myself, but it seems to be related to using different rendering methods…
The bug appears to be happening in the display() method, particularly the raytrace() method.
What should happen: by pressing the arrow keys, the player moves around and the screen updates. Do not click the mouse as it may result in out of bounds exception.
What happens instead: screen updates, but then doesn’t?
I have not received an index out of bounds error yet but I think I found the trouble with no display.
At the end of draw(), change the last bit to:
if (mousePressed) {
int X = mouseX/32-10+x;
int Y = mouseY/32-9+y;
if (mouseButton==LEFT) {
tiles[X][Y][z]=(byte)selector;
} else {
tiles[X][Y][z]=1;
}
//onWorldUpdate();
handleMove();
}
display();
Also add handleMove(); at the end of setup() to initialize.
Indeed, the noSmooth() call appears to affect how the frame is initialized with each call of draw().
If we force the render by calling display(), it seems okay.