Ads...

My Heart

X-position of the mouse cursor

Y-position of the mouse cursor




Showing posts with label My Programs.... Show all posts
Showing posts with label My Programs.... Show all posts

Friday, 29 April 2011

My Coding For Game Creation In C n C++... Puzzling Puzzle...

#include<graphics.h>
#include<conio.h>
#include"stdio.h"
#include<string.h>
#include<dos.h>
#include<stdlib.h>
#include<time.h>
#include<process.h>
class onkar
{
public:
void grap()
{
//***********************LAYOUT OF THE BOXES******************************
    int z, i,o, p=DETECT,x,y,l,mn;
    char a[2],b[2],c[2],d[2],e[2],f[2],g[2],h[2],j[2],a1[2],u[2],qw[2],zx[2];
    initgraph(&p,&o,"e:\\tc\\bgi");


    setlinestyle(SOLID_LINE,15,random(5));
    rectangle(250,300,350,150);
    rectangle(200,200,400,250);
    line(300,150,300,300);

outtextxy(250, 153, "1");
outtextxy(303, 153, "2");
outtextxy(203, 205, "3");
outtextxy(250, 205, "4");
outtextxy(303, 205, "5");
outtextxy(353, 205, "6");
outtextxy(250, 255, "7");
outtextxy(303, 255, "8");
settextstyle(4,0,4);
outtextxy(300,400,"Onkar N Pritesh");
//delay(10);
//putpixel(random(620),random(48),random(65));
// }

 while(!kbhit())
 {
    delay(111);            /* Repeat until a key is hit    */
    setcolor(random(WHITE));    /* Randomly select a color    */
       delay(10);
       putpixel(random(53),random(23),random(12));
   settextstyle(4,0,3);
  outtextxy(240,20,"Press a Key");

 }
    setfillstyle(SOLID_FILL,BLACK);
    bar(390,10,170,70);

  }//end function grap




    };//end class onkar
//--------------------------------------------

