用C语言编写的五子棋游戏
Code
#include
#include
#include
#include
#include
#include
#include
#define R 10 /*The size of mouse*/
void init(void); /* BGI initialization */
int cover(int); /*draw lines , set color, output the text*/
void get_board(void);
/*using the loop and the line function to draw the chessboard*/
void word(int); /*input word,the color is come from the rand*/
void getmouse(int *,int *,int *);
/*get the location and the button of mouse,key=1 is the left button,key=2 is the right button*/
void visbilemouse(void);
/*Display the mouse*//*after typing ,gets the x, y and mouse button,then return */
void mouse(int *,int *,int *);
/*drawing a mouse is to put an empty rectangular in the memory , then draw the shape of the mouse in the empty rectangular*/
void change_word(int); /*show the black or the white*/
void help(void); /*get playing help*/
void prompt(int); /*the cancel or quit*/
void game_player(void); /*how to realize the game*/
int main()
{
int key;
init();/*BGI initialization*/
key=cover(0); /*the welcome interface*/
while(key) /*only it is 1.it will running the loop*/
{
get_board(); /*draw the chessboard*/
game_player(); /*control or play the games*/
}
closegraph();
return 0;
}
void init() /* BGI initialization */
{
int graphdriver = DETECT, graphmode = 0;
/* The same effect with gd =VGA and gm = VGAHI */
registerbgidriver(EGAVGA_driver);
/* After register the BGI driver needn't the support of running the BGI */
initgraph(&graphdriver, &graphmode, "");
return;
}
int cover(int choose)
{
int row,col,i;
char answer;
switch(choose)
{
case 0:
setfillstyle(SOLID_FILL,BLUE); /*fill in the color*/
bar(630,450,10,30);
for(row=30;row<=180;row+=30) /*draw cross lines*/
line(10,row,160,row);
for(col=10;col<=180;col+=30) /*draw vertical lines