/* Thank you Jesus Christ! */
#include <graphics.h>
#include <conio.h>
#include <time.h>
#include <stdlib.h>
#include <dos.h>
#include <math.h>

int main()
{
double itempr, fullcirclerad = 3.14159265*2;



int cfx, cfy;
int cfax, cfay, cfab;

int splitx, splity, splitr;
int splitxd, splityd, dopple;

unsigned long score, points = 10;

int mx, my, ms, tmy;
char *mystring;

int x = 0, y = 350, s = 5;
int barsize = 120;

int idozen[100], idz;

int cx, cy, cr;
int cxd = 0, cyd = 0;

int p = 12;

double p2;

int xshf, yshf, cpyr;

int ix, iy, ic, itemp, itemp2;
int nblocks;

char keypress = '';
char keybuf = '';

int GraphDriver = DETECT, GraphMode;
mystring = "I love you Jesus Christ without-gap!!!!!!!!!!!!";

cr = 12;
cx = 640-cr;
cy = y - cr;

srand(time(NULL));

if (registerfarbgidriver(ATT_driver_far) < 0) exit(1);
if (registerfarbgidriver(CGA_driver_far) < 0) exit(1);
if (registerfarbgidriver(EGAVGA_driver_far) < 0) exit(1);
if (registerfarbgidriver(Herc_driver_far) < 0) exit(1);
if (registerfarbgidriver(IBM8514_driver_far) < 0) exit(1);
if (registerfarbgidriver(PC3270_driver_far) < 0) exit(1);

if (registerfarbgifont (gothic_font_far) < 0) exit(1);
if (registerfarbgifont (small_font_far) < 0) exit(1);
if (registerfarbgifont (sansserif_font_far) < 0) exit(1);
if (registerfarbgifont (triplex_font_far) < 0) exit(1);

initgraph(&GraphDriver, &GraphMode, "");

clearviewport();

xshf = 280;
yshf = 402;
cpyr = 8;
setcolor(15);
outtextxy(-2+xshf, -2+yshf, "C");
setcolor(12);
circle(1+xshf, 1+yshf, cpyr);
outtextxy(12, 400, "Created using Turbo C, Copyright   Borland 1987, 1988.");
outtextxy(12, 410, "Arkanoid/Brix Rendition Demo written by Tien Khoa Nguyen");
outtextxy(12, 420, "Honour to dad Thuy Binh Nguyen");
outtextxy(12, 430, "Honour to mom Huong Thi Vu");
outtextxy(12, 440, "Love to brother Carl Anh Cuong Cao Vu");
setcolor(14);
outtextxy(12, 359, "God, Jesus Christ, is number one!");
setcolor(10);
settextstyle(2,0,8);
outtextxy(12, 370, "Jesus Christ!hehe");
settextstyle(2,0,5);
outtextxy(12, 450, "Q to quit; J moves left; L moves right.");
setcolor(5);
outtextxy(12, 468, "Thank you Jesus Christ.");
setcolor(8);
outtextxy(350,430, "Mr.Flibble & Quadko @ WWW.DOSGAMES.COM");
outtextxy(350,450, "Joris @ WWW.PLAYDOSGAMES.COM");

ms = 0;
score = 0;
dopple = 0;
DRAWBLOCK:;

if ( score == 0 )
{
splitr = cr;
splitx = 640-splitr;
splity = y-splitr;
splitxd = 1;
splityd = 1;
dopple = 0;
}

/*
ms = 0;
*/
nblocks = 36;
/*
keypress = '';
*/
ix = 0;
iy = 0;
ic = 0;
BLOCK:;
if ( ((ix*barsize) < 640) )
{
ix++;
ic = (rand()%15)+1;
setcolor(ic);
for (itemp = 0; itemp < 24; itemp++)
{
line(ix*barsize-barsize, iy+itemp, ix*barsize, iy+itemp);
}
goto BLOCK;
}
if ( (iy < 110) )
{
iy = iy + 24;
ix = 0;
goto BLOCK;
}







START:;

if ( score > 1200000000 )
{
score = 1200000000;
}
setcolor(0);
settextstyle(2, 0, 12);
outtextxy(350, 350, mystring );
ultoa(score, mystring, 10);
setcolor(9);
settextstyle(2, 0, 12);
outtextxy(350, 350, mystring );

if ( kbhit() )
{
keypress = getch();
if ( (keypress == 'j') | (keypress == 'l') )
{
keybuf = keypress;
}
}

nblocks = 0;
for (itemp = 0; itemp <= (120*5); itemp = itemp + 120)
{
for (itemp2 = 0; itemp2 <= 5; itemp2++)
{
if ( getpixel(itemp+12, (itemp2*24)+12) != 0 )
{
nblocks++;
}
}
}
if ( nblocks <= 0 )
{
setcolor(0);
settextstyle(2, 0, 12);
outtextxy(225, 200, "You win!");
for (itemp = 0; itemp < 1200; itemp++)
{
sound(itemp);
for (p2 = 0; p2 < 1200; p2 = p2 + 100)
{
}

}
nosound();

goto DRAWBLOCK;
}

if ( keypress == 'a' )
{
keypress = keybuf;
dopple = 0;
}

if ( (keypress == 'd') && (score > 0) )
{
keypress = keybuf;
dopple = 1;
if (cxd == 1)
{
splitxd = 0;
}
if (cxd == 0)
{
splitxd = 1;
}
splityd = cyd;

splitx = 640-splitr;
splity = y-splitr;



}


if (keypress == 'j')
{
if (x > 0)
{
x = x - s;
}
}
if (keypress == 'l')
{
if ( x < (640-(s+barsize+s+2+s+s+s)) )
{
x = x + s;
}
}
setcolor(0);
line(x, y, x+s, y);
setcolor(15);
line(x+s+1, y, x+s+1+barsize, y);

if (keypress == 'k')
{
if (keybuf != '')
{
keypress = keybuf;
}

if (ms != 1)
{
mx = x+s+1;
my = y;
ms = 1;
setcolor(8);
line(mx+barsize, my, mx+barsize, my-12);
}
}
if (ms == 1)
{
if ( (my-12) > 0 )
{
my = my - s;

for (tmy = 0; tmy <= (12+s); tmy = tmy + ((tmy + s)/5) )
{

if ( (getpixel(mx+barsize, my-12+tmy) != 0) )
{
sound(1200);

score = score + points;
setcolor(0);
ix = (int)( (mx+barsize)/barsize);
iy = (int)((my-12+tmy)/24);
for (itemp = 0; itemp < 24; itemp++)
{
line( (ix*barsize), (iy*24)+itemp, (ix*barsize)+barsize, (iy*24)+itemp);
}
nosound();
}

}
/*
for (idz = 0; idz < 12; idz++)
{

idozen[idz] = getpixel(mx+barsize, my-12+idz);
}
*/
setcolor(8);
line(mx+barsize, my, mx+barsize, my-12);

setcolor(0);
line(mx+barsize, my+s, mx+barsize, my);


if ( (my-12) <= 0 )
{
ms = 0;

setcolor(0);
line(mx+barsize, 0, mx+barsize, 12);

}
}
/*
for (idz = 0; idz < 12; idz++)
{
putpixel(mx+barsize, my-12+idz, idozen[idz]);
}
*/
}



setcolor(0);
line(x+s+1+barsize+1, y, x+s+1+barsize+1+s, y);

for (itempr = 0; itempr < fullcirclerad; itempr = itempr + (fullcirclerad/12) )
{
cfax = (int)((double)cx+((double)(cr*2)*cos(itempr)));
cfay = (int)((double)cy+((double)(cr*2)*sin(itempr)));
cfab = getpixel(cfax, cfay);
putpixel(cfax, cfay, 15);
putpixel(cfax, cfay, cfab);

cfx = (int)((double)cx+((double)cr*cos(itempr)));
cfy = (int)((double)cy+((double)cr*sin(itempr)));
if ( (getpixel(cfx, cfy) != 0) && ( (cy+cr) < 200) )
{
sound(1200);

score = score + points;
setcolor(0);
ix = (int)( (cfx)/barsize);
iy = (int)( (cfy)/24);
for (itemp = 0; itemp < 24; itemp++)
{
line( (ix*barsize), (iy*24)+itemp, (ix*barsize)+barsize, (iy*24)+itemp);
}
nosound();
}
}

for (itempr = 0; itempr < fullcirclerad; itempr = itempr + (fullcirclerad/12))
{
cfx = (int)((double)splitx+((double)splitr*cos(itempr)));
cfy = (int)((double)splity+((double)splitr*sin(itempr)));
if ( (getpixel(cfx, cfy) != 0) && ( (splity+cr) < 200) )
{
sound(1200);

score = score + points;
setcolor(0);
ix = (int)( (cfx)/barsize);
iy = (int)( (cfy)/24);
for (itemp = 0; itemp < 24; itemp++)
{
line( (ix*barsize), (iy*24)+itemp, (ix*barsize)+barsize, (iy*24)+itemp);
}
nosound();
}
}






setcolor(5);
circle(cx, cy, cr);
if ( dopple == 1 )
{
score--;
if ( score <= 0 )
{
score = 0;
dopple = 0;
}
if ( score > 0 )
{
setcolor(11);
circle(splitx, splity, splitr);
}
}
p = 12000;
pauseloop:;
if ( p > 0 )
{
p--;
goto pauseloop;
}

setcolor(0);
circle(splitx, splity, splitr);

if ( dopple == 1 )
{
if ( (splitx < (640-splitr)) && (splitxd == 1) )
{
splitx = splitx + s;
}
if ( splitx >= (640-splitr) )
{
splitxd = 0;
}
if ( (splitx > 0) && (splitxd == 0) )
{
splitx = splitx - s;
}
if ( splitx <= 0 )
{
splitxd = 1;
}
if ( (splity < (y-splitr)) && (splityd == 1) )
{
splity = splity + s;
}
if ( splity >= (y-splitr) )
{
splityd = 0;
}
if ( (splity > splitr) && (splityd == 0) )
{
splity = splity - s;
}
if ( splity <= splitr )
{
splityd = 1;
}

}


setcolor(0);
circle(cx, cy, cr);

if ( (cx < (640-cr)) && (cxd == 1) )
{
cx = cx + s;
}
if ( cx >= (640-cr) )
{
cxd = 0;
}
if ( (cx > 0) && (cxd == 0) )
{
cx = cx - s;
}
if ( cx <= 0 )
{
cxd = 1;
}



if ( (cy < (y-cr)) && (cyd == 1) )
{
cy = cy + s;
}
if ( cy >= (y-cr) && (cyd == 1) )
{
if ( ((cx+cr) >= (x+s+1)) && ((cx-cr) <= (x+s+1+barsize)) )
{
cyd = 0;
}
}
if ( (cyd == 0) && (cy > cr) )
{
cy = cy - s;
}
if ( (cyd == 0) && (cy <= cr) )
{
cyd = 1;
}


REPEAT:;
if ( keypress != 'q' )
{
goto START;
}
closegraph();
return 0;




}

