Sunday 9 November 2014

                     Tetires source code to compile

#include <graphics.h>
#include <dos.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
#include <bios.h>
#include <string.h>
#include <process.h>

#define DELAYS 10
#define INTR 0X1C

#ifdef __cplusplus
    #define __CPPARGS ...
#else
    #define __CPPARGS
#endif

void interrupt (*oldhandler)(__CPPARGS);

int loop=0;

void interrupt handler(__CPPARGS)
   {
   disable(); loop++;
   enable();  oldhandler();
   }
#define LCLICK 1
#define RCLICK 2
#define SPECIAL_KEY bioskey

#define RIGHT_ARROW 0x4d00
#define LEFT_ARROW 0x4b00
#define UP_ARROW 0x4800
#define DOWN_ARROW 0x5000
#define ESC 0x11b
#define ENTER 0x1c0d
#define BACKSPACE 0xe08
#define SPACEBAR 0x3920
#define F1 0x3b00
#define F2 0x3c00
#define F3 0x3d00
#define F4 0x3e00
#define F5 0x3f00
#define F6 0x4000

/////////////********* Declaration For Mouse Control **************///////////
class mouseobj{
    public:
       void init();
       void show();
       void hide();
       int  post(int,int,int,int);
       int  press();
       void vert_limit(int,int);
       void horiz_limit(int,int);
          };

void mouseobj::init(){ asm {mov ax,0x00; int 0x33 } }
void mouseobj::show(){ asm {mov ax,0x01; int 0x33 } }
void mouseobj::hide(){ asm {mov ax,0x02; int 0x33 } }
void mouseobj::horiz_limit( int minx, int maxx ) {
    union REGS inregs,outregs;
    inregs.x.ax = 7;
    inregs.x.cx = minx;
    inregs.x.dx = maxx;
    int86(0x33,&inregs,&outregs);
        }

void mouseobj::vert_limit( int miny, int maxy ){
    union REGS inregs,outregs;
    inregs.x.ax = 8;
    inregs.x.cx = miny;
    inregs.x.dx = maxy;
    int86(0x33,&inregs,&outregs);
        }

int mouseobj::post(int left,int top,int right,int buttom)
    { union REGS inregs,outregs;
      inregs.x.ax=3;
      int86(0x33,&inregs,&outregs);
      return(outregs.x.cx>=left && outregs.x.cx<=right &&
         outregs.x.dx>=top && outregs.x.dx<=buttom);
    }
int mouseobj::press(){
      union REGS inregs,outregs;
      inregs.x.ax=3;
      int86(0x33,&inregs,&outregs);
      return(outregs.x.bx);
              }

/*************************************************/

char buf[80];
/*Class Interface (Base Class)*/
class interf {
    protected:
       int maxx,maxy;
    public:
       void shadow_outtext( int, int, char *, int, int, int);
       void thin_box( int, int, int, int, int, int, int);
       void sizable_box( int, int, int, int, int, int, int, int);
       void quit_box( int, int, int, int);
       char box_exit();
       void interface();
         };
/*Class Derive*/
class gameobj:public interf{
    private:
      int x,y,color;
      int i,j;
    public:
     int stage,stage_h;
     gameobj(int,int);
     void caro(int,int,int);
     void show_text();
     void make_caro(int,int,int,int);
     void fullclear(int cross[][45],int);
     void show_score(long);
     void show_next(int *);
     int not_miny(int,int,int,int cross[][45]);
     int chang_stage(int *,int chang);
     void show_stage(int *,long,int);
     void show_stage_h(int);
     int  win();
     void lost();
     };

void interf::thin_box(int x,int y,int x1,int y1,int width,int color,int color1)
     { for(int i=0;i<width;i++)
        { setcolor(color); line(x+i,y+i,x+i,y1-i);
                   line(x+i,y+i,x1-i,y+i);
          setcolor(color1);line(x+i,y1-i,x1-i,y1-i);
                   line(x1-i,y+i,x1-i,y1-i); }
     }

void interf::sizable_box(int x,int y,int x1,int y1,int width,int thick,int color,int color1){
    thin_box(x, y, x1, y1, width, color, color1);
    thin_box(x+thick, y+thick, x1-thick, y1-thick, width, color1, color);
        }

void interf::shadow_outtext(int x,int y,char *str,int color,
            int sh_color,int shadow){
    setcolor(color);outtextxy(x-shadow,y-shadow,str);
    setcolor(sh_color);outtextxy(x,y,str);
        }

void interf::quit_box(int x,int y,int z,int w){
    thin_box(x,y,z,w,2,15,8);
    setfillstyle(1,7); bar(x+2,y+2,z-2,w-2);
    settextstyle(0,0,1);
    setcolor(0); outtextxy(x+4,y+3,"x");
           }

