lynx7

03-16-2004, 04:03 AM

Hi

I have a a screen 512x512 all contained in a lookup table so i am able to pin point any cell i want and assign a colour to it. What i need to do now is to be able to make these coloured squares move accross the screen following set rules. I am modelling salmon migration so the first objective is to get the salmon to 'swim' up the screen from their starting postion. The code i have to do what i have so far is;

#define checkImageWidth 512

#define checkImageHeight 512

GLubyte checkImage[checkImageHeight][checkImageWidth][3];

void makeCheckImage(void)

{

int i,j,r,g,b,x,y;

for (i = 0; i< checkImageHeight; i++) {

for (j = 0; j< checkImageWidth; j++) {

// r = j%4 * 255;

// r = i%255;

// g = j;

// b = 50;

checkImage[i][j][0] = (GLubyte) r;

checkImage[i][j][1] = (GLubyte) g;

checkImage[i][j][2] = (GLubyte) b;

}

}

int sea, fish, pred, nents;

sea = 0; fish = 1; pred = 2; nents = 3;

GLubyte lutr[nents], lutg[nents], lutb[nents];

lutr[sea] = 20;

lutg[sea] = 80;

lutb[sea] = 200;

lutr[fish] = 150;

lutg[fish] = 200;

lutb[fish] = 230;

lutr[pred] = 200;

lutg[pred] = 50;

lutb[pred] = 50;

for (y = 0; y < 512; y++)

{

for (x = 0; x < 512; x++)

{

checkImage[y][x][0] = lutr[sea];

checkImage[y][x][1] = lutg[sea];

checkImage[y][x][2] = lutb[sea];

}

}

for (y = 0; y < 110; y++)

{

for (x = 200; x < 310; x++)

{

checkImage[y][x][0] = lutr[fish];

checkImage[y][x][1] = lutg[fish];

checkImage[y][x][2] = lutb[fish];

}

}

for (y = 383; y < 433; y++) {

for (x = 128; x < 178; x++) {

checkImage[y][x][0] = lutr[pred];

checkImage[y][x][1] = lutg[pred];

checkImage[y][x][2] = lutb[pred];

}

}

}

Do i use agents to do this? I want a ticker system that carries out a set of rules on each cell every tick. Does anyone have any idea on how to do this?

I have a a screen 512x512 all contained in a lookup table so i am able to pin point any cell i want and assign a colour to it. What i need to do now is to be able to make these coloured squares move accross the screen following set rules. I am modelling salmon migration so the first objective is to get the salmon to 'swim' up the screen from their starting postion. The code i have to do what i have so far is;

#define checkImageWidth 512

#define checkImageHeight 512

GLubyte checkImage[checkImageHeight][checkImageWidth][3];

void makeCheckImage(void)

{

int i,j,r,g,b,x,y;

for (i = 0; i< checkImageHeight; i++) {

for (j = 0; j< checkImageWidth; j++) {

// r = j%4 * 255;

// r = i%255;

// g = j;

// b = 50;

checkImage[i][j][0] = (GLubyte) r;

checkImage[i][j][1] = (GLubyte) g;

checkImage[i][j][2] = (GLubyte) b;

}

}

int sea, fish, pred, nents;

sea = 0; fish = 1; pred = 2; nents = 3;

GLubyte lutr[nents], lutg[nents], lutb[nents];

lutr[sea] = 20;

lutg[sea] = 80;

lutb[sea] = 200;

lutr[fish] = 150;

lutg[fish] = 200;

lutb[fish] = 230;

lutr[pred] = 200;

lutg[pred] = 50;

lutb[pred] = 50;

for (y = 0; y < 512; y++)

{

for (x = 0; x < 512; x++)

{

checkImage[y][x][0] = lutr[sea];

checkImage[y][x][1] = lutg[sea];

checkImage[y][x][2] = lutb[sea];

}

}

for (y = 0; y < 110; y++)

{

for (x = 200; x < 310; x++)

{

checkImage[y][x][0] = lutr[fish];

checkImage[y][x][1] = lutg[fish];

checkImage[y][x][2] = lutb[fish];

}

}

for (y = 383; y < 433; y++) {

for (x = 128; x < 178; x++) {

checkImage[y][x][0] = lutr[pred];

checkImage[y][x][1] = lutg[pred];

checkImage[y][x][2] = lutb[pred];

}

}

}

Do i use agents to do this? I want a ticker system that carries out a set of rules on each cell every tick. Does anyone have any idea on how to do this?