home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
DP Tool Club 26
/
CD_ASCQ_26_1295.iso
/
vrac
/
volume_3.zip
/
DRAW2.CPP
< prev
next >
Wrap
C/C++ Source or Header
|
1995-11-03
|
9KB
|
447 lines
#include "C:\tc\mouse.h"
#include "C:\tc\misc.h"
#include "C:\tc\keyboard.h"
#include "C:\tc\graphvga.h"
#include "C:\tc\pcx.cpp"
#define NEWLINE "\n"
void PerformGame(void);
void Perform_Exit(void);
void Perform_Save_Load(void);
void main(void)
{
// Detects if Mouse Present
Detect_Mouse();
// Initialize VGA graphics.
InitGraphics(9);
// clears graphics screen
cleardevice();
// Draws Screen
Display_PCX("draw2.pcx");
// Performs game till ESC is Pressed
PerformGame();
// Reset's Graphics to original mode before InitGraphics()
closegraph();
// Returns to DOS
return;
}
void PerformGame(void)
{
// Used for Keyboard Routines
char char_ch = NULL;
int Scan1,Alt_Ctrl = NULL;
int int_ch;
// Mouse Position
int X,tempX;
int Y,tempY;
// Drawing Color
int Drawing_Color = 1;
// Toggle Switch to cut on text writing
int Text_Switch = FALSE;
// Line Drawing size
int Drawing_Size = 20;
// Used to Clear the Screen
int Clear_Y;
// Cuts on and Displays Mouse Arrow
Display_Mouse();
Cursor_Shape(6);
//mouse
int Button_Check;
// Start Loop untill ESCAPE is Pressed
//while((int_ch = Key_Press(&char_ch)) != ESC)
// {
while((int_ch = Key_Press(&char_ch,&Scan1,&Alt_Ctrl)) != ESC)
{
Mouse_Position(&X,&Y); // Returns Current Mouse Location
//***********************************************
// Beggining of Key Board Routine
//************************************************
switch(Scan1) //Acts upon Key pressed
{
case UP:
if((Y > 40) AND (Text_Switch != TRUE))
{
Y = Y - 5; //Up arrow key pressed
Move_Mouse(X,Y);
DrawBox(X,Y,Drawing_Size,Drawing_Size,Drawing_Color,1);
}
break;
case DOWN:
if((Y > 40) AND (Text_Switch != TRUE))
{
Y = Y + 5; //Down arrow key pressed
Move_Mouse(X,Y);
DrawBox(X,Y,Drawing_Size,Drawing_Size,Drawing_Color,1);
}
break;
case LEFT:
if((Y > 40) AND (Text_Switch != TRUE))
{
X = X - 5; //Left arrow key pressed
Move_Mouse(X,Y);
DrawBox(X,Y,Drawing_Size,Drawing_Size,Drawing_Color,1);
}
break;
case RIGHT:
if((Y > 40) AND (Text_Switch != TRUE))
{
X = X + 5; //Right arrow key pressed
Move_Mouse(X,Y);
DrawBox(X,Y,Drawing_Size,Drawing_Size,Drawing_Color,1);
}
break;
//**********************
// Clears Drawing Screen
//**********************
case SPACEBAR:
Hide_Mouse();
for(Clear_Y = 31;Clear_Y < (Max_Y + 1) ;Clear_Y++)
{
setcolor(0);
line(0,Clear_Y, Max_X, Clear_Y);
setcolor(8);
line(0,Clear_Y, Max_X, Clear_Y);
}
flush_buffer();
Display_Mouse();
break;
default:
if((Y > 40) AND (Text_Switch != TRUE))
{
// itoa(int_ch,ct,10);
// outtextxy(10,40,ct);
sound(Scan1/5);
delay(20);
nosound();
}
break;
}
//**************************************************
// End of Keyboard Routine
//**************************************************
//*************************************************
// Beggining of TEXT DRAW Routine
//*************************************************
if((Text_Switch == TRUE) AND (Y > 45))
{
while((Mouse_Status() != 1) AND (Y > 45)) //Allows Mouse to be moved till
{
Mouse_Position(&X,&Y);
flush_buffer();
}
while((Mouse_Status() == 1) AND (Y > 45))//You press a mouse button & then
{ //is where text starts
Mouse_Position(&X,&Y);
flush_buffer();
}
sound(500);
delay(30);
nosound();
flush_buffer(); //Enter
while(((int_ch = Key_Press(&char_ch,&Scan1,&Alt_Ctrl)) != 13) AND (Mouse_Status() == 0))
{
if((int_ch != 0) AND (Y > 40))
{
Hide_Mouse();
setcolor(Drawing_Color);
//Makes sound for everything except spaces
if(char_ch != ' ')
{
sound(150);
Slow_Down(10);
nosound();
}
outtextxy(X,Y - 10,&char_ch);
X = X + 10;
if(X > Max_X)
{
for(int temp2=0;temp2<20;temp2++)
{
Basic_Sound(temp2*10,12);
}
Basic_Sound(700,70);
X = 5;
if(Y < Max_Y) Y = Y + 10;//New
}
Display_Mouse();
Move_Mouse(X,Y);//Moves mouse to new X,Y position.
}
}
Cursor_Shape(6);
Text_Switch = FALSE;
Hide_Mouse();
setcolor(BLACK);
line(2,26,34,26);
line(34,26,34,3);
setcolor(WHITE);
line(34,3,2,3);
line(2,3,2,26);
setcolor(Drawing_Color);
Display_Mouse();
flush_buffer();
Button_Up();
}
//************************************************
// End of TEXT DRAW Routine
//************************************************
//*************************************************
// Beggining of Mouse Routine
//*************************************************
if(Button_Press_XY(&tempX,&tempY,Button_Check))
{
if(Y < 30)
{
// if((Y == tempY) AND (X == tempX))
// Under Windows 95 Button_Press_XY will not set
//tempY or tempX to the button release position
//this works great under dos 6.22 so it must be
//a bug with windows 95 not allowing correct dos
//mouse routines?
if((Y != tempY) AND (X != tempX))
{
sound(100);
delay(10);
nosound();
//Exit
if((X > 572) AND (X < 605) )
{
Hide_Mouse();
setcolor(WHITE);
line(572,26,605,26);
line(605,26,605,3);
setcolor(BLACK);
line(605,3,572,3);
line(572,3,572,26);
setcolor(Drawing_Color);
Button_Up();
Perform_Exit();
setcolor(BLACK);
line(572,26,605,26);
line(605,26,605,3);
setcolor(WHITE);
line(605,3,572,3);
line(572,3,572,26);
setcolor(Drawing_Color);
Display_Mouse();
}
if((X > 523) AND (X < 556) )
{
Hide_Mouse();
setcolor(WHITE);
line(523,26,556,26);
line(556,26,556,3);
setcolor(BLACK);
line(556,3,523,3);
line(523,3,523,26);
setcolor(Drawing_Color);
Button_Up();
Perform_Save_Load();
setcolor(BLACK);
line(523,26,556,26);
line(556,26,556,3);
setcolor(WHITE);
line(556,3,523,3);
line(523,3,523,26);
setcolor(Drawing_Color);
Display_Mouse();
}
//Clears Screen
if((X > 471) AND (X < 504) )
{
Button_Up();
Hide_Mouse();
setcolor(WHITE);
line(471,26,504,26);
line(504,26,504,3);
setcolor(BLACK);
line(504,3,471,3);
line(471,3,471,26);
setcolor(Drawing_Color);
for(Clear_Y = 31;Clear_Y < (Max_Y + 1) ;Clear_Y++)
{
setcolor(0);
line(0,Clear_Y, Max_X, Clear_Y);
setcolor(8);
line(0,Clear_Y, Max_X, Clear_Y);
}
flush_buffer();
setcolor(BLACK);
line(471,26,504,26);
line(504,26,504,3);
setcolor(WHITE);
line(504,3,471,3);
line(471,3,471,26);
setcolor(Drawing_Color);
Display_Mouse();
}
//Toggles text Mode
else if((X > 0) AND (X < 40) AND (Text_Switch != TRUE))
{
Button_Up();
Hide_Mouse();
Text_Switch = TRUE;
Cursor_Shape(5);
setcolor(WHITE);
line(2,26,34,26);
line(34,26,34,3);
setcolor(BLACK);
line(34,3,2,3);
line(2,3,2,26);
setcolor(Drawing_Color);
Display_Mouse();
}
// Line Drawing Size
else if((X > 418) AND (X < 456))
{
Button_Up();
switch(Drawing_Size)
{
case 20:
Drawing_Size = 10;
break;
case 10:
Drawing_Size = 5;
break;
case 5:
Drawing_Size = 2;
break;
case 2:
Drawing_Size = 20;
break;
}
}
//Color Selection
else if(X > 41)
{
if(X < 404)
{
if(Y > 2)
{
if(Y < 27)
{
if( X > 386)
{
Drawing_Color = 8;//ERASE
Button_Up();
}
else if( (getpixel(X,Y)) != 8)
{
Hide_Mouse();
Drawing_Color = getpixel(X,Y);
Button_Up();
Display_Mouse();
}
}
}
}
}
// CheckForColor(X,&Drawing_Color);
// }
//else if
}
}
}
switch(Mouse_Status())
{
case 1: //Left Mouse Button
//******************************
//Draws only if in drawing page
//******************************
if(Y > 30)
{
DrawBox(X,Y,Drawing_Size,Drawing_Size,Drawing_Color,1);
}
break;
case 2: // If Right Mouse Button Held Down
sound(100);
delay(10);
nosound();
break;
default: break;
}
//***************************************************
// End of Mouse Routine
//***************************************************
}//End of While of Loop
return;
}
void Perform_Exit(void)
{
sound(500);
delay(60);
nosound();
return;
}
void Perform_Save_Load(void)
{
sound(500);
delay(60);
nosound();
return;
}