void main()
{    clrscr();
//********************FIRST PAGE************************************
 char *password;
 char *c;
 union REGS ii,oo;
 gotoxy(20,7);
 password = getpass("Enter password to start the game:");



 if(strcmp(password,"o")==0)
 {
    int z, i,o,x,y,m=DETECT,l,mn,maxx,maxy;
    char a[2],b[2],c[2],d[2],e[2],f[2],g[2],h[2],j[2],a1[2],u[2],qw[2],zx[2];
    int botton;
    initgraph(&m, &l,"e:\\tc\\bgi");

    setcolor(YELLOW);

    settextstyle(1,0,3);
    outtextxy(230,10,"PUZZLING PUZZLE");
    setcolor(RED);
    settextstyle(111,0,3);
    outtextxy(50,50,"RULES");
    settextstyle(111,0,2);
    setcolor(BROWN);
    outtextxy(50,100,"1.You must fill the boxes value such that the consucutive");
    outtextxy(50,115,"  number's boxes should not touch  each other.");
    outtextxy(50,145,"2.Values range is '1 to 8'.");
    outtextxy(50,175,"3.To check weather the inserted values are correct,");
    outtextxy(50,190,"  press 9 when it asks for BOX NUMBER.");
    outtextxy(50,210,"4.Once you have entered all values press 10 to refresh.");
    outtextxy(80,300,"             press any key to continue:");
    settextstyle(6,0,4);
    outtextxy(250,340,"By- Pritesh & Onkar");
    circle(453,360,1);
    circle(460,360,1);
    ellipse(456,367,225,3,4,1);
    maxx=getmaxx();
    maxy=getmaxy();
     getch();


    cleardevice();
//***********************SECOND PAGE(GAME PAGE)***********************
    onkar oop;

    oop.grap();

    getch();
    for( i=0;i<=100;i++)

    {
    int omy;
    int ch;



    gotoxy(3,3);
    printf("Box number: ");
    gotoxy(14,3);
    scanf("%d",&x);

    setcolor(RED);
    settextstyle(DEFAULT_FONT,0,1);
    switch(x)
    {


    case 1:
    {
        gotoxy(3,7);
        printf("BOX value: ");
        gotoxy(13,7);
        scanf("%s",a);

        setfillstyle(SOLID_FILL,BLACK);
        bar(255,170,290,190);
        outtextxy(270,175,a);
        break;

    }//end case 1


    case 2:
    {       gotoxy(3,7);
        printf("BOX value: ");
        gotoxy(13,7);
        scanf("%s",b);
        setfillstyle(SOLID_FILL,BLACK);
        bar(315,190,340,160);
        outtextxy(320,175,b);
        break;

    }//end case 2

    case 3:
    {       gotoxy(3,7);
        printf("BOX value: ");
        gotoxy(13,7);
        scanf("%s",c);
        setfillstyle(SOLID_FILL,BLACK);
        bar(245,215,220,240);
        outtextxy(220,225,c);
        break;

    }//end case 3

    case 4:
    {       gotoxy(3,7);
        printf("BOX value: ");
        gotoxy(13,7);
        scanf("%s",d);
        setfillstyle(SOLID_FILL,BLACK);
        bar(255,215,290,240);
        outtextxy(270,225,d);
        break;

    }//end case 4

    case 5:
    {       gotoxy(3,7);
        printf("BOX value: ");
        gotoxy(13,7);
        scanf("%s",e);
        setfillstyle(SOLID_FILL,BLACK);
        bar(315,215,340,240);
        outtextxy(320,225,e);
        break;

    }//end case 5

    case 6:
    {       gotoxy(3,7);
        printf("BOX value: ");
        gotoxy(13,7);
        scanf("%s",f);
        setfillstyle(SOLID_FILL,BLACK);
        bar(370,215,390,240);
        outtextxy(370,225,f);
        break;

    }//end case 6

    case 7:
    {       gotoxy(3,7);
        printf("BOX value: ");
        gotoxy(13,7);
        scanf("%s",g);
        setfillstyle(SOLID_FILL,BLACK);
        bar(265,255,290,290);
        outtextxy(270,275,g);
        break;

    }//end case 7


    case 8:
    {       gotoxy(3,7);
        printf("BOX value: ");
        gotoxy(13,7);
        scanf("%s",h);
        setfillstyle(SOLID_FILL,BLACK);
        bar(315,275,340,290);
        outtextxy(320,275,h);
        break;

    }//end case 8

    case 9:
    {
        i=105;
        if(strcmp(a,"6")==0 && strcmp(b,"4")==0 &&strcmp(c,"2")==0 && strcmp(d,"8")==0 && strcmp(e,"1")==0 && strcmp(f,"7")==0 && strcmp(g,"5")==0 &&strcmp(h,"3")==0 )

             {       sound(77);
                 delay(10);
                 nosound();
                 settextstyle(DEFAULT_FONT,0,4);
                 setcolor(RED);
                 outtextxy(120,20,"CONGRATULATIONS");
                 settextstyle(DEFAULT_FONT,0,3);
                 outtextxy(200,80,"RIGHT ANSWER");
             }//end if

        else if(strcmp(a,"5")==0 && strcmp(b,"3")==0 &&strcmp(c,"2")==0 && strcmp(d,"8")==0 && strcmp(e,"1")==0 && strcmp(f,"7")==0 && strcmp(g,"6")==0 &&strcmp(h,"4")==0 )
             {       sound(77);
                 delay(10);
                 nosound();
                 settextstyle(DEFAULT_FONT,0,4);
                 setcolor(RED);
                 outtextxy(120,20,"CONGRATULATIONS");
                 settextstyle(DEFAULT_FONT,0,3);
                 outtextxy(200,80,"RIGHT ANSWER");
             } //end else if 1

           else if(strcmp(a,"4")==0 && strcmp(b,"6")==0 &&strcmp(c,"7")==0 && strcmp(d,"1")==0 && strcmp(e,"8")==0 && strcmp(f,"2")==0 && strcmp(g,"3")==0 &&strcmp(h,"5")==0 )
             {
                 settextstyle(DEFAULT_FONT,0,4);
                 setcolor(RED);
                 outtextxy(120,20,"CONGRATULATIONS");
                 settextstyle(DEFAULT_FONT,0,3);
                 outtextxy(200,80,"RIGHT ANSWER");

             }//end else if 2

           else if(strcmp(a,"3")==0 && strcmp(b,"5")==0 &&strcmp(c,"7")==0 && strcmp(d,"1")==0 && strcmp(e,"8")==0 && strcmp(f,"2")==0 && strcmp(g,"4")==0 &&strcmp(h,"6")==0 )
             {
                 settextstyle(DEFAULT_FONT,0,4);
                 setcolor(RED);
                 outtextxy(120,20,"CONGRATULATIONS");
                 settextstyle(DEFAULT_FONT,0,3);
                 outtextxy(200,80,"RIGHT ANSWER");

             }//end else if 3
           else
             {
                 settextstyle(DEFAULT_FONT,0,5);
                 setcolor(RED);
                 outtextxy(225,20,"SORRY");
                 settextstyle(DEFAULT_FONT,0,3);
                 outtextxy(200,80,"WRONG ANSWER");

             }//end else


           break;
             }//end case 9

          default:

        {
            printf("wrong choice");
            break;

        }//end default
            }//end switch




            } //end for
            getch();



//===================================================
    cleardevice();
//***************LAST PAGE***************************

    setcolor(4);
    rectangle(30,30,624,464);
    setfillstyle(LINE_FILL,WHITE);
    rectangle(1,1,639,479);
    settextstyle(3,0,5);
    setcolor(6);
    outtextxy(90,185,"     O        P");
    settextstyle(3,0,3);
    outtextxy(70,200,"MADE BY :   nkar Ghule &    ritesh Bhavsar") ;
    outtextxy(70,300,"CLASS   : Syco Poly.");


 }
 else
 {
 gotoxy(23,7);
 printf("Wrong password   ");
 }
 getch();
}//end main