35 :
puyo.cと保存せよ!:
#include <curses.h>
#include <sys/time.h>
#include <time.h>
#define check(p,d) ((field[(p)]+field[(p)+dird[(d)]])==0)
#define set(c) do{field[pos]=puyo[0]*c;field[pos+dird[dir]]=puyo[1]*c;}while(0)
char delf[7*14],field[7*14],puyo[2],nxt[2],dird[]={-7,-1,7,1};char *puyoc[]={
" ","[-]","[@]","[!]","[*]","[#]", "///"};int pos,dir;void view(){int i,j;
for(i=1;i<14;i++)for(j=0;j<7;j++){move(i-1, j*3);printw("%s", puyoc[field[i
*7+j]]);}}int fall(){int i,j,r=0;for(i=0;i<6;i++){for(j=12;field[i+j*7]&&j>0;j
--);for(;j>0;j--)if((field[i+j*7]=field[i+j*7-7])!=0)r=1;field[i]=0;}return r;}
int delp(int p,int d){int i,j,r=1;delf[p]=d+1;for(i=0;i<4;i++){j=p+dird[i];if(j
>=0&&delf[j]<d+1&&field[p]==field[j])r+=delp(j, d);}if(d)field[p]=0;return r;}
int delpuyo(){int i,r=0;bzero(delf, 7*14);for(i=0;i<7*13;i++)if(field[i]&&field
[i]<6&&delp(i,0)>3){delp(i,1);r=1;}return r;}void main(){int i,cnt,w,f=fileno(
stdin),c;fd_set fdset,rfdset;struct timeval tv;srand(time(NULL));bzero(field,7*
14);for(i=0;i<14;i++)field[i*7+6]=6;for(i=0;i<6;i++)field[13*7+i]=6;FD_ZERO(&
fdset);FD_SET(f,&fdset);tv.tv_sec=0;tv.tv_usec=100000;initscr();noecho();cbreak
();erase();nxt[0]=((rand()/10)%5)+1;nxt[1]=((rand()/10)%5)+1;while(1){dir=0;pos
=7+3;w=10;puyo[0]=nxt[0];puyo[1]=nxt[1];nxt[0]=((rand()/10)%5)+1;move(4,24);
printw("%s",puyoc[nxt[0]]);nxt[1]=((rand()/10)%5)+1;move(3,24);printw("%s",
puyoc[nxt[1]]);while(1){rfdset=fdset;if(select(f+1,&rfdset,NULL,NULL,&tv)>0){c=
getch();if(w<10)w+=2;if(c==' '&&check(pos,(dir+1)%4))dir=(dir+1)%4;if(c=='q'&&
check(pos+7,dir))exit(0);if(c==','&&check(pos-1,dir))pos--;if(c=='.'&&check(pos
+1,dir))pos++;}else cnt++;if(check(pos+7,dir)){if(++cnt>10){pos+=7;cnt=0;}}else
{if(--w<0){set(1);break;}}set(1);view();refresh();set(0);}while(1){while(fall()
){view();refresh();usleep(100000);}usleep(300000);if(!delpuyo())break;view();
refresh();usleep(300000);}}}
ていうか俺も暇人だな。