0

so Here's a piece of void draw code that I can't figure out. Please explain to me what I'm doing wrong.

void draw() {
loadPixels();
int x,y,offs,u,v;
offs=0;
for (y=0;y<988;y++) {
for (x=0;x<554;x++) {
u=(utab[x][y]+voffs)&255;
v=(vtab[x][y]+uoffs)&255;
pixels[offs++]=tex.pixels[(u<<8)+v];
}
}
updatePixels();
uoffs++;
voffs++;
}

I don't get how to make the '&255' value for 'u' and 'v' random. Could somebody please explain? Cause u=(utab[x][y]+voffs)&random(0,255) or something won't work.

1 Answers1

0

You can try something like this:

u=(utab[random(554)][random(988)]+voffs)&255;

which should probably safe, although we could help you a lot more if you posted some more code...

Petros Koutsolampros
  • 2,790
  • 1
  • 14
  • 20
  • Never mind I fixed it using a new int! :D int ra = (int) random(0,250); and then I used the int for: u=(utab[x][y]+voffs)&ra; But thanks anyway!! – Pim Hoogeveen Sep 25 '13 at 16:28