home *** CD-ROM | disk | FTP | other *** search
Wrap
/* F I D D L E by Doug Beeferman. V1.0; January 12, 1992 */ #include <graphics.h> #include <ctype.h> #include <stdio.h> #include <time.h> #include <stdlib.h> #define LEVELNUM 28 /* Includes title and congrats screen */ void grstart(void); /* Start gr., draw permanent elements */ void levelstart(void); /* Start up particular level */ void MakeSquare(char,char); /* Draw square at loc x,y of the grid */ int MakeShape(int,char,char,char); /* Draw piece */ void Translate(char,char,char); /* Slide piece */ char Illegal(char,char); /* Determine whether position x,y is illegal or occupied */ void LegendSelect(char,char); /* Highlight legend entry */ void Rotate(char,char); /* Rotate piece */ void BorderFlash(void); /* Flash border for illegal move */ char BeginGame(void); /* Selection screen */ char CheckWin(void); /* Determine whether square completed */ void Message(char); /* Draw blinking message of praise */ void WriteDone(char); /* Update levels bar entry w/"DONE" */ void WriteBonus(char); /* Update bonus points remaining */ void Congrats(void); /* Congrats screen */ void CongratSquare(char,char); /* Like MakeSquare but for Congrats */ char sayings[52][20]= {"Well done!\0","Incredible!\0","Way to go!\0","Great!\0", "Excellent!\0","Good work!\0","Teriffic!\0","Amazing!\0", "Wonderful!\0","Stupendous!\0","Awesome!\0","Extraordinary!\0", "Beautiful!\0","Spectacular!\0","Fantastic!\0","Outstanding!\0", "Superb!\0","Tremendous!\0","Fine job!\0","Masterfully done!\0", "Fabulous!\0","Stunning!\0","Formidable!\0","Ingenious!\0", "Astounding!\0","Unbelievable!\0", "Orientation\0","Basic four\0","Jigsaw I\0","Tribute to Tetris\0", "Jagged edge\0","UIUC\0","Jigsaw II\0","Truism\0", "Trident\0","Arrows\0","Clockwise\0","Tight squeeze\0","One good turn\0", "Magic\0","Have a good one!\0","The windmill\0","Be happy!\0", "SuperCactus\0","Cuts both ways\0","Spacemaker\0", "Misplaced\0","Think negative!\0","Holey Piece\0","Overturn\0", "Revenge of Jigsaw\0","Nightmare\0"}, clrs[11]={0,4,1,2,14,3,12,13,9,10}, levelinfo[53]= {0,15,20,20,25,30,30,30,30,35,35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,3,3,1,1,1,1,1,1,2,2,1,3,3,0, 24,8,3,3,3,3,2,2,4,4,1,1,1,1,1,1,1,1,1,2,2,3,3,1,4,0, 29,10,3,3,2,2,1,3,4,4,1,1,1,2,2,2,0, 35,12,4,2,2,4,1,0, 20,27,4,1,4,1,1,1,2,4,3,3,3,2,3,2,2,1,2,1,1,1,4,0, 20,25,2,4,3,0,-1}, /*"CONGRATS" screen*/ {4,12,4,4,3,3,3,3,2,2,0, 9,12,4,4,4,3,3,3,3,2,2,2,1,1,1,1,0, 15,12,3,3,3,3,4,4,1,1,1,1,4,4,3,3,3,3,0, 20,12,4,4,4,3,3,3,3,2,2,2,1,1,4,0, 25,16,1,1,4,1,1,4,4,3,3,2,4,3,3,0, 29,16,1,1,1,1,4,4,3,3,2,4,3,3,0, 32,12,4,2,2,4,3,3,3,3,0, 37,12,4,4,3,3,2,2,3,3,4,4,0,-1} }, level,selshape,levelsdone=0,index[255],TurnOffFlash,login[8],*filename=""; int indexptr[11],flashc,score; void main(void) {char a,i,flash=1; int x,y,timer; FILE *fptr; time_t sec1; clrscr(); textcolor(14); highvideo(); gotoxy(1,19); cprintf("F I D D L E "); textcolor(4); cprintf("A game of visualization and logic by Doug Beeferman"); printf("\n\nPlease log-in by entering your first name.\n\n\> "); scanf("%s",login); sprintf(filename,"%s.fid",login); /**/ fptr=fopen(filename,"r"); if (fptr) for (i=1; i<53; i++) status[i]=getc(fptr)-50; else for (i=27; i<53; i++) status[i]=levelinfo[i-26]; fclose(fptr); /**/ grstart(); for (i=1; i<27; i++) if (status[i]) WriteDone(i); while (BeginGame()) {setcolor(15); MakeShape(0,15,1,1); sec1=time(NULL); timer=1; flashc=0; do { while(!kbhit()) {if (flash) {flashc++; if (flashc==600) MakeShape(indexptr[selshape],clrs[selshape],1,1); if (flashc==800) {MakeShape(indexptr[selshape],15,1,1); flashc=0;}} if ((((time(NULL)-sec1)/12)>=timer)&&(status[level+26])) {timer++; if (level!=1) status[level+26]--; WriteBonus(level);}} a=getch(); if ((a>48)&&(a<(49+indexptr[0]))) { MakeShape(indexptr[selshape],clrs[selshape],1,1); setcolor(0); LegendSelect(selshape,clrs[selshape]); selshape=a-48; MakeShape(indexptr[selshape],15,1,1); setcolor(15); LegendSelect(selshape,15); flashc=0;} if (a==48) {flash=(flash)?0:1; MakeShape(indexptr[selshape],15,1,1);} if (a==0) {a=getch(); switch(a) { case 72: case -104: for (i=1; i<((a==72)?2:4); i++) Translate(selshape,0,-1); break; case 80: case -96: for (i=1; i<((a==80)?2:4); i++) Translate(selshape,0,1); break; case 75: case -101: for (i=1; i<((a==75)?2:4); i++) Translate(selshape,-1,0); break; case 77: case -99: for (i=1; i<((a==77)?2:4); i++) Translate(selshape,1,0); break; case 79: Rotate(selshape,-1); break; case 81: Rotate(selshape,1); break; }} else switch (a) { case 90: case 122: Rotate(selshape,-1); break; case 88: case 120: Rotate(selshape,1); } if (CheckWin()) {MakeShape(indexptr[selshape],clrs[selshape],1,1); Message(level-1); status[level]=1; WriteDone(level); break;} if (a==27) {for (x=0; index[x]!=-1; x++) zz[level][x]=index[x]; break;} } while (1); {setcolor(0); x=101+13*(level-1); rectangle(3,x,53,x+14);} } closegraph(); textcolor(14); if (levelsdone<26) {cprintf("S c o r e r e p o r t"); x=0; for (i=1; i<27; i++) x+=status[i]*levelinfo[i]*2; printf("\n\nLevels completed... %i Points earned... %i/%i\n\nYou have ",levelsdone,score,x); if (levelsdone==25) printf("only one level"); else printf("%i levels",26-levelsdone); printf(" yet to complete. Good luck!\n\n\n");} else {cprintf("C o n g r a t u l a t i o n s !"); printf("\n\n\nYour final score/rating... %i/",score); if (score>1599) printf("EXCELLENT"); else {if (score>1299) printf("GOOD"); else printf("FAIR");} printf("\n\n\nIf you enjoyed the game and would like Cyberbox, source code, and more (see\nthe end of FIDDLE.DOC for details), send $5 to\n\n\t\tDoug Beeferman\n\t\t904 W. Green #215\n\t\tUrbana, IL 61801"); printf("\n\nPlease report your final score code in any feedback: %i-%i-%i\n\n\n",score,score%92,score%73);} /**/ fptr=fopen(filename,"w"); for(i=1; i<53; i++) putc(status[i]+50,fptr); fclose(fptr); } char BeginGame(void) {int i; char a,str[4]; score=0; for (i=1; i<27; i++) score+=(status[i]*(status[i+26]+levelinfo[i])); itoa(score,str,10); setfillstyle(1,0); bar(57,448,156,477); setcolor(4); outtextxy(80,460,str); if (levelsdone>25) {Congrats(); return 0;} level=0; TurnOffFlash=1; levelstart(); Translate(7,0,0); setcolor(15); outtextxy(210,440,"Choose a level by hitting a letter from A to Z,"); outtextxy(242,450,"or hit ESC to quit and save your score."); while (1) { if (kbhit()) {a=toupper(getch()); if (((a>64)&&(a<64+LEVELNUM))&&(!status[a-64])) {level=a-64; TurnOffFlash--; levelstart(); return 1;} else if (a==27) return 0;} i++; if (i==400) {if (index[indexptr[7]]>12) Translate(7,-1,0); else Translate(7,20,0); i=0;}} } void grstart(void) {int i,j; char str[2]=" ",str2[3]=" "; int gdriver = DETECT, gmode, errorcode; initgraph(&gdriver, &gmode, ""); _setcursortype(0); setcolor(7); rectangle(0,0,639,479); rectangle(1,1,638,478); line(2,70,637,70); line(157,2,157,477); setcolor(14); line(11,40,21,10); line(21,10,41,10); line(16,25,26,25); line(51,10,41,40); line(51,40,61,10); line(61,10,71,25); line(71,25,51,50); line(71,40,81,10); line(81,10,91,25); line(91,25,71,50); line(101,10,91,40); line(91,40,111,40); line(136,40,116,40); line(116,40,126,10); line(126,10,146,10); line(121,25,131,25); setcolor(4); outtextxy(11,55,"by Doug Beeferman"); setcolor(8); line(56,71,56,477); line(120,71,120,447); line(2,447,156,447); setcolor(7); outtextxy(300,7,"- Select a piece. 0 to toggle flash"); outtextxy(300,17,"- Slide the selected piece"); outtextxy(300,27,"- Rotate the selected piece clockwise"); outtextxy(300,37,"- Rotate counter-clockwise"); outtextxy(300,47,"- Hold down to slide more quickly"); outtextxy(300,57,"- Give up and select another level"); for (i=65; i<91; i++) { strset(str,i); outtextxy(26,105+13*(i-65),str); itoa(levelinfo[i-64],str2,10); outtextxy(62,105+13*(i-65),str2); outtextxy(80,105+13*(i-65),"+"); WriteBonus(i-64);} setcolor(15); outtextxy(9,460,"SCORE"); outtextxy(8,85,"Level Points"); outtextxy(200,7,"Number keys"); outtextxy(208,17,"Arrow keys"); outtextxy(200,27,"PageDn or X"); outtextxy(224,37,"End or Z"); outtextxy(264,47,"Alt"); outtextxy(264,57,"Esc"); } void levelstart(void) {int i,j; char shape=0,x,y,dir1,dir2,str[2]; char Lev_Dim [45]; setfillstyle(1,0); bar(195,71,605,477); if (!TurnOffFlash) { setcolor(7); sprintf(Lev_Dim,"Level: %c `%s' Dimensions: %ix%i", level+64,sayings[level+25],levelinfo[level+26],levelinfo[level+26] ); outtextxy(401-4*strlen(Lev_Dim),85,Lev_Dim); setcolor(1); i=101+13*(level-1); rectangle(3,i,53,i+14);} setcolor(8); for (i=200; i<601; i+=10) line(i,105,i,405); for (j=105; j<406; j+=10) line(200,j,600,j); for (i=0; i<40; i++) for (j=0; j<30; j++) z[i][j]=0; for (i=0; i<11; i++) indexptr[i]=0; i=-1; do {i++; index[i]=zz[level][i];} while (index[i]!=-1); i=0; while (index[i]!=-1) { shape++; indexptr[shape]=i; i=MakeShape(i,clrs[shape],1,1);} indexptr[0]=shape; selshape=1; if (!TurnOffFlash) {setcolor(15); for (i=1; i<shape+1; i++) {setfillstyle(1,clrs[i]); bar(160+i*40,425,180+i*40,444); setcolor(7); rectangle(160+i*40,425,180+i*40,444); itoa(i,str,10); outtextxy(167+i*40,455,str); } LegendSelect(1,15);} } void LegendSelect(char i,char color) { rectangle(157+40*i,420,183+40*i,469); setfillstyle(1,color); bar(164+40*i,429,176+40*i,440);} int MakeShape(int i,char color,char change,char changeto) {char dir1=0,dir2=0, x=index[i],y=index[1+i]; setfillstyle(1,color); i+=2; while (index[i]!=0) {switch(index[i]) {case 1: dir2--; break; case 2: dir1++; break; case 3: dir2++; break; case 4: dir1--; break;} ++i; if (change) {MakeSquare(x+dir1,y+dir2); z[x+dir1][y+dir2]=changeto;} else if (Illegal(x+dir1,y+dir2)) return 0;} if (change) {MakeSquare(x,y); setcolor(0); line(202+10*x,107+10*y,208+10*x,113+10*y); line(208+10*x,107+10*y,202+10*x,113+10*y); z[x][y]=changeto;} else if (Illegal(x,y)) return 0; i++; if (change) return i; else return 1; } char Illegal(char x,char y) { if ((((x<0)||(x>39))||((y<0)||(y>29))) || (z[x][y])) return 1; else return 0;} void MakeSquare(char x,char y) { bar(202+10*x,107+10*y,208+10*x,113+10*y); } void Translate(char selshape,char dir1,char dir2) {int i=indexptr[selshape]; char flash=0,affected[10]; MakeShape(i,0,1,0); flashc=-300; index[i]+=dir1; index[i+1]+=dir2; if (!MakeShape(i,0,0,0)) {index[i]-=dir1; index[i+1]-=dir2; flash++;} MakeShape(i,15,1,1); if (flash) BorderFlash(); } void Rotate(char selshape,char dir1) {int i=indexptr[selshape],j; char flash=0; MakeShape(i,0,1,0); j=i+1; flashc=-300; while (index[j+1]!=0) {j++; index[j]+=dir1; if (index[j]==5) index[j]=1; if (index[j]==0) index[j]=4;} if (!MakeShape(i,0,0,0)) {j=i+1; while (index[j+1]!=0) {j++; index[j]-=dir1; if (index[j]==5) index[j]=1; if (index[j]==0) index[j]=4;} flash++;} MakeShape(i,15,1,1); if (flash) BorderFlash(); } void BorderFlash(void) {char i,j,k; if (!TurnOffFlash) {setcolor(4); rectangle(0,0,639,479); rectangle(1,1,638,478); delay(50); setcolor(7); rectangle(0,0,639,479); rectangle(1,1,638,478);} } char CheckWin(void) {char i,j,a,b,k; for (i=0; i<40; i++) for (j=0; j<30; j++) if (z[i][j]) goto Cont; Cont: k=levelinfo[level+26]; for (a=i; a<i+k; a++) for (b=j; b<j+k; b++) if (!z[a][b]) return 0; return 1;} void Message(char mnum) {int i,j=999; setfillstyle(1,0); j=999; bar(190,410,600,472); Goback: while (!kbhit()) {j++; if (j==1000) { setcolor(15); rectangle(300,420,500,462); i=399-(strlen(sayings[mnum])*4); setcolor(14); outtextxy(i,430,sayings[mnum]); setcolor(7); outtextxy(354,444,"-Hit Enter-");} if (j==2500) {bar(300,420,500,462); j=0;} } if (getch()!=13) goto Goback;} void WriteDone(char i) { setcolor(4); outtextxy(123,105+13*(i-1),"DONE"); levelsdone++; moveto(110,107+13*(i-1)); linerel(3,5); linerel(4,-8); } void WriteBonus(char i) {char str2[3]=" "; setfillstyle(1,0); bar(92,105+13*(i-1),109,113+13*(i-1)); setcolor(7); itoa(status[i+26],str2,10); outtextxy(92,105+13*(i-1),str2);} void Congrats(void) {char h,v,a,count=0,str[20]; int i; level=LEVELNUM-1; TurnOffFlash=1; levelstart(); setcolor(15); outtextxy(183,435,"You have completed every level of Fiddle! Hit any key."); while (!kbhit()) {h=random(26)+7; v=random(24)+3; if ((count%4)==0) { setfillstyle(1,0); bar(320,85,480,96); sprintf(str,"%s",sayings[count/4]); outtextxy(401-4*(strlen(str)),85,str);} for (a=2; a<40; a++) { selshape=1; CongratSquare(h,v+a); CongratSquare(h,v-a); CongratSquare(h+a,v); CongratSquare(h-a,v); CongratSquare(h+a,v+a); CongratSquare(h-a,v-a); CongratSquare(h+a,v-a); CongratSquare(h-a,v+a); selshape=0; setfillstyle(1,0); CongratSquare(h,v+a-4); CongratSquare(h,v-a+4); CongratSquare(h+a-4,v); CongratSquare(h-a+4,v); CongratSquare(h+a-4,v+a-4); CongratSquare(h-a+4,v-a+4); CongratSquare(h+a-4,v-a+4); CongratSquare(h-a+4,v+a-4); delay(15);} count++; if (count==104) count=0;} a=getch(); } void CongratSquare(char x,char y) {if (!Illegal(x,y)) {if (selshape) setfillstyle(1,4+10*(random(2))); MakeSquare(x,y);}}