#include<my.h> void rectclean(void); void make(void); void linesmove(void); void blockmove(void); void rect(void); char ch='f'; float b,c; int e,f,g,h,m,n,o,p; //int check=1; int tm=7; int c1,c2; int r1,r2; void main(void) { int d=0,m; clrscr(); initgraph(&d,&m,"d:\\tc\\bgi"); make(); linesmove(); blockmove(); //getch(); } void make(void){ cleardevice(); rectangle(199,79,401,401); rectangle(198,78,402,402); rectangle(197,77,403,403); rectangle(196,76,404,404); rectangle(200,80,400,400); setlinestyle(0,1,3); line(200,375,400,375); line(200,350,400,350); line(200,325,400,325); line(200,300,400,300); line(200,275,400,275); line(200,250,400,250); b=220; c=b+70; for(int a=b;a<=c;a++){setcolor(9);line(a,252,a,273);delay(1);} e=270; f=e+70; for(a=e;a<=f;a++){setcolor(9);line(a,327,a,348);delay(1);} g=220; h=g+50; for(a=g;a<=h;a++){setcolor(9);line(a,352,a,373);delay(5);} m=320; n=m+60; for(a=m;a<=n;a++){setcolor(9);line(a,302,a,323);delay(5);} o=340; p=o+50; for(a=o;a<=p;a++){setcolor(9);line(a,277,a,298);delay(5);} for(int rt=275;rt<=300;rt++){setcolor(5);line(rt,377,rt,399);} c1=275,c2=300,r1=377,r2=398; } void blockmove(void) { ch=getch(); while(ch=='w' || ch=='s' || ch=='a' || ch=='d' || ch=='f') { if(ch=='w'){rectclean();r1=r1-25;r2=r2-25; if(r1==227){c1=275,c2=300,r1=377,r2=398; } rect();linesmove(); } else if(ch=='s'){rectclean();r1=r1+25;r2=r2+25; if(r1>380){r1=r1-25;r2=r2-25;} rect();linesmove();} else if(ch=='a') {rectclean();c1=c1-25;c2=c2-25; if(c1<199){c1=c1+25;c2=c2+25;} rect();linesmove();} else if(ch=='d') {rectclean();c1=c1+25;c2=c2+25; if(c2>410){c1=c1-25;c2=c2-25;} rect();linesmove();} else if(ch=='f') ; ch=getch(); } } void rect(void) { for(;c1<=c2;c1++){setcolor(5);line(c1,r1,c1,r2);} c1=c1-25; } void rectclean(void) { for(;c1<=c2;c1++){setcolor(0);line(c1,r1,c1,r2);} c1=c1-25; } void linesmove(void) { while(!kbhit()) { //CONDITIONSSSSSS WHEN (BlOCK Hits LINES)// if(((c2<=h && c2>=g) || (c1>=g && c1<=h) || (g>351 && c1<=h) || (c2>=g && h<249) ) && r1==352) { getche();getch();exit(0); } if(((c2<=f && c2>=e) || (c1>=e && c1<=f) || (e>331 && c1<=f) || (c2>=e && f<269)) && r1==327) {getch();exit(0);} if(((c2<=n && c2>=m) || (c1>=m && c1<=n) || (m>341 && c1<=n) || (c2>=m && n<259)) && r1==302) {getche();exit(0);} if(((c2<=p && c2>=o) || (c1>=o && c1<=p) || (o>351 && c1<=p) || (c2>=o && p<249)) && r1==277) {getch();exit(0);} if(((c2<=c && c2>=b) || (c1>=b && c1<=c) || (b>331 && c1<=c) || (c2>=b && c<269)) && r1==252) {getch();exit(0);} //LINES MOVES With incremant OF ONE// setcolor(0); line(b,252,b,273); setcolor(9); line(c,252,c,273); setcolor(9); line(e,327,e,348); setcolor(0); line(f,327,f,348); setcolor(0); line(g,352,g,373); setcolor(9); line(h,352,h,373); setcolor(0); line(m,302,m,323); setcolor(9); line(n,302,n,323); setcolor(9); line(o,277,o,298); setcolor(0); line(p,277,p,298); b=b+0.05;c=c+0.05; g++;h++; m++;n++; e--;f--; o--;p--; delay(tm); //CONDITIONS FOR LINES WHEN HITS BORDER LINE OF MAIN BLOCK if(b==399)b=201; if(c==399)c=201; if(g==399)g=201; if(h==399)h=201; if(o==201)o=399; if(p==201)p=399; if(e==201)e=399; if(f==201)f=399; if(m==399)m=201; if(n==399)n=201; } }
C Program For Creating Block Game
January 04, 2015
By:
Bhanu Namikaze
Bhanu Namikaze
Bhanu Namikaze is an Ethical Hacker, Security Analyst, Blogger, Web Developer and a Mechanical Engineer. He Enjoys writing articles, Blogging, Debugging Errors and Capture the Flags. Enjoy Learning; There is Nothing Like Absolute Defeat - Try and try until you Succeed.
No comments:
Post a Comment