#include <allegro.h> /*              Obfuscated Code Jigsaw - Ryan Patterson */
#include <stdio.h> /*         This program is my entry into the 2004 Allegro */
#include <string.h> /*  ScreenHack competition. The game is a classic jigsaw */
/*      puzzle. Simply move pieces around to piece back together my horribly */
/*   obfuscated code. Compiles with gcc 3.3.1 and MSVC 7. Note that the file */
/* needs to be run from the same directory as its source file -- it reads in */
/*   its source as the background for the puzzle. Even has animation. Enjoy! */
int i,x,y,p=4,m=0;BITMAP*b[25],*d[25],*s,*w;char l[81],*c;k(){if((i==p-1&&p%5!=
0)||(i==p+1&&p%5!=4)||(i==p+5&&p<20)||(i==p-5&&p>4)){w=b[p];b[p]=b[i];b[i]=w;p=
i;if(!*l)++m;}}main(){FILE*f=fopen(__FILE__,"r");srand(time(NULL));allegro_init
();install_keyboard();install_mouse();set_color_depth(32);set_gfx_mode(GFX_AUT\
ODETECT_WINDOWED,640,200,0,0);s=create_bitmap(640,200);clear(s);for(i=0;i<25&&!
feof(f)&&*fgets(l,81,f);++i,*l=0){if(strlen(l)<2){--i;continue;}c=strchr(l,13);
if(!c)c=strchr(l,10);if(c)*c=0;textout(s,font,l,0,i*8,-1);}fclose(f);for(x=0;x<
5;++x)for(y=0;y<5;++y)b[y*5+x]=d[y*5+x]=create_sub_bitmap(s,x*128,y*40,128,40);
clear(b[p]);*l=1;while(!key[KEY_ESC]){if(!*l){if(!(mouse_b&1))continue;i=(mous\
e_y/40)*5+(mouse_x/128);k();i=0;for(x=0;x<5;++x)for(y=0;y<5;++y)if(b[y*5+x]!=d[
y*5+x])i=1;if(!i){textprintf(screen,font,392,168,0xff00,"You won in %d moves!",
m);rest(2000);readkey();break;}}else{textprintf(screen,font,392,168,0xff0000,"\
Randomizing... %d%%",(unsigned char)*l*100/255);rest(100);switch(rand()%4){case
0:i=p-1;break;case 1:i=p+1;break;case 2:i=p-5;break;case 3:i=p+5;break;}k();++*
l;}show_mouse(NULL);for(x=0;x<5;++x)for(y=0;y<5;++y)blit(b[y*5+x],screen,0,0,x*
128,y*40,128,40);for(x=1;x<5;++x)vline(screen,x*128,0,200,-1);for(y=1;y<5;++y)\
hline(screen,0,y*40,640,-1);show_mouse(screen);}for(i=0;i<25;++i)destroy_bitmap
(b[i]);destroy_bitmap(s);}END_OF_MAIN()/*Thanks for playing! Hope you enjoyed*/