#include #include "map.h" #include "cell.h" #include "position.h" #include "worm.h" #include "renderascii.h" #include "renderpng.h" #include #include #include "image.h" #include "palette.h" #include "font.h" int main( int argc, char *argv[] ) { /* Image im( 400, 400 ); Font f("ter-u12n.bdf"); Palette pl; pl.addColor( 0, 0, 0 ); pl.addColor( 255, 0, 0 ); pl.addColor( 0, 0, 255 ); im.drawLine( 0, 12, 399, 12, 2 ); im.drawText( f, 12, 12, 1, "Hello World!yqjm (01234,56789)"); im.save("test.png", pl); return 0; */ srand( time( NULL ) ); if( argc <= 2 ) { printf( "Specify dimensions as paramters, and at least two e.g.:\n" " %s 10 10\n" " %s 5 5 5\n" " %s 10 5 8 3\n" "\n", argv[0], argv[0], argv[0] ); return 0; } Position p( argc-1 ); bool bOk = false; for( int j = 0; j < argc-1; j++ ) { int tmp = strtol( argv[j+1], NULL, 10 ); if( tmp > 1 ) { bOk = true; } p[j] = tmp; } if( !bOk ) { printf("At least one dimension must be greater than 1.\n"); return 0; } // Position p( 4, 4, 4, 4, 4 ); // Position p( 3, 5, 5, 5 ); Map m( p ); for( int j = 0; j < p.getDims(); j++ ) p[j]--; int iCount = 2; Worm **pWorm = new Worm*[iCount]; pWorm[0] = new Worm( 1, Position( p.getDims() ), m ); pWorm[1] = new Worm( 2, p, m ); /* Position t( p.getDims() ); pWorm[0] = new Worm( 1, t, m ); t[0] = p[0]; pWorm[1] = new Worm( 2, t, m ); */ while( iCount > 0 ) { for( int j = 0; j < iCount; j++ ) { if( pWorm[j]->timestep() == false ) { delete pWorm[j]; if( j < iCount-1 ) { pWorm[j] = pWorm[iCount-1]; pWorm[iCount-1] = 0; j--; } else { pWorm[j] = 0; } iCount--; } } } m.connect( 1, 2 ); // RenderAscii r( m ); RenderPng r( m ); r.render(); return 0; }