mirror of
https://github.com/The-Powder-Toy/The-Powder-Toy.git
synced 2025-08-30 19:29:52 +02:00
Shrink GOL wrapping code. GSPEED now works.
This commit is contained in:
@@ -1113,6 +1113,7 @@ int main(int argc, char *argv[])
|
||||
void *load_data=NULL;
|
||||
pixel *load_img=NULL;//, *fbi_img=NULL;
|
||||
int save_mode=0, save_x=0, save_y=0, save_w=0, save_h=0, copy_mode=0;
|
||||
GSPEED = 1;
|
||||
|
||||
#ifdef MT
|
||||
numCores = core_count();
|
||||
|
56
src/powder.c
56
src/powder.c
@@ -1230,14 +1230,15 @@ void update_particles_i(pixel *vid, int start, int inc)
|
||||
}
|
||||
}
|
||||
}
|
||||
CGOL++;
|
||||
if (ISGOL==1&&CGOL>=GSPEED)//GSPEED is frames per generation
|
||||
{
|
||||
CGOL=0;
|
||||
ISGOL=0;
|
||||
int createdsomething = 0;
|
||||
for (nx=4; nx<XRES-4; nx++)
|
||||
for (ny=4; ny<YRES-4; ny++)
|
||||
for (nx=CELL; nx<XRES-CELL; nx++)
|
||||
for (ny=CELL; ny<YRES-CELL; ny++)
|
||||
{
|
||||
CGOL=0;
|
||||
ISGOL=0;
|
||||
r = pmap[ny][nx];
|
||||
if ((r>>8)>=NPART || !r)
|
||||
{
|
||||
@@ -1252,47 +1253,13 @@ void update_particles_i(pixel *vid, int start, int inc)
|
||||
for ( nnx=-1; nnx<2; nnx++)
|
||||
for ( nny=-1; nny<2; nny++)//it will count itself as its own neighbor, which is needed, but will have 1 extra for delete check
|
||||
{
|
||||
if (ny+nny<4&&nx+nnx<4) {//any way to make wrapping code smaller?
|
||||
gol2[XRES-5][YRES-5][golnum] ++;
|
||||
gol2[XRES-5][YRES-5][0] ++;
|
||||
}
|
||||
else if (ny+nny<4&&nx+nnx>=XRES-4) {
|
||||
gol2[4][YRES-5][golnum] ++;
|
||||
gol2[4][YRES-5][0] ++;
|
||||
}
|
||||
else if (ny+nny>=YRES-4&&nx+nnx<4) {
|
||||
gol2[XRES-5][4][golnum] ++;
|
||||
gol2[XRES-5][4][0] ++;
|
||||
}
|
||||
else if (nx+nnx<4) {
|
||||
gol2[XRES-5][ny+nny][golnum] ++;
|
||||
gol2[XRES-5][ny+nny][0] ++;
|
||||
}
|
||||
else if (ny+nny<4) {
|
||||
gol2[nx+nnx][YRES-5][golnum] ++;
|
||||
gol2[nx+nnx][YRES-5][0] ++;
|
||||
}
|
||||
else if (ny+nny>=YRES-4&&nx+nnx>=XRES-4) {
|
||||
gol2[4][4][golnum] ++;
|
||||
gol2[4][4][0] ++;
|
||||
}
|
||||
else if (ny+nny>=YRES-4) {
|
||||
gol2[nx+nnx][4][golnum] ++;
|
||||
gol2[nx+nnx][4][0] ++;
|
||||
}
|
||||
else if (nx+nnx>=XRES-4) {
|
||||
gol2[4][ny+nny][golnum] ++;
|
||||
gol2[4][ny+nny][0] ++;
|
||||
}
|
||||
else {
|
||||
gol2[nx+nnx][ny+nny][golnum] ++;
|
||||
gol2[nx+nnx][ny+nny][0] ++;
|
||||
}
|
||||
gol2[((nx+nnx+XRES-3*CELL)%(XRES-2*CELL))+CELL][((ny+nny+YRES-3*CELL)%(YRES-2*CELL))+CELL][golnum] ++;
|
||||
gol2[((nx+nnx+XRES-3*CELL)%(XRES-2*CELL))+CELL][((ny+nny+YRES-3*CELL)%(YRES-2*CELL))+CELL][0] ++;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (nx=4; nx<XRES-4; nx++)
|
||||
for (ny=4; ny<YRES-4; ny++)
|
||||
for (nx=CELL; nx<XRES-CELL; nx++)
|
||||
for (ny=CELL; ny<YRES-CELL; ny++)
|
||||
{
|
||||
int neighbors = gol2[nx][ny][0];
|
||||
if (neighbors==0)
|
||||
@@ -1315,11 +1282,6 @@ void update_particles_i(pixel *vid, int start, int inc)
|
||||
if (createdsomething)
|
||||
GENERATION ++;
|
||||
}
|
||||
//if(ISWIRE==1)
|
||||
//{
|
||||
// CGOL = 0;
|
||||
// ISWIRE = 0;
|
||||
//}
|
||||
if (ISWIRE==1)
|
||||
{
|
||||
for ( q = 0; q<99; q++)
|
||||
|
Reference in New Issue
Block a user