#include <graphics.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
#define K 24
#define N 18
#define up 0x4800
#define down 0x5000
#define left 0x4b00
#define right 0x4d00
#define esc 0x011b
#define enter 0x1c0d
#define A 0x1e61
#define S 0x1f73
#define D 0x2064
#define W 0x1177
#define space 0x3920
#define Y 0x1579
#define n 0x316e
struct chess
{
int x;
int y; /*x,y表示當前光標的位置*/
int yes[N][N]; /* 0表示無棋子,1表示白色棋子,2表示黑色棋子*/
int kao; /* 1表示白棋準備落子,2表示黑棋落子*/
int ok; /*1表示白棋勝出,2表示黑棋勝出*/
}chess;
int key,t;
char hong64H[]={
/* 以下是 '紅' 的 64點陣華文新魏 字模,512 byte */
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x20,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x70,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0xF0,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0xF0,0x00,0x00,0x00,0x00,
0x00,0x00,0x01,0xE0,0x00,0x00,0x00,0x00,
0x00,0x00,0x01,0xC0,0x00,0x00,0x00,0x00,
0x00,0x00,0x03,0xC0,0x00,0x00,0x00,0x00,
0x00,0x00,0x03,0x80,0x00,0x00,0x00,0x00,
0x00,0x00,0x07,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x0F,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x0E,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x1E,0x00,0x00,0x03,0xE0,0x00,
0x00,0x00,0x1C,0x18,0x00,0x1F,0xE0,0x00,
0x00,0x00,0x3C,0x38,0x7F,0xFF,0xE0,0x00,
0x00,0x00,0x78,0x70,0xFF,0xFF,0xE0,0x00,
0x00,0x00,0xFF,0xE0,0xFF,0xFF,0xE0,0x00,
0x00,0x01,0xFF,0xE0,0x7F,0xFF,0x80,0x00,
0x00,0x07,0xFF,0xC0,0x7F,0xFF,0x00,0x00,
0x00,0x1F,0xFF,0x80,0x7F,0xFC,0x00,0x00,
0x00,0x0F,0xFF,0x00,0x7F,0xF8,0x00,0x00,
0x00,0x0F,0xFE,0x00,0x01,0xF8,0x00,0x00,
0x00,0x0F,0xFE,0x00,0x01,0xF8,0x00,0x00,
0x00,0x07,0x1C,0x20,0x01,0xF0,0x00,0x00,
0x00,0x04,0x1F,0xE0,0x01,0xF0,0x00,0x00,
0x00,0x00,0x3F,0xE0,0x01,0xF0,0x00,0x00,
0x00,0x00,0x7F,0xE0,0x01,0xF0,0x00,0x00,
0x00,0x00,0x7F,0xC0,0x01,0xF0,0x00,0x00,
0x00,0x00,0xFF,0x80,0x01,0xF0,0x00,0x00,
0x00,0x01,0xFE,0x00,0x01,0xF0,0x00,0x00,
0x00,0x07,0xF8,0x00,0x01,0xF0,0x00,0x00,
0x00,0x03,0xE0,0x00,0x01,0xF0,0x00,0x00,
0x00,0x03,0xC0,0x60,0x03,0xE0,0x00,0x00,
0x00,0x01,0x80,0xE0,0x03,0xF0,0x00,0x00,
0x00,0x00,0x03,0xE0,0x03,0xFF,0xFE,0x00,
0x00,0x00,0x07,0x80,0x07,0xFF,0xFF,0x80,
0x00,0x00,0x1F,0x00,0x3F,0xFF,0xFF,0x80,
0x00,0x00,0x7E,0x01,0xFF,0xFF,0xFF,0xC0,
0x00,0x00,0xF8,0x0F,0xFF,0xFF,0xFF,0xC0,
0x00,0x03,0xF0,0x7F,0xF0,0x00,0x03,0xC0,
0x00,0x0F,0xE0,0xFE,0x00,0x00,0x00,0x00,
0x00,0x0F,0xC0,0x70,0x00,0x00,0x00,0x00,
0x00,0x0F,0x80,0x40,0x00,0x00,0x00,0x00,
0x00,0x07,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x03,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
};
char fang64H[]={
/* 以下是 '方' 的 64點陣華文新魏 字模,512 byte */
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x07,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x07,0xC0,0x00,0x00,0x00,
0x00,0x00,0x00,0x07,0xE0,0x00,0x00,0x00,
0x00,0x00,0x00,0x07,0xE0,0x00,0x00,0x00,
0x00,0x00,0x00,0x07,0xF0,0x00,0x00,0x00,
0x00,0x00,0x00,0x03,0xF0,0x00,0x00,0x00,
0x00,0x00,0x00,0x01,0xF8,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x70,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x7C,0x00,
0x00,0x00,0x00,0x00,0x03,0xFF,0xFC,0x00,
0x00,0x00,0x00,0x00,0x3F,0xFF,0xFE,0x00,
0x00,0x00,0x00,0x01,0xFF,0xFF,0xFE,0x00,
0x00,0x00,0x00,0x1F,0xFF,0xFF,0xFE,0x00,
0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFE,0x00,
0x00,0x00,0x0F,0xFF,0xFF,0xFF,0xFE,0x00,
0x00,0x00,0x7F,0xFF,0xF8,0x00,0x1E,0x00,
0x00,0x0F,0xFF,0xFF,0xF8,0x00,0x00,0x00,
0x00,0xFF,0xFF,0x00,0xF8,0x00,0x00,0x00,
0x00,0x7F,0xE0,0x01,0xFC,0x00,0x00,0x00,
0x00,0x7F,0x00,0x01,0xE6,0x00,0x00,0x00,
0x00,0x60,0x00,0x03,0xC3,0x80,0x00,0x00,
0x00,0x00,0x00,0x07,0x81,0xC0,0x00,0x00,
0x00,0x00,0x00,0x07,0x00,0xF0,0x00,0x00,
0x00,0x00,0x00,0x0F,0x00,0xF8,0x00,0x00,
0x00,0x00,0x00,0x1E,0x00,0xFC,0x00,0x00,
0x00,0x00,0x00,0x3C,0x00,0xFC,0x00,0x00,
0x00,0x00,0x00,0x78,0x00,0xF8,0x00,0x00,
0x00,0x00,0x01,0xF0,0x01,0xF0,0x00,0x00,
0x00,0x00,0x03,0xE0,0x01,0xE0,0x00,0x00,
0x00,0x00,0x07,0xC0,0x03,0xE0,0x00,0x00,
0x00,0x00,0x1F,0x80,0x03,0xC0,0x00,0x00,
0x00,0x00,0x7F,0x00,0x07,0xC0,0x00,0x00,
0x00,0x01,0xFF,0x00,0x0F,0x80,0x00,0x00,
0x00,0x07,0xFF,0x00,0x0F,0x80,0x00,0x00,
0x00,0x1F,0xF8,0x00,0x1F,0x00,0x00,0x00,
0x00,0x3F,0xC0,0x10,0x3E,0x00,0x00,0x00,
0x00,0x00,0x00,0x0F,0xFE,0x00,0x00,0x00,
0x00,0x00,0x00,0x0F,0xFC,0x00,0x00,0x00,
0x00,0x00,0x00,0x07,0xF8,0x00,0x00,0x00,
0x00,0x00,0x00,0x03,0xF8,0x00,0x00,0x00,
0x00,0x00,0x00,0x01,0xF0,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0xE0,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0xC0,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
};
char huo64H[]={
/* 以下是 '獲' 的 64點陣華文新魏 字模,512 byte */
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x60,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x70,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0xF0,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0xF0,0x00,0x00,
0x00,0x00,0x00,0x00,0x01,0xE0,0x00,0x00,
0x00,0x00,0x00,0x00,0x01,0xE0,0x00,0x00,
0x00,0x00,0x00,0xF0,0x03,0xC0,0x00,0x00,
0x00,0x00,0x00,0xF0,0x03,0xC0,0x00,0x00,
0x00,0x00,0x00,0xF0,0x03,0x80,0x00,0x00,
0x00,0x00,0x00,0xF0,0x07,0x81,0xC0,0x00,
0x00,0x00,0x00,0xF0,0x07,0xFF,0xC0,0x00,
0x00,0x00,0x00,0xF0,0x0F,0xFF,0xC0,0x00,
0x00,0x00,0x00,0x7F,0xFF,0xFF,0x00,0x00,
0x00,0x00,0x01,0xFF,0xFF,0xE0,0x00,0x00,
0x00,0x00,0x3F,0xFC,0x1F,0x00,0x00,0x00,
0x00,0x00,0x7F,0xF8,0x1C,0x00,0x00,0x00,
0x00,0x00,0x7F,0x38,0x18,0x00,0x00,0x00,
0x00,0x00,0x3C,0x10,0x30,0x00,0x00,0x00,
0x00,0x00,0x10,0x00,0x30,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x0C,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x0E,0x00,0x80,0x00,
0x00,0x00,0x00,0x20,0x04,0x00,0xE0,0x00,
0x00,0x00,0x30,0x70,0x04,0x00,0xF0,0x00,
0x00,0x00,0x1F,0xF0,0x04,0x00,0xF8,0x00,
0x00,0x00,0x0F,0xF0,0x0C,0x00,0x78,0x00,
0x00,0x00,0x07,0xE0,0x0C,0x00,0x00,0x00,
0x00,0x00,0x07,0xC0,0x0F,0xF8,0x00,0x00,
0x00,0x00,0x0F,0xC0,0x0F,0xF8,0x00,0x00,
0x00,0x00,0x1F,0xE0,0x1F,0xF8,0x00,0x00,
0x00,0x00,0x1F,0xF0,0xFF,0xF0,0x00,0x00,
0x00,0x00,0x39,0xFF,0xFF,0xC0,0x00,0x00,
0x00,0x00,0x61,0xFF,0xFF,0x00,0x00,0x00,
0x00,0x00,0xC1,0xC3,0xFE,0x00,0x00,0x00,
0x00,0x01,0x83,0xC1,0xFC,0x00,0x00,0x00,
0x00,0x0F,0x03,0xC1,0x9C,0x00,0x00,0x00,
0x00,0x0C,0x07,0xC0,0x1E,0x00,0x00,0x00,
0x00,0x0C,0x0C,0xC0,0x1F,0x00,0x00,0x00,
0x00,0x00,0x10,0xC0,0x1F,0x80,0x00,0x00,
0x00,0x00,0x20,0xC0,0x3F,0xC0,0x00,0x00,
0x00,0x00,0x60,0xC0,0x3F,0xE0,0x00,0x00,
0x00,0x00,0xC0,0xC0,0x3F,0xF0,0x00,0x00,
0x00,0x03,0x80,0xC0,0x60,0x38,0x00,0x00,
0x00,0x07,0x80,0x80,0xE0,0x0E,0x00,0x00,
0x00,0x0F,0x00,0x81,0xC0,0x07,0x00,0x00,
0x00,0x3C,0x00,0x87,0xC0,0x07,0xC0,0x00,
0x00,0x00,0x01,0xFF,0x80,0x03,0xF0,0x00,
0x00,0x00,0x01,0xFF,0x00,0x03,0xFE,0x00,
0x00,0x00,0x01,0xFC,0x00,0x01,0xFF,0xC0,
0x00,0x00,0x01,0xE0,0x00,0x00,0xFF,0xF0,
0x00,0x00,0xFF,0x80,0x00,0x00,0x7F,0xF8,
0x00,0x00,0x7F,0x80,0x00,0x00,0x1F,0xF8,
0x00,0x00,0x1F,0x80,0x00,0x00,0x00,0x00,
0x00,0x00,0x0F,0x80,0x00,0x00,0x00,0x00,
0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
};
char sheng64H[]={
/* 以下是 '勝' 的 64點陣華文新魏 字模,512 byte */
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x0E,0x00,0x00,
0x00,0x00,0x00,0xE0,0x00,0x0F,0x00,0x00,
0x00,0x00,0x07,0xFC,0x00,0x1F,0x00,0x00,
0x00,0x00,0x7F,0xFC,0x00,0x1E,0x00,0x00,
0x00,0x00,0xF0,0x7C,0x00,0x1E,0x00,0x00,
0x00,0x00,0xC0,0x78,0x00,0x1E,0x00,0x00,
0x00,0x00,0xC0,0x78,0x00,0x1E,0x00,0x00,
0x00,0x01,0xC0,0x38,0x00,0x1E,0x00,0x00,
0x00,0x01,0x80,0x38,0x00,0x1E,0x00,0x00,
0x00,0x01,0x80,0x30,0x00,0x1E,0x00,0x00,
0x00,0x01,0x80,0x30,0x00,0x1E,0x00,0x00,
0x00,0x01,0xCC,0x70,0x00,0x1E,0x00,0x00,
0x00,0x01,0xFE,0x70,0x10,0x1E,0x30,0x00,
0x00,0x01,0xFC,0x70,0x38,0x1F,0xF0,0x00,
0x00,0x01,0xFC,0x70,0x3F,0xFF,0xF0,0x00,
0x00,0x01,0xF8,0x70,0x3F,0xFF,0xF0,0x00,
0x00,0x01,0xE0,0x70,0x7F,0xFF,0xE0,0x00,
0x00,0x01,0xC0,0x70,0x7F,0xFF,0xC0,0x00,
0x00,0x01,0x80,0x70,0xFF,0xFF,0x00,0x00,
0x00,0x03,0x00,0x71,0xF1,0xFC,0x00,0x00,
0x00,0x03,0x0C,0x71,0xC0,0x7C,0x00,0x00,
0x00,0x03,0xFC,0x73,0x80,0x3C,0x00,0x00,
0x00,0x03,0xFC,0x7F,0x00,0x3C,0x00,0x00,
0x00,0x03,0xFC,0x7E,0x00,0x3C,0x00,0x00,
0x00,0x03,0xF8,0x7C,0x00,0x3F,0xF0,0x00,
0x00,0x07,0xF0,0x70,0x00,0x7F,0xF0,0x00,
0x00,0x07,0xC0,0x30,0x1F,0xFF,0xF0,0x00,
0x00,0x07,0x00,0x30,0x1F,0xFF,0xF0,0x00,
0x00,0x0E,0x00,0x30,0x0F,0xFF,0xE0,0x00,
0x00,0x08,0x00,0x30,0x0F,0xFF,0x80,0x00,
0x00,0x08,0x00,0x30,0x0F,0xFC,0x00,0x00,
0x00,0x18,0x00,0x30,0x00,0x38,0x00,0x00,
0x00,0x18,0x00,0x30,0x00,0x38,0x00,0x00,
0x00,0x38,0x00,0x30,0x00,0x38,0x00,0x00,
0x00,0x78,0x00,0x30,0x00,0x3C,0x00,0x00,
0x00,0x78,0x00,0x70,0x00,0x3C,0x00,0x00,
0x00,0xF0,0x00,0x60,0x00,0x3E,0x03,0x00,
0x01,0xF0,0x00,0x60,0x00,0x7F,0xFF,0x80,
0x03,0xE0,0x00,0x60,0x03,0xFF,0xFF,0xC0,
0x03,0xC0,0x00,0xE0,0x3F,0xFF,0xFF,0xC0,
0x07,0x80,0x7F,0xF1,0xFF,0xFF,0xFF,0xC0,
0x0F,0x00,0x3F,0xF1,0xFF,0xF8,0x07,0xC0,
0x1C,0x00,0x1F,0xF0,0xF0,0x00,0x00,0x00,
0x10,0x00,0x0F,0xF0,0x80,0x00,0x00,0x00,
0x00,0x00,0x03,0xF0,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0xE0,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x20,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
};
char bai64H[]={
/* 以下是 '白' 的 64點陣華文新魏 字模,512 byte */
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x03,0x80,0x00,0x00,0x00,
0x00,0x00,0x00,0x07,0xC0,0x00,0x00,0x00,
0x00,0x00,0x00,0x0F,0xC0,0x00,0x00,0x00,
0x00,0x00,0x00,0x1F,0x80,0x00,0x00,0x00,
0x00,0x00,0x00,0x3E,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x78,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0xF8,0x00,0x00,0x00,0x00,
0x00,0x00,0x01,0xF0,0x00,0x00,0x00,0x00,
0x00,0x00,0x03,0xC0,0x00,0x00,0x00,0x00,
0x00,0x00,0x03,0x80,0x00,0x00,0x00,0x00,
0x00,0x00,0x07,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x0E,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x18,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x30,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x70,0x00,0x0F,0xF0,0x00,0x00,
0x00,0x00,0x60,0x01,0xFF,0xFE,0x00,0x00,
0x00,0x00,0xE0,0x0F,0xFF,0xFF,0xC0,0x00,
0x00,0x01,0xE0,0x7F,0xF0,0x3F,0xF0,0x00,
0x00,0x03,0xE3,0xFF,0x80,0x0F,0xF0,0x00,
0x00,0x07,0xFF,0xFC,0x00,0x0F,0xE0,0x00,
0x00,0x0F,0xFF,0xF0,0x00,0x0F,0xE0,0x00,
0x00,0x1F,0xFF,0xC0,0x00,0x0F,0xC0,0x00,
0x00,0x3F,0xFF,0x00,0x00,0x0F,0xC0,0x00,
0x00,0x7F,0xFE,0x00,0xF8,0x0F,0xC0,0x00,
0x00,0x7C,0x7C,0x0F,0xF8,0x0F,0x80,0x00,
0x00,0x70,0x3C,0x1F,0xF0,0x0F,0x80,0x00,
0x00,0x40,0x3C,0x1F,0xF0,0x1F,0x80,0x00,
0x00,0x00,0x3C,0x1F,0xC0,0x1F,0x00,0x00,
0x00,0x00,0x3C,0x0F,0x00,0x1F,0x00,0x00,
0x00,0x00,0x1E,0x06,0x00,0x1F,0x00,0x00,
0x00,0x00,0x1E,0x00,0x00,0x3E,0x00,0x00,
0x00,0x00,0x0E,0x00,0x00,0x3E,0x00,0x00,
0x00,0x00,0x0E,0x00,0x00,0x3E,0x00,0x00,
0x00,0x00,0x0F,0x00,0xE0,0x7C,0x00,0x00,
0x00,0x00,0x07,0x03,0xF0,0x7C,0x00,0x00,
0x00,0x00,0x03,0xFF,0xF8,0xFC,0x00,0x00,
0x00,0x00,0x03,0xFF,0xFF,0xF8,0x00,0x00,
0x00,0x00,0x01,0xFF,0x87,0xF8,0x00,0x00,
0x00,0x00,0x01,0xF0,0x03,0xF0,0x00,0x00,
0x00,0x00,0x00,0x80,0x00,0xF0,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x60,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
};
char wu64H[]={
/* 以下是 '五' 的 64點陣華文新魏 字模,512 byte */
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x70,0x00,0x00,
0x00,0x00,0x00,0x00,0x07,0xF8,0x00,0x00,
0x00,0x00,0x00,0x00,0x3F,0xF8,0x00,0x00,
0x00,0x00,0x00,0x03,0xFF,0xF8,0x00,0x00,
0x00,0x00,0x03,0xFF,0xFF,0xF0,0x00,0x00,
0x00,0x00,0x03,0xFF,0xFF,0xC0,0x00,0x00,
0x00,0x00,0x03,0xFF,0xFF,0x80,0x00,0x00,
0x00,0x00,0x03,0xFF,0xFE,0x00,0x00,0x00,
0x00,0x00,0x01,0xFF,0xFC,0x00,0x00,0x00,
0x00,0x00,0x01,0xFF,0xF8,0x00,0x00,0x00,
0x00,0x00,0x00,0xFF,0xE0,0x00,0x00,0x00,
0x00,0x00,0x00,0x07,0xE0,0x00,0x00,0x00,
0x00,0x00,0x00,0x03,0xE0,0x00,0x00,0x00,
0x00,0x00,0x00,0x03,0xE0,0x00,0x00,0x00,
0x00,0x00,0x00,0x03,0xC0,0x00,0x00,0x00,
0x00,0x00,0x00,0x07,0xFF,0xC0,0x00,0x00,
0x00,0x00,0x00,0x07,0xFF,0xF0,0x00,0x00,
0x00,0x00,0x00,0x0F,0xFF,0xFC,0x00,0x00,
0x00,0x00,0x00,0x3F,0xFF,0xFC,0x00,0x00,
0x00,0x00,0x1F,0xFF,0xFF,0xF8,0x00,0x00,
0x00,0x00,0x1F,0xFF,0x83,0xF0,0x00,0x00,
0x00,0x00,0x3F,0xFF,0x03,0xF0,0x00,0x00,
0x00,0x00,0x18,0x1F,0x03,0xF0,0x00,0x00,
0x00,0x00,0x00,0x1E,0x03,0xE0,0x00,0x00,
0x00,0x00,0x00,0x1C,0x03,0xE0,0x00,0x00,
0x00,0x00,0x00,0x3C,0x03,0xE0,0x00,0x00,
0x00,0x00,0x00,0x38,0x03,0xC0,0x00,0x00,
0x00,0x00,0x00,0x78,0x07,0xC0,0x00,0x00,
0x00,0x00,0x00,0x78,0x07,0x80,0x00,0x00,
0x00,0x00,0x00,0x70,0x07,0x80,0x00,0x00,
0x00,0x00,0x00,0xF0,0x0F,0x80,0x00,0x00,
0x00,0x00,0x00,0xF0,0xFF,0x80,0x00,0x00,
0x00,0x00,0x01,0xFF,0xFF,0xFF,0xF8,0x00,
0x00,0x00,0x07,0xFF,0xFF,0xFF,0xFC,0x00,
0x00,0x00,0x1F,0xFF,0xFF,0xFF,0xFE,0x00,
0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFE,0x00,
0x00,0x0F,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,
0x00,0xFF,0xFF,0xC0,0x00,0x01,0xFF,0x00,
0x00,0xFF,0xE0,0x00,0x00,0x00,0x1F,0x00,
0x00,0xFE,0x00,0x00,0x00,0x00,0x07,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
};
char zi64H[]={
/* 以下是 '子' 的 64點陣華文新魏 字模,512 byte */
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00,
0x00,0x00,0x00,0x03,0xFF,0x00,0x00,0x00,
0x00,0x00,0x00,0x1F,0xFF,0xC0,0x00,0x00,
0x00,0x00,0x00,0x7F,0xFF,0xE0,0x00,0x00,
0x00,0x00,0x01,0xFE,0x0F,0xE0,0x00,0x00,
0x00,0x00,0x07,0xF8,0x0F,0xC0,0x00,0x00,
0x00,0x00,0x1F,0xE0,0x0F,0x80,0x00,0x00,
0x00,0x00,0x7F,0xC0,0x0F,0x00,0x00,0x00,
0x00,0x00,0x7F,0x00,0x1E,0x00,0x00,0x00,
0x00,0x00,0x3C,0x00,0x1C,0x00,0x00,0x00,
0x00,0x00,0x18,0x00,0x38,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x60,0x00,0x00,0x00,
0x00,0x00,0x00,0x03,0xE0,0x00,0x00,0x00,
0x00,0x00,0x00,0x03,0xE0,0x00,0x00,0x00,
0x00,0x00,0x00,0x01,0xE0,0x00,0x00,0x00,
0x00,0x00,0x00,0x01,0xE0,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0xFF,0xFF,0xE0,0x00,
0x00,0x00,0x00,0x00,0xFF,0xFF,0xF0,0x00,
0x00,0x00,0x00,0x03,0xFF,0xFF,0xF0,0x00,
0x00,0x00,0x00,0x3F,0xFF,0xFF,0xF8,0x00,
0x00,0x00,0x01,0xFF,0xFF,0xFF,0xF8,0x00,
0x00,0x00,0x0F,0xFF,0xFC,0x00,0x3C,0x00,
0x00,0x00,0x7F,0xFF,0xF8,0x00,0x04,0x00,
0x00,0x07,0xFF,0xF8,0x78,0x00,0x00,0x00,
0x00,0x7F,0xFF,0x80,0x78,0x00,0x00,0x00,
0x00,0x7F,0xE0,0x00,0x78,0x00,0x00,0x00,
0x00,0x7E,0x00,0x00,0x78,0x00,0x00,0x00,
0x00,0x30,0x00,0x00,0x78,0x00,0x00,0x00,
0x00,0x20,0x00,0x00,0x78,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x78,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x78,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x78,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x78,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x78,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x70,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x70,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x70,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x70,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x70,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x70,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x70,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0xF0,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0xF0,0x00,0x00,0x00,
0x00,0x00,0x06,0x00,0xF0,0x00,0x00,0x00,
0x00,0x00,0x03,0xFF,0xE0,0x00,0x00,0x00,
0x00,0x00,0x00,0xFF,0xE0,0x00,0x00,0x00,
0x00,0x00,0x00,0x3F,0xE0,0x00,0x00,0x00,
0x00,0x00,0x00,0x03,0xE0,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x60,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
};
char qi64H[]={
/* 以下是 '棋' 的 64點陣華文新魏 字模,512 byte */
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x03,0x80,0x00,0x00,0x00,0x00,
0x00,0x00,0x03,0x80,0x00,0x04,0x00,0x00,
0x00,0x00,0x03,0x00,0x00,0x07,0x00,0x00,
0x00,0x00,0x03,0x00,0x00,0x0F,0x00,0x00,
0x00,0x00,0x03,0x00,0x00,0x0F,0x00,0x00,
0x00,0x00,0x03,0x00,0x00,0x0E,0x00,0x00,
0x00,0x00,0x02,0x00,0x00,0x0E,0x00,0x00,
0x00,0x00,0x02,0x00,0x30,0x0E,0x00,0x00,
0x00,0x00,0x02,0x00,0x30,0x0E,0x00,0x00,
0x00,0x00,0x02,0x00,0x30,0x0E,0x00,0x00,
0x00,0x00,0x02,0x00,0x30,0x0E,0x00,0x00,
0x00,0x00,0x06,0x00,0x30,0x0F,0x80,0x00,
0x00,0x00,0x06,0x00,0x30,0x3F,0xE0,0x00,
0x00,0x00,0x07,0x00,0x3F,0xFF,0xE0,0x00,
0x00,0x00,0x07,0xE0,0x7F,0xFF,0xE0,0x00,
0x00,0x00,0x3F,0xE3,0xFF,0xFF,0x80,0x00,
0x00,0x01,0xFF,0xE3,0xFF,0xFE,0x00,0x00,
0x00,0x3F,0xFF,0xC1,0xFF,0x9E,0x00,0x00,
0x00,0x3F,0xFF,0x81,0xF0,0x1E,0x00,0x00,
0x00,0x3F,0xFF,0x00,0x70,0x1E,0x00,0x00,
0x00,0x3F,0xFE,0x00,0x7F,0x1C,0x00,0x00,
0x00,0x1F,0x3E,0x00,0x7F,0x1C,0x00,0x00,
0x00,0x18,0x1E,0x00,0x7F,0x1C,0x00,0x00,
0x00,0x00,0x1F,0x00,0x78,0x1C,0x00,0x00,
0x00,0x00,0x3F,0x80,0x70,0x1C,0x00,0x00,
0x00,0x00,0x3F,0xC0,0x70,0x1C,0x00,0x00,
0x00,0x00,0x7F,0xC0,0x7F,0x1C,0x00,0x00,
0x00,0x00,0xFF,0xC0,0x7E,0x1C,0x00,0x00,
0x00,0x01,0xFC,0x00,0x7E,0x1C,0x00,0x00,
0x00,0x03,0xFC,0x00,0x78,0x1C,0x00,0x00,
0x00,0x03,0xCC,0x00,0x70,0x1C,0x02,0x00,
0x00,0x07,0x0C,0x00,0x60,0x1F,0xFF,0x00,
0x00,0x0E,0x0C,0x00,0x60,0xFF,0xFF,0x00,
0x00,0x1C,0x0C,0x00,0x7F,0xFF,0xFF,0x80,
0x00,0x38,0x0C,0x07,0xFF,0xFF,0xFF,0x80,
0x00,0xF0,0x0F,0xFF,0xFF,0xE0,0x00,0x80,
0x01,0xE0,0x0F,0xFF,0x00,0x00,0x00,0x00,
0x01,0x80,0x0F,0x80,0x00,0x00,0x00,0x00,
0x00,0x00,0x0C,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x0C,0x00,0x00,0x08,0x00,0x00,
0x00,0x00,0x0C,0x00,0x40,0x07,0xC0,0x00,
0x00,0x00,0x0C,0x01,0xC0,0x03,0xF0,0x00,
0x00,0x00,0x0C,0x07,0x80,0x01,0xF8,0x00,
0x00,0x00,0x0C,0x1F,0x00,0x01,0xF8,0x00,
0x00,0x00,0x0C,0x1F,0x00,0x00,0xF8,0x00,
0x00,0x00,0x0C,0x0E,0x00,0x00,0x38,0x00,
0x00,0x00,0x0C,0x04,0x00,0x00,0x18,0x00,
0x00,0x00,0x1C,0x00,0x00,0x00,0x08,0x00,
0x00,0x00,0x1C,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
};
char zuo16H[]={
/* 以下是 '作' 的 16點陣黑體 字模,32 byte */
0x18,0xC0,0x18,0xC0,0x19,0x80,0x31,0xFE,
0x33,0xFE,0x76,0xC0,0xF0,0xFC,0xB0,0xFC,
0x30,0xC0,0x30,0xC0,0x30,0xFE,0x30,0xFE,
0x30,0xC0,0x30,0xC0,0x30,0xC0,0x00,0x00,
};
char zhe16H[]={
/* 以下是 '者' 的 16點陣黑體 字模,32 byte */
0x03,0x00,0x03,0x0C,0x1F,0xCC,0x1F,0xD8,
0x03,0x30,0xFF,0xFE,0xFF,0xFE,0x03,0x00,
0x0F,0xF8,0x3F,0xF8,0xEC,0x18,0xCF,0xF8,
0x0C,0x18,0x0F,0xF8,0x0F,0xF8,0x00,0x00,
};
char mh16H[]={
0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00,
0x30,0x00, 0x30,0x00, 0x00,0x00, 0x00,0x00,
0x30,0x00, 0x30,0x00, 0x00,0x00, 0x00,0x00
};
char zhao16H[]={
0x0C,0x00, 0x0C,0x0C, 0x7F,0x8C, 0x7F,0xCC,
0x0C,0x6C, 0x0C,0x38, 0xFF,0x98, 0xFF,0xB8,
0x0C,0x38, 0x6F,0x6C, 0x6F,0xCC, 0x7C,0x84,
0x7C,0x00, 0xCF,0xFE, 0x87,0xFE, 0x00,0x00
};
char peng16H[]={
0x00,0x30, 0x77,0x7C, 0x77,0x7C, 0x55,0x64,
0x55,0x7C, 0x77,0x64, 0x55,0x6C, 0x55,0x60,
0x77,0x7E, 0x77,0x7E, 0x55,0x06, 0x55,0x76,
0x55,0x06, 0xD5,0x1E, 0xAB,0x0C, 0x00,0x00
};
void init(void)
{
int gdriver = DETECT, gmode, errorcode;
int i,j;
registerbgidriver(0);
initgraph(&gdriver, &gmode,"c:\\turboc2");
errorcode = graphresult();
if (errorcode != grOk)
{
printf("Graphics error: %s",grapherrormsg(errorcode));
printf("Press any key to halt:");
getch();
exit(1);
}
chess.x=10*K;
chess.y=10*K;
chess.kao=1;
chess.ok=0;
for(i=0;i<N;i++)
for(j=0;j<N;j++)
chess.yes[i][j]=0;
}
void draw_mat(char *mat,int matsize,int x,int y,int color)
{
int i,j,k,m;
m=(matsize-1)/8+1;
for(j=0;j<matsize;j++)
for(i=0;i<m;i++)
for(k=0;k<8;k++)
if(mat[j*m+i]&(0x80>>k))
putpixel(x+i*8+k,y+j,color);
}
void player_clew(void) /*input message*/
{
setcolor(15);
settextstyle(0,0,1);
outtextxy(24,10,"1P: Up Down Left Right Enter 2P: W S A D Space ");
setcolor(10);
outtextxy(570,10,"QUIT:ESC");
}
void draw_chessboard(void)
{
int i;
setcolor(1);
rectangle((N+2)*K,K,(N+9)*K,(N+1)*K);
setfillstyle(1,3);
floodfill((N+2)*K+1,K+2,1);
for(i=0;i<=N;i++)
{
line(K,K*i+K,K*N+K,K*i+K);
line(K*i+K,K,K*i+K,K*N+K);
}
for(i=0;i<5;i++)
{
circle(5*K,5*K,i);
circle(15*K,5*K,i);
circle(5*K,15*K,i);
circle(15*K,15*K,i);
circle(10*K,10*K,i);
}
}
void show_character(void)/*input word*/
{
draw_mat(wu64H,64,479,21,0);
draw_mat(zi64H,64,529,21,0);
draw_mat(qi64H,64,579,21,0);
draw_mat(wu64H,64,480,22,1);
draw_mat(zi64H,64,530,22,1);
draw_mat(qi64H,64,580,22,1);
draw_mat(zuo16H,16,480,460,15);
draw_mat(zhe16H,16,498,460,15);
draw_mat(mh16H,16,516,460,15);
draw_mat(zhao16H,16,530,460,15);
draw_mat(peng16H,16,552,460,15);
}
void cursor_position(int x,int y,int color)
{
setcolor(color);
line(x-K/2,y-K/2,x-K/2+5,y-K/2);
line(x-K/2,y-K/2,x-K/2,y-K/2+5);
line(x+K/2,y-K/2,x+K/2-5,y-K/2);
line(x+K/2,y-K/2,x+K/2,y-K/2+5);
line(x-K/2,y+K/2,x-K/2+5,y+K/2);
line(x-K/2,y+K/2,x-K/2,y+K/2-5);
line(x+K/2,y+K/2,x+K/2-5,y+K/2);
line(x+K/2,y+K/2,x+K/2,y+K/2-5);
if(color==4)
setcolor(15);
}
void draw_chessman(int x,int y,int color)
{
int i;
setcolor(color);
for(i=0;i<10;i++)
circle(x,y,i);
}
void x_and_y(void)/*顯示光標的橫縱座標*/
{
char str1[10],str2[10];
setfillstyle(1,7);
bar(24,460,192,480);
setcolor(14);
settextstyle(0,0,2);
sprintf(str1,"X:%d",(chess.x-K)/K);
sprintf(str2,"Y:%d",(chess.y-K)/K);
outtextxy(70,470,str1);
outtextxy(145,470,str2);
setcolor(15);
}
void win_(void)/*判斷是否勝出*/
{
int i,j;
for(i=0;i<=N;i++)
{
for(j=0;j<=N;j++)
{
if(((j+4)<=N&&chess.yes[i][j]!=0&&
chess.yes[i][j]==chess.yes[i][j+1]&&
chess.yes[i][j+1]==chess.yes[i][j+2]&&
chess.yes[i][j+2]==chess.yes[i][j+3]&&
chess.yes[i][j+3]==chess.yes[i][j+4])||
((i+4)<=N&&chess.yes[i][j]!=0&&
chess.yes[i][j]==chess.yes[i+1][j]&&
chess.yes[i+1][j]==chess.yes[i+2][j]&&
chess.yes[i+2][j]==chess.yes[i+3][j]&&
chess.yes[i+3][j]==chess.yes[i+4][j])||
((i+4)<=N&&(j+4)<=N&&chess.yes[i][j]!=0&&
chess.yes[i][j]==chess.yes[i+1][j+1]&&
chess.yes[i+1][j+1]==chess.yes[i+2][j+2]&&
chess.yes[i+2][j+2]==chess.yes[i+3][j+3]&&
chess.yes[i+3][j+3]==chess.yes[i+4][j+4])||
((i+4)<=N&&j>=4&&chess.yes[i][j]!=0&&
chess.yes[i][j]==chess.yes[i+1][j-1]&&
chess.yes[i+1][j-1]==chess.yes[i+2][j-2]&&
chess.yes[i+2][j-2]==chess.yes[i+3][j-3]&&
chess.yes[i+3][j-3]==chess.yes[i+4][j-4]))
{
if(chess.yes[i][j]==1)
chess.ok=1;
else
chess.ok=2;
break;
}
}
if(chess.ok!=0)
break;
}
}
void game_over(void)
{
if(chess.ok==1)
{
draw_mat(bai64H,64,528,99,0);
draw_mat(bai64H,64,530,100,15);
}
else
{
draw_mat(hong64H,64,528,99,0);
draw_mat(hong64H,64,530,100,4);
}
draw_mat(fang64H,64,529,189,0);
draw_mat(huo64H,64,529,259,0);
draw_mat(sheng64H,64,529,329,0);
draw_mat(fang64H,64,530,190,0);
draw_mat(huo64H,64,530,260,0);
draw_mat(sheng64H,64,530,330,0);
}
void exit_(int x)
{
while(1)
{
key=bioskey(0);
if(key==Y||key==n)
break;
}
if(x==key)
exit(1);
}
void game_play(void)
{
int q=0;
setcolor(15);
settextstyle(1,0,2);
settextjustify(CENTER_TEXT, CENTER_TEXT);
while(1)
{
x_and_y();
key=bioskey(0);
switch(key)
{
case right:
if(chess.kao==1&&chess.x<19*K)
{
cursor_position(chess.x,chess.y,0);
chess.x+=K;
cursor_position(chess.x,chess.y,15);
}
break;
case left:
if(chess.kao==1&&chess.x>K)
{
cursor_position(chess.x,chess.y,0);
chess.x-=K;
cursor_position(chess.x,chess.y,15);
}
break;
case up:
if(chess.kao==1&&chess.y>K)
{
cursor_position(chess.x,chess.y,0);
chess.y-=K;
cursor_position(chess.x,chess.y,15);
}
break;
case down:
if(chess.kao==1&&chess.y<19*K)
{
cursor_position(chess.x,chess.y,0);
chess.y+=K;
cursor_position(chess.x,chess.y,15);
}
break;
case enter:
if(chess.kao==1&&chess.yes[chess.x/K-1][chess.y/K-1]==0)
{
int k;
chess.yes[chess.x/K-1][chess.y/K-1]=1;
win_();
if(chess.ok==1)
{
q=1;
game_over();
outtextxy(14*K,19*K+12,"CONTINUE ?(Y/N)");
exit_(n);
}
else
{
cursor_position(chess.x,chess.y,4);
chess.kao=2;
draw_chessman(chess.x,chess.y,15);
}
}
break;
case A:
if(chess.kao==2&&chess.x>K)
{
cursor_position(chess.x,chess.y,0);
chess.x-=K;
cursor_position(chess.x,chess.y,4);
}
break;
case D:
if(chess.kao==2&&chess.x<19*K)
{
cursor_position(chess.x,chess.y,0);
chess.x+=K;
cursor_position(chess.x,chess.y,4);
}
break;
case W:
if(chess.kao==2&&chess.y>K)
{
cursor_position(chess.x,chess.y,0);
chess.y-=K;
cursor_position(chess.x,chess.y,4);
}
break;
case S:
if(chess.kao==2&&chess.y<19*K)
{
cursor_position(chess.x,chess.y,0);
chess.y+=K;
cursor_position(chess.x,chess.y,4);
}
break;
case space:
if(chess.kao==2&&chess.yes[chess.x/K-1][chess.y/K-1]==0)
{
int k;
chess.yes[chess.x/K-1][chess.y/K-1]=2;
win_();
if(chess.ok==2)
{
q=1;
game_over();
setcolor(15);
outtextxy(14*K,19*K+12,"CONTINUE ?(Y/N)");
exit_(n);
}
else
{
cursor_position(chess.x,chess.y,15);
chess.kao=1;
draw_chessman(chess.x,chess.y,4);
setcolor(15);
}
}
break;
case esc:
outtextxy(14*K,19*K+12,"QUIT ?(Y/N)");
exit_(Y);
setcolor(0);
outtextxy(14*K,19*K+12,"QUIT ?(Y/N)");
setcolor(15);
break;
}
if(q==1)
break;
}
}
void main(void)
{
while(1)
{
init();
player_clew();
draw_chessboard();
show_character();
cursor_position(10*K,10*K,15);
game_play();
}
closegraph();
}