diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..7b05c67 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +.vscode +output.mp4 +conway.map \ No newline at end of file diff --git a/conway b/conway new file mode 100755 index 0000000..3b56df0 Binary files /dev/null and b/conway differ diff --git a/conway.c b/conway.c new file mode 100644 index 0000000..a26eb71 --- /dev/null +++ b/conway.c @@ -0,0 +1,175 @@ +#include +#include +#include +#include + +const int h=1080; +const int w=1920; +const int f=3600; +const int t=12; + +void update(unsigned char* _p1,unsigned char* _p2,int* rng){ + int a=0; + for(int i=-1;i<2;i++){ + if(*(_p1-w+i)==255){ + a++; + } + if(*(_p1+w+i)==255){ + a++; + } + if(*(_p1+i)==255&&i!=0){ + a++; + } + } + if((*rng)/(a+1)==0){ + *rng=((double)rand()/RAND_MAX)*100000; + if(*_p1==255){ + *_p2=0; + }else{ + *_p2=255; + } + return; + } + *rng-=1; + if(*_p1==0&&a==3){ + *_p2=255; + return; + } + if(*_p1==255&&a<2){ + *_p2=0; + return; + } + if(*_p1==255&&a>3){ + *_p2=0; + return; + } + if(*_p1==255){ + *_p2=255; + return; + } +} + +struct update_struct{ + int low; + int high; + int fra; + int* rng; + unsigned char* new; + unsigned char* mai; + unsigned char* frame; +}; + +void* update_thread(void* _i){ + struct update_struct _p = *(struct update_struct*)_i; + for(int he=_p.low;he<_p.high;he++){ + for(int wi=0;wi