home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 26 / CD_ASCQ_26_1295.iso / vrac / volume_3.zip / DRAW2.BAK < prev    next >
Text File  |  1995-11-03  |  9KB  |  441 lines

  1. #include "C:\tc\mouse.h"
  2. #include "C:\tc\misc.h"
  3. #include "C:\tc\keyboard.h"
  4. #include "C:\tc\graphvga.h"
  5. #include "C:\tc\pcx.cpp"
  6.  
  7. #define NEWLINE "\n"
  8.  
  9. void PerformGame(void);
  10. void Perform_Exit(void);
  11. void Perform_Save_Load(void);
  12.  
  13.  
  14. void main(void)
  15. {
  16.  // Detects if Mouse Present
  17. Detect_Mouse();
  18.   //  Initialize VGA graphics.
  19. InitGraphics(9);
  20.   //  clears graphics screen
  21. cleardevice();
  22.  //  Draws Screen
  23. Display_PCX("draw2.pcx");
  24.  // Performs game till ESC is Pressed
  25. PerformGame();
  26.  // Reset's Graphics to original mode before InitGraphics()
  27. closegraph();
  28.  // Returns to DOS
  29. return;
  30. }
  31.  
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42. void PerformGame(void)
  43. {
  44. // Used for Keyboard Routines
  45. char char_ch = NULL;
  46. int Scan1,Alt_Ctrl = NULL;
  47. int int_ch;
  48. // Mouse Position
  49. int X,tempX;
  50. int Y,tempY;
  51. // Drawing Color
  52. int Drawing_Color  = 1;
  53. // Toggle Switch to cut on text writing
  54. int Text_Switch = FALSE;
  55. // Line Drawing size
  56. int Drawing_Size = 20;
  57. // Used to Clear the Screen
  58. int Clear_Y;
  59. // Cuts on and Displays Mouse Arrow
  60. Display_Mouse();
  61. Cursor_Shape(6);
  62. //mouse
  63. int Button_Check;
  64.  
  65.  
  66.  
  67.  
  68. // Start Loop untill ESCAPE is Pressed
  69. //while((int_ch = Key_Press(&char_ch))  != ESC)
  70. // {
  71. while((int_ch = Key_Press(&char_ch,&Scan1,&Alt_Ctrl))  != ESC)
  72.     {
  73.       Mouse_Position(&X,&Y); // Returns Current Mouse Location
  74.  
  75. //***********************************************
  76. // Beggining of Key Board Routine
  77. //************************************************
  78.       switch(Scan1) //Acts upon Key pressed
  79.         {
  80.         case UP:
  81.         if((Y > 40) AND (Text_Switch != TRUE))
  82.             {
  83.             Y = Y - 5;  //Up arrow key pressed
  84.             Move_Mouse(X,Y);
  85.             DrawBox(X,Y,Drawing_Size,Drawing_Size,Drawing_Color,1);
  86.             }
  87.         break;
  88.  
  89.         case DOWN:
  90.         if((Y > 40) AND (Text_Switch != TRUE))
  91.             {
  92.             Y = Y + 5; //Down arrow key pressed
  93.             Move_Mouse(X,Y);
  94.             DrawBox(X,Y,Drawing_Size,Drawing_Size,Drawing_Color,1);
  95.             }
  96.         break;
  97.  
  98.         case LEFT:
  99.         if((Y > 40) AND (Text_Switch != TRUE))
  100.             {
  101.              X = X - 5; //Left arrow key pressed
  102.             Move_Mouse(X,Y);
  103.             DrawBox(X,Y,Drawing_Size,Drawing_Size,Drawing_Color,1);
  104.             }
  105.         break;
  106.  
  107.         case RIGHT:
  108.         if((Y > 40) AND (Text_Switch != TRUE))
  109.             {
  110.             X = X + 5; //Right arrow key pressed
  111.             Move_Mouse(X,Y);
  112.             DrawBox(X,Y,Drawing_Size,Drawing_Size,Drawing_Color,1);
  113.             }
  114.         break;
  115.  
  116.         //**********************
  117.         // Clears Drawing Screen
  118.         //**********************
  119.         case SPACEBAR:
  120.         Hide_Mouse();
  121.         for(Clear_Y = 31;Clear_Y < (Max_Y + 1) ;Clear_Y++)
  122.             {
  123.             setcolor(0);
  124.             line(0,Clear_Y, Max_X, Clear_Y);
  125.             setcolor(8);
  126.             line(0,Clear_Y, Max_X, Clear_Y);
  127.             }
  128.         flush_buffer();
  129.         Display_Mouse();
  130.         break;
  131.  
  132.         default:
  133.         if((Y > 40) AND (Text_Switch != TRUE))
  134.             {
  135.            //    itoa(int_ch,ct,10);
  136.            //    outtextxy(10,40,ct);
  137.             sound(Scan1/5);
  138.             delay(20);
  139.             nosound();
  140.             }
  141.         break;
  142.         }
  143. //**************************************************
  144. // End of Keyboard Routine
  145. //**************************************************
  146.  
  147.  
  148.  
  149. //*************************************************
  150. // Beggining of TEXT DRAW Routine
  151. //*************************************************
  152.       if((Text_Switch == TRUE) AND (Y > 45))
  153.         {
  154.         while((Mouse_Status() != 1) AND (Y > 45)) //Allows Mouse to be moved till
  155.             {
  156.             Mouse_Position(&X,&Y);
  157.             flush_buffer();
  158.             }
  159.         while((Mouse_Status() == 1) AND (Y > 45))//You press a mouse button & then
  160.             {                             //is where text starts
  161.              Mouse_Position(&X,&Y);
  162.             flush_buffer();
  163.             }
  164.             sound(500);
  165.             delay(30);
  166.             nosound();
  167.             flush_buffer();                                 //Enter
  168.         while(((int_ch = Key_Press(&char_ch,&Scan1,&Alt_Ctrl))  != 13) AND (Mouse_Status() == 0))
  169.             {
  170.             if((int_ch != 0) AND (Y > 40))
  171.                 {
  172.                  Hide_Mouse();
  173.                  setcolor(Drawing_Color);
  174.             //Makes sound for everything except spaces
  175.                 if(char_ch != ' ')
  176.                     {
  177.                     sound(150);
  178.                     Slow_Down(10);
  179.                     nosound();
  180.                     }
  181.                  outtextxy(X,Y - 10,&char_ch);
  182.                  X = X + 10;
  183.                  if(X > Max_X)
  184.                     {
  185.                     for(int temp2=0;temp2<20;temp2++)
  186.                         {
  187.                         Basic_Sound(temp2*10,12);
  188.                         }
  189.                     Basic_Sound(700,70);
  190.                     X = 5;
  191.                     if(Y < Max_Y) Y = Y + 10;//New
  192.                     }
  193.                  Display_Mouse();
  194.                  Move_Mouse(X,Y);//Moves mouse to new X,Y position.
  195.                 }
  196.             }
  197.         Cursor_Shape(6);
  198.         Text_Switch = FALSE;
  199.         Hide_Mouse();
  200.         setcolor(BLACK);
  201.         line(2,26,34,26);
  202.         line(34,26,34,3);
  203.         setcolor(WHITE);
  204.         line(34,3,2,3);
  205.         line(2,3,2,26);
  206.         setcolor(Drawing_Color);
  207.         Display_Mouse();
  208.         flush_buffer();
  209.         Button_Up();
  210.         }
  211.  
  212. //************************************************
  213. // End of TEXT DRAW Routine
  214. //************************************************
  215.  
  216.  
  217.  //*************************************************
  218.  // Beggining of Mouse Routine
  219.  //*************************************************
  220. if(Button_Press_XY(&tempX,&tempY,Button_Check))
  221.     {
  222.     if(Y < 30)
  223.         {
  224.         if((Y != tempY) AND (X != tempX))
  225.             {
  226.             sound(100);
  227.             delay(10);
  228.             nosound();
  229.             //Exit
  230.             if((X > 572) AND (X < 605) )
  231.                 {
  232.                 Hide_Mouse();
  233.                 setcolor(WHITE);
  234.                 line(572,26,605,26);
  235.                 line(605,26,605,3);
  236.                 setcolor(BLACK);
  237.                 line(605,3,572,3);
  238.                 line(572,3,572,26);
  239.                 setcolor(Drawing_Color);
  240.                 Button_Up();
  241.  
  242.                 Perform_Exit();
  243.  
  244.                 setcolor(BLACK);
  245.                 line(572,26,605,26);
  246.                 line(605,26,605,3);
  247.                 setcolor(WHITE);
  248.                 line(605,3,572,3);
  249.                 line(572,3,572,26);
  250.                 setcolor(Drawing_Color);
  251.                 Display_Mouse();
  252.  
  253.  
  254.                 }
  255.             if((X > 523) AND (X < 556) )
  256.                 {
  257.                 Hide_Mouse();
  258.                 setcolor(WHITE);
  259.                 line(523,26,556,26);
  260.                 line(556,26,556,3);
  261.                 setcolor(BLACK);
  262.                 line(556,3,523,3);
  263.                 line(523,3,523,26);
  264.                 setcolor(Drawing_Color);
  265.                 Button_Up();
  266.  
  267.                 Perform_Save_Load();
  268.  
  269.  
  270.                 setcolor(BLACK);
  271.                 line(523,26,556,26);
  272.                 line(556,26,556,3);
  273.                 setcolor(WHITE);
  274.                 line(556,3,523,3);
  275.                 line(523,3,523,26);
  276.                 setcolor(Drawing_Color);
  277.                 Display_Mouse();
  278.                 }
  279.             //Clears Screen
  280.             if((X > 471) AND (X < 504) )
  281.                 {
  282.                 Button_Up();
  283.                 Hide_Mouse();
  284.                 setcolor(WHITE);
  285.                 line(471,26,504,26);
  286.                 line(504,26,504,3);
  287.                 setcolor(BLACK);
  288.                 line(504,3,471,3);
  289.                 line(471,3,471,26);
  290.                 setcolor(Drawing_Color);
  291.  
  292.                 for(Clear_Y = 31;Clear_Y < (Max_Y + 1) ;Clear_Y++)
  293.                     {
  294.                     setcolor(0);
  295.                     line(0,Clear_Y, Max_X, Clear_Y);
  296.                     setcolor(8);
  297.                     line(0,Clear_Y, Max_X, Clear_Y);
  298.                     }
  299.                 flush_buffer();
  300.                 setcolor(BLACK);
  301.                 line(471,26,504,26);
  302.                 line(504,26,504,3);
  303.                 setcolor(WHITE);
  304.                 line(504,3,471,3);
  305.                 line(471,3,471,26);
  306.                 setcolor(Drawing_Color);
  307.  
  308.                 Display_Mouse();
  309.                 }
  310.             //Toggles text Mode
  311.             else if((X > 0) AND (X <  40) AND (Text_Switch != TRUE))
  312.                 {
  313.                 Button_Up();
  314.                 Hide_Mouse();
  315.                 Text_Switch = TRUE;
  316.                 Cursor_Shape(5);
  317.                 setcolor(WHITE);
  318.                 line(2,26,34,26);
  319.                 line(34,26,34,3);
  320.                 setcolor(BLACK);
  321.                 line(34,3,2,3);
  322.                 line(2,3,2,26);
  323.                 setcolor(Drawing_Color);
  324.                 Display_Mouse();
  325.                 }
  326.             // Line Drawing Size
  327.             else if((X > 418) AND (X < 456))
  328.                 {
  329.                 Button_Up();
  330.                 switch(Drawing_Size)
  331.                     {
  332.                     case 20:
  333.                         Drawing_Size = 10;
  334.                         break;
  335.  
  336.                     case 10:
  337.                         Drawing_Size = 5;
  338.                         break;
  339.  
  340.                     case 5:
  341.                         Drawing_Size = 2;
  342.                         break;
  343.  
  344.                     case 2:
  345.                         Drawing_Size = 20;
  346.                         break;
  347.  
  348.                     }
  349.  
  350.                 }
  351.             //Color Selection
  352.             else if(X > 41)
  353.                  {
  354.                  if(X < 404)
  355.                     {
  356.                     if(Y > 2)
  357.                         {
  358.                         if(Y < 27)
  359.                             {
  360.                             if( X > 386)
  361.                                 {
  362.                                 Drawing_Color = 8;//ERASE
  363.                                 Button_Up();
  364.                                 }
  365.                             else if( (getpixel(X,Y)) != 8)
  366.                                 {
  367.                                 Hide_Mouse();
  368.                                 Drawing_Color = getpixel(X,Y);
  369.                                 Button_Up();
  370.                                 Display_Mouse();
  371.                                 }
  372.  
  373.                             }
  374.                         }
  375.                     }
  376.                  }
  377.                //    CheckForColor(X,&Drawing_Color);
  378.                 //    }
  379.             //else if
  380.  
  381.             }
  382.         }
  383.     }
  384.  
  385.  
  386.  
  387.      switch(Mouse_Status())
  388.         {
  389.         case 1: //Left Mouse Button
  390.         //******************************
  391.         //Draws only if in drawing page
  392.         //******************************
  393.         if(Y > 30)
  394.             {
  395.             DrawBox(X,Y,Drawing_Size,Drawing_Size,Drawing_Color,1);
  396.             }
  397.         break;
  398.  
  399.         case 2: // If Right Mouse Button Held Down
  400.         sound(100);
  401.         delay(10);
  402.         nosound();
  403.         break;
  404.  
  405.  
  406.         default: break;
  407.         }
  408. //***************************************************
  409. // End of Mouse Routine
  410. //***************************************************
  411.  
  412.  }//End of While of Loop
  413.  
  414.  
  415. return;
  416. }
  417.  
  418.  
  419. void Perform_Exit(void)
  420. {
  421. sound(500);
  422. delay(60);
  423. nosound();
  424.  
  425.  
  426. return;
  427. }
  428.  
  429.  
  430.  
  431.  
  432. void Perform_Save_Load(void)
  433. {
  434. sound(500);
  435. delay(60);
  436. nosound();
  437.  
  438.  
  439. return;
  440. }
  441.