char interf::box_exit(){
    sizable_box(maxx/2-150,maxy/2-60,maxx/2+150,maxy/2+60,1,1,15,8);
    thin_box(maxx/2-95,maxy/2+20,maxx/2-30,maxy/2+50,1,15,8);
    thin_box(maxx/2+20,maxy/2+20,maxx/2+90,maxy/2+50,1,15,8);
    setcolor(0);
    setusercharsize(2,5,2,5);
    settextstyle(installuserfont("kh02.chr"),HORIZ_DIR,USER_CHAR_SIZE);
    outtextxy(maxx/2+30,maxy/2+18,"Qb;elg");
    outtextxy(maxx/2-85,maxy/2+18,"elgeTot");
    class mouseobj mouse;
    mouse.init();
    while(1){
       mouse.show();
       mouse.horiz_limit(maxx/2-150,maxx/2+150);
       mouse.vert_limit(maxy/2-60,maxy/2+60);
       if(mouse.post(maxx/2-95,maxy/2+20,maxx/2-30,maxy/2+50)){
        if(mouse.press()==LCLICK){
          while(mouse.press()==LCLICK)
            thin_box(maxx/2-95,maxy/2+20,maxx/2-30,maxy/2+50,1,8,15);
          mouse.hide();
          thin_box(maxx/2-95,maxy/2+20,maxx/2-30,maxy/2+50,1,15,8);
          if(mouse.post(maxx/2-95,maxy/2+20,maxx/2-30,maxy/2+50)) return('y');
            }}
       if(mouse.post(maxx/2+20,maxy/2+20,maxx/2+90,maxy/2+50)){
        if(mouse.press()==LCLICK){
          while(mouse.press()==LCLICK)
            thin_box(maxx/2+20,maxy/2+20,maxx/2+90,maxy/2+50,1,8,15);
          mouse.hide();
          thin_box(maxx/2+20,maxy/2+20,maxx/2+90,maxy/2+50,1,15,8);
          if(mouse.post(maxx/2+20,maxy/2+20,maxx/2+90,maxy/2+50)) return('n');
        }}
        }
        }

void interf::interface(){
    setfillstyle(1,3); bar(0,0,maxx,maxy);
    for(int i=0;i<8;i++) thin_box(1,maxy-20+3*i,maxx-1,maxy-21+3*i,1,15,8);
    for(i=0;i<9;i++) thin_box(1,17-2*i,maxx-1,16-2*i,1,15,8);
    thin_box(180,maxy-23,181,18,1,15,8);
    thin_box(182,maxy-23,183,18,1,15,8);
    setfillstyle(1,0); bar(30,270,150,300);
    bar(30,150,150,220);
    thin_box(30,150,150,220,2,8,15);
    thin_box(30,270,150,300,2,8,15);
    bar(maxx/2-77,50,maxx/2+77,maxy-55);
    thin_box(maxx/2-77,50,maxx/2+77,maxy-55,2,8,15);
    }

gameobj::gameobj(int xIn,int yIn){
    maxx=xIn;
    maxy=yIn;
    stage = stage_h = 1;
    }

void gameobj::caro(int x,int y,int color){
    setfillstyle(1,color);
    bar(maxx/2-75+10*x,60+10*y,maxx/2-67+10*x,52+10*y);
    color?thin_box(maxx/2-74+10*x,60+10*y,maxx/2-66+10*x,52+10*y,1,15,8):
          thin_box(maxx/2-74+10*x,60+10*y,maxx/2-66+10*x,52+10*y,1,0,0);
    }

void gameobj::make_caro(int CARO,int cx,int cy,int col){
    x = cx; y = cy; color = col;
    setfillstyle(1,color);
       if((CARO>=0&&CARO<4)||(CARO>4&&CARO<=7)||
       CARO==10||CARO==11||(CARO>12&&CARO<16)||
      (CARO>17&&CARO<21)||CARO==22||CARO==23||
      (CARO>=25&&CARO<=31))
        caro(x,y,color);
       if(CARO==1||CARO==3||(CARO>=6&&CARO<=9)||CARO==11||
      CARO==12||(CARO>=14&&CARO<=17)||(CARO>=19&&CARO<=22)||
      CARO==24||(CARO>=26&&CARO<=28))
        caro(x+1,y,color);
       if(CARO==1||CARO==4||CARO==6||CARO==11||
      CARO==15||CARO==24||CARO==25||CARO==27)
        caro(x+2,y,color);
       if(CARO==1)
         {     caro(x+3,y,color);
        caro(x+4,y,color); }
       if((CARO>=2&&CARO<=6)||(CARO>=8&&CARO<=10)||
      (CARO>11&&CARO<15)||(CARO>=17&&CARO<=19)||
       CARO==21||(CARO>=23&&CARO<=27)||CARO==29||CARO==30)
        caro(x,y-1,color);
       if(CARO==2||CARO==5||CARO==10||CARO==14||CARO==16||
      CARO==21||CARO==26||CARO==28||CARO==29)
        caro(x,y-2,color);
       if(CARO==2)
         {    caro(x,y-3,color);
        caro(x,y-4,color); }
       if(CARO==3||CARO==4||(CARO>=7&&CARO<=13)||
     (CARO>=16&&CARO<=18)||(CARO>=20&&CARO<=25)
     ||CARO==28)
        caro(x+1,y-1,color);
       if(CARO==4||CARO==8||CARO==9||CARO==13||
      CARO==15||CARO==22||CARO==25||CARO==27)
        caro(x+2,y-1,color);
       if(CARO==5||CARO==7||CARO==8||CARO==12||
      CARO==16||CARO==23||CARO==26||CARO==28)
        caro(x+1,y-2,color);

No comments:

Post a Comment