论坛交流
首页办公自动化| 网页制作| 平面设计| 动画制作| 数据库开发| 程序设计| 全部视频教程
应用视频: Windows | Word2007 | Excel2007 | PowerPoint2007 | Dreamweaver 8 | Fireworks 8 | Flash 8 | Photoshop cs | CorelDraw 12
编程视频: C语言视频教程 | HTML | Div+Css布局 | Javascript | Access数据库 | Asp | Sql Server数据库Asp.net  | Flash AS
当前位置 > 文字教程 > Photoshop教程
Tag:photoshop cs,照片,非主流,水晶,效果,画笔,圣诞,滤镜,艺术,手绘,蒙版,抠图,风景,特效,人像,矢量,国画,图像,数码,合成,玻璃,美女,图案,鼠绘,调色,婚纱,插画,图层,山水,漫画,透明,水粉,光线,笔刷,工具,实例,入门,人物,头发,签名,视频,壁纸,水墨,相框,海报,立体,动画,文字,换头,视频教程

C语言实例:华荣道

文章类别:Photoshop | 发表日期:2010-11-6 9:35:14

#include<graphics.h>
#include<dos.h>
#include<math.h>
#include<alloc.h>
#include<stdio.h>

#define SPACE 0x3920
#define ESC 0x11b
#define ENTER 0x1c0d
#define ALT_LW 0x1100
#define ALT_LC 0x2e00
#define KEY_LY 0x1579
#define KEY_LN 0x316e
#define TAB 0xf09
#define KEY_UP 0x4800
#define KEY_DOWN 0x5000
#define KEY_LEFT 0x4b00
#define KEY_RIGHT 0x4d00

#define PASS 19


int yy[PASS][40]={{2,0,4,2,0,0,2,1,0,1,2,2,0,2,2,3,0,3,2,4,2,2,4,3,0,4,1,5,2,3,3,4,3,3,4,4,1,4,2,5},
                  {2,0,4,2,0,2,2,3,0,0,2,1,0,1,2,2,3,3,4,5,2,2,4,3,0,3,1,4,0,4,1,5,2,3,3,4,1,3,2,4},
                  {2,0,4,2,2,3,4,4,0,1,2,2,0,2,2,3,0,3,2,4,2,2,4,3,0,0,1,1,2,4,3,5,3,4,4,5,1,0,2,1},
                  {1,0,3,2,0,2,1,4,3,2,4,4,1,3,2,5,2,3,3,5,1,2,3,3,0,0,1,1,3,0,4,1,3,1,4,2,0,1,1,2},
                  {1,0,3,2,0,2,2,3,2,2,4,3,0,3,2,4,2,3,4,4,1,4,3,5,0,0,1,1,3,0,4,1,3,1,4,2,0,1,1,2},
                  {0,0,2,2,2,0,4,1,2,1,4,2,0,2,1,4,1,2,2,4,2,2,4,3,0,4,1,5,2,3,3,4,3,3,4,4,1,4,2,5},
                  {0,0,2,2,0,2,2,3,2,2,4,3,0,3,2,4,2,3,4,4,0,4,2,5,2,0,3,1,2,1,3,2,3,1,4,2,3,0,4,1},
                  {1,0,3,2,0,0,1,2,0,2,2,3,0,3,1,5,3,3,4,5,1,3,3,4,2,2,3,3,3,0,4,1,3,1,4,2,3,2,4,3},
                  {1,0,3,2,0,3,2,4,2,3,4,4,0,4,2,5,3,0,4,2,2,4,4,5,0,2,1,3,2,2,3,3,3,2,4,3,1,2,2,3},
                  {1,0,3,2,0,0,1,2,3,2,4,4,1,2,3,3,0,2,1,4,1,3,3,4,0,4,1,5,3,0,4,1,3,1,4,2,3,4,4,5},
                  {0,0,2,2,0,3,2,4,0,2,2,3,2,2,4,3,3,0,4,2,2,3,4,4,0,4,1,5,2,0,3,1,2,1,3,2,3,4,4,5},
                  {1,0,3,2,3,0,4,2,0,0,1,2,0,3,1,5,3,3,4,5,1,2,3,3,0,2,1,3,2,3,3,4,1,3,2,4,3,2,4,3},
                  {0,0,2,2,3,0,4,2,2,0,3,2,0,3,1,5,1,3,2,5,0,2,2,3,2,2,3,3,2,3,3,4,3,3,4,4,3,2,4,3},
                  {1,0,3,2,0,2,2,3,2,2,4,3,0,3,2,4,3,0,4,2,2,3,4,4,0,4,1,5,0,0,1,1,0,1,1,2,3,4,4,5},
                  {1,0,3,2,0,0,1,2,3,0,4,2,1,2,3,3,0,2,1,4,1,3,3,4,0,4,1,5,3,2,4,3,3,3,4,4,3,4,4,5},
                  {1,0,3,2,0,0,1,2,3,0,4,2,3,2,4,4,0,2,1,4,1,2,3,3,0,4,1,5,2,3,3,4,1,3,2,4,3,4,4,5},
                  {1,0,3,2,0,0,1,2,3,0,4,2,1,2,3,3,1,3,3,4,1,4,3,5,0,2,1,3,3,2,4,3,3,3,4,4,0,3,1,4},
                  {1,0,3,2,0,1,1,3,3,1,4,3,1,2,2,4,2,4,4,5,0,4,2,5,0,0,1,1,3,3,4,4,0,3,1,4,3,0,4,1},
                  {1,0,3,2,0,1,1,3,3,1,4,3,1,2,3,3,1,3,3,4,1,4,3,5,0,0,1,1,0,3,1,4,3,3,4,4,3,0,4,1}
                  };/*定义等级,各位的位置,曹操/张飞/赵云/马超/黄忠/关羽/兵/卒/丁/勇*/

int Sign[PASS][20]={{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0},
                    {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,1},
                    {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,1,1},
                    {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1,0},
                    {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1,0},
                    {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0},
                    {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0},
                    {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,1},
                    {0,1,1,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}, 
                    {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,1},
                    {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,1},
                    {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,1},
                    {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0},
                    {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,1},
                    {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,1},
                    {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,1},
                    {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1,0},
                    {1,1,1,1,1,1,1,1,1,1,0,1,1,1,0,1,1,1,1,1},
                    {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1,0}
                   }; /*标记各等级被占的位置*/



char cao1hk20[]={
    0x00,0x00,0x00,0x01,0x98,0x00,0x01,0x90,
    0x40,0x7f,0xff,0xe0,0x00,0x90,0x00,0x0f,
    0xff,0x80,0x08,0x91,0x00,0x08,0x91,0x00,
    0x0f,0xff,0x00,0x08,0x91,0x00,0x0f,0xff,
    0x00,0x00,0x02,0x00,0x07,0xff,0x00,0x04,
    0x02,0x00,0x04,0x02,0x00,0x07,0xfe,0x00,
    0x04,0x02,0x00,0x07,0xfe,0x00,0x04,0x02,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
};
char cao2hk20[]={
    0x00,0x00,0x00,0x08,0x00,0x00,0x08,0x7f,
    0x00,0x08,0x42,0x00,0x08,0x42,0x00,0x7e,
    0x7e,0x00,0x0a,0x00,0x00,0x09,0xe7,0xc0,
    0x0b,0x24,0x40,0x0d,0x24,0x40,0x79,0xe7,
    0xc0,0x48,0x08,0x00,0x0f,0xff,0xe0,0x08,
    0x3c,0x00,0x08,0x6a,0x00,0x08,0xc9,0x00,
    0x09,0x88,0xc0,0x7a,0x08,0x40,0x14,0x08,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
};
char zhanghk20[]={
    0x00,0x00,0x00,0x00,0x20,0x00,0x7f,0x20,
    0x00,0x02,0x21,0x80,0x02,0x23,0x00,0x02,
    0x22,0x00,0x22,0x24,0x00,0x3e,0x38,0x00,
    0x20,0x20,0x00,0x21,0xff,0xc0,0x3e,0x28,
    0x00,0x02,0x24,0x00,0x02,0x24,0x00,0x04,
    0x22,0x00,0x04,0x23,0x00,0x04,0x25,0x80,
    0x04,0x28,0xc0,0x38,0x30,0x00,0x10,0x20,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
};
char feihk20[]={
    0x00,0x00,0x00,0x00,0x00,0x00,0x3f,0xe0,
    0x00,0x00,0x21,0x00,0x00,0x23,0x00,0x00,
    0x24,0x00,0x00,0x28,0x00,0x00,0x30,0x00,
    0x00,0x28,0x00,0x00,0x26,0x00,0x00,0x23,
    0x00,0x00,0x21,0x00,0x00,0x20,0x00,0x00,
    0x10,0x40,0x00,0x10,0x40,0x00,0x08,0x40,
    0x00,0x06,0x40,0x00,0x03,0xc0,0x00,0x00,
    0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
};
char zhaohk20[]={
    0x00,0x00,0x00,0x02,0x00,0x00,0x02,0x00,
    0xc0,0x02,0x40,0x80,0x1f,0xb0,0x80,0x02,
    0x09,0x00,0x02,0x05,0x00,0x02,0x27,0x00,
    0x7f,0xc2,0x00,0x02,0x03,0x00,0x1a,0x05,
    0x00,0x13,0xe8,0x80,0x12,0x08,0x80,0x12,
    0x10,0xc0,0x1a,0x20,0x00,0x26,0x40,0x00,
    0x43,0x00,0x00,0x40,0xff,0xc0,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
};
char yunhk20[]={
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,
    0x00,0x0f,0xfc,0x00,0x00,0x00,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,
    0x7f,0xff,0xc0,0x00,0x40,0x00,0x00,0xc0, 
  0x00,0x00,0x88,0x00,0x01,0x04,0x00,0x02,
    0x02,0x00,0x04,0x03,0x00,0x04,0x01,0x80,
    0x0f,0xff,0x80,0x08,0x00,0x80,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
};
char mahk20[]={
    0x00,0x00,0x00,0x00,0x00,0x00,0x0f,0xfe,
    0x00,0x02,0x04,0x00,0x02,0x04,0x00,0x02,
    0x04,0x00,0x02,0x04,0x00,0x02,0x04,0x00,
    0x06,0x04,0x00,0x04,0x08,0xc0,0x07,0xf7,
    0x80,0x00,0x00,0x80,0x00,0x04,0x80,0x3f,
    0xf8,0x80,0x00,0x00,0x80,0x00,0x00,0x80,
    0x00,0x01,0x80,0x00,0x0f,0x00,0x00,0x06,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
};
char chaohk20[]={
    0x00,0x00,0x00,0x06,0x00,0x00,0x04,0x3f,
    0xc0,0x04,0x0c,0x40,0x3f,0x88,0x40,0x04,
    0x08,0x40,0x04,0x08,0x40,0x04,0x93,0x80,
    0x7f,0x60,0x80,0x04,0x60,0x80,0x14,0x1f,
    0xc0,0x14,0x90,0x80,0x27,0x10,0x80,0x24,
    0x10,0x80,0x34,0x1f,0x80,0x2c,0x10,0x80,
    0x46,0x20,0x00,0x41,0xff,0xe0,0x00,0x07,
    0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
};
char huanghk20[]={
    0x00,0x00,0x00,0x01,0x0c,0x00,0x01,0x08,
    0x00,0x1f,0xff,0xc0,0x01,0x08,0x00,0x01,
    0x08,0x00,0x7f,0xff,0xe0,0x00,0x40,0x00,
    0x0f,0xff,0x00,0x08,0x41,0x00,0x08,0x41,
    0x00,0x0f,0xff,0x00,0x08,0x41,0x00,0x08,
    0x41,0x00,0x0f,0xbf,0x00,0x03,0x08,0x00,
    0x06,0x07,0x00,0x08,0x01,0x80,0x30,0x00,
    0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
};
char zhonghk20[]={
    0x00,0x00,0x00,0x00,0x60,0x00,0x00,0x60,
    0x00,0x08,0x61,0x00,0x0f,0xff,0x00,0x08,
    0x61,0x00,0x08,0x61,0x00,0x08,0x61,0x00,
    0x0f,0xff,0x00,0x08,0x61,0x00,0x00,0x60,
    0x00,0x00,0x80,0x00,0x02,0x61,0x00,0x12,
    0x30,0xc0,0x12,0x32,0x40,0x32,0x02,0x40,
    0x62,0x02,0x00,0x62,0x03,0x00,0x01,0xfc,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
};
char guanghk20[]={
    0x00,0x00,0x00,0x02,0x04,0x00,0x01,0x0c,
    0x00,0x01,0x88,0x00,0x00,0x90,0x00,0x00,
    0x10,0xc0,0x1f,0xef,0x00,0x00,0x40,0x00,
    0x00,0x40,0x00,0x00,0x40,0x40,0x7f,0xff,
    0xe0,0x00,0x50,0x00,0x00,0xd0,0x00,0x00,
    0x88,0x00,0x01,0x0c,0x00,0x03,0x06,0x00,
    0x04,0x03,0x00,0x08,0x01,0xe0,0x30,0x00,
    0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
};
char yuhk20[]={
    0x00,0x00,0x00,0x00,0x00,0x00,0x7f,0xff,
    0xc0,0x00,0x80,0x80,0x00,0x90,0x80,0x10,
    0x88,0x80,0x08,0x8c,0x80,0x0c,0x84,0x80,
    0x00,0x84,0x80,0x00,0x81,0x80,0x03,0x86,
    0x80,0x0c,0x98,0x80,0x30,0xb0,0x80,0x60,
    0x80,0x80,0x00,0x80,0x80,0x00,0x80,0x80,
    0x07,0x87,0x80,0x01,0x81,0x80,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
};
char binhk20[]={
    0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x1e,
    0x00,0x07,0xe0,0x00,0x04,0x00,0x00,0x04,
    0x00,0x00,0x04,0x00,0x80,0x07,0xff,0x00,
    0x04,0x08,0x00,0x04,0x08,0x00,0x04,0x08,
    0x00,0x04,0x08,0x40,0x7f,0xff,0xe0,0x02, 
  0x10,0x00,0x03,0x0c,0x00,0x06,0x03,0x00,
    0x08,0x01,0x80,0x10,0x00,0xc0,0x60,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
};
char zuhk20[]={
    0x00,0x00,0x00,0x00,0x40,0x00,0x00,0x20,
    0x00,0x3f,0xff,0x80,0x02,0x08,0x00,0x02,
    0x0c,0x00,0x06,0x08,0x00,0x05,0x14,0x00,
    0x08,0xa2,0x00,0x08,0xc1,0x00,0x10,0xc1,
    0x00,0x00,0x20,0x40,0x7f,0xff,0xe0,0x00,
    0x20,0x00,0x00,0x20,0x00,0x00,0x20,0x00,
    0x00,0x20,0x00,0x00,0x20,0x00,0x00,0x60,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
};
char dinghk20[]={
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0xc0,0x3f,0xff,0x00,0x00,0x60,0x00,0x00,
    0x60,0x00,0x00,0x60,0x00,0x00,0x60,0x00,
    0x00,0x60,0x00,0x00,0x60,0x00,0x00,0x60,
    0x00,0x00,0x60,0x00,0x00,0x60,0x00,0x00,
    0x60,0x00,0x00,0x60,0x00,0x00,0x60,0x00,
    0x00,0x60,0x00,0x01,0xe0,0x00,0x00,0x40,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
};
char yonghk20[]={
    0x00,0x00,0x00,0x00,0x02,0x00,0x0f,0xff,
    0x00,0x00,0xd0,0x00,0x00,0x60,0x00,0x0f,
    0xff,0x80,0x08,0x21,0x00,0x0f,0xff,0x00,
    0x08,0x21,0x00,0x08,0x21,0x00,0x0f,0xff,
    0x00,0x08,0x41,0x00,0x00,0x41,0x00,0x3f,
    0xff,0x80,0x00,0x81,0x80,0x00,0x81,0x00,
    0x03,0x01,0x00,0x04,0x0f,0x00,0x38,0x06,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
};


union REGS regs;

int xx[10][4]; /*记录各人物当前的实际坐标*/
int Signxx[5][4];/*记录当前已站的位置*/

struct time tim0;
struct time tim1;
int tt1=0;




/*****************************程序开始*************************/

void DrawStr(char *mat,int matsize,int x,int y,int color)/*输出字符*/
{
  int i, j, k, n;
  n = (matsize - 1) / 8 + 1;
  for(j = 0; j < matsize; j++)
    for(i = 0; i < n; i++)
      for(k = 0;k < 8; k++)
        if(mat[j * n + i] & (0x80 >> k))
          putpixel(x + i * 8 + k, y + j, color);
}


void OutTime(int tt)/*计时*/
{
    char str[5];
    setcolor(15);
    setfillstyle(1,5);
    bar(375,155,415,170);
    sprintf(str,"%d",tt);
    outtextxy(380,160,str);
}


int InitMouse(int min_x,int min_y,int max_x,int max_y)/*初始化鼠标*/
{
    int retcode;
    regs.x.ax=0;
    int86(0x33,®s,®s);
    retcode=regs.x.ax;
    if(retcode==0)
        return 0;  /*没有正确安装,返回0*/
    regs.x.ax=7;
    regs.x.cx=min_x;
    regs.x.dx=max_x;
    int86(0x33,®s,®s);
    regs.x.ax=8;
    regs.x.cx=min_y;
    regs.x.dx=max_y;
    int86(0x33,®s,®s);
    return  retcode;
}

void DrawMouse(int mx,int my)/*画出鼠标*/
{   
    int i;
    setcolor(11);
    line(mx,my,mx+3,my+13);
    line(mx,my,mx+4,my+13);
    line(mx,my,mx+5,my+13);
    line(mx,my,mx+12,my+10);
    line(mx,my,mx+13,my+10);
    line(mx,my,mx+14,my+10);
    circle(mx+11,my+16,8);
    circle(mx+11,my+16,7);
    circle(mx+11,my+16,6);
}



int NewMouseKeyTime(int *mx,int *my,int *butt,int *key)/*获取鼠标和键盘和时间*/
{
    int xx0=*mx,yy0=*my;
    int newx,newy,mb;
    int tt0=0;
    do
    {
        regs.x.ax=3;
        int86(0x33,& regs,& regs);
        newx=regs.x.cx;
        newy=regs.x.dx;
        mb=regs.x.bx;
        if(tim0.ti_hour!=0 && tim0.ti_min!=0 && tim0.ti_sec!=0)
        {
            gettime(&tim1);
            tt1=(tim1.ti_hour-tim0.ti_hour)*3600+(tim1.ti_min-tim0.ti_min)*60+(tim1.ti_sec-tim0.ti_sec);
           if(tt1>0 && (tt1-tt0)>=1)
           {
              OutTime(tt1);
              tt0=tt1;
           }
        }
        if(kbhit())
            *key=bioskey(0);
    }while(newx==xx0 && newy==yy0 && mb==0 && *key==0);
    *butt=mb;
    *mx=newx;  /*更改原来的坐标*/
    *my=newy;
}

void InitBack()/* 初始化界面*/
{
    int tu[]={170,390,100,390,100,100,340,100,340,390,270,390,270,372,322,372,322,118,118,118,118,372,170,372,170,390};
    setbkcolor(9);
    cleardevice();
    setcolor(15);
    setlinestyle(0,0,3);
    rectangle(10,10,610,470);
    setcolor(1);
    drawpoly(13,tu);
    setfillstyle(8,11);
    floodfill(110,110,1);
    setfillstyle(1,7);
    bar(120,120,320,370);
    bar(172,370,268,391);

    setcolor(2);
    outtextxy(380,90,"Step");
    setfillstyle(1,5);
    bar(375,105,415,120);
    outtextxy(380,110,"0");
    outtextxy(380,140,"Time");
    bar(375,155,415,170);
    outtextxy(380,160,"0");

    outtextxy(470,120,"HELP");
    outtextxy(450,145,"ESC to exit");
    outtextxy(450,160,"ALT+W open win");
    outtextxy(450,175,"AlT+C open ChPA");
    outtextxy(455,190,"TAB Change");


    setcolor(2);
    setfillstyle(1,7);
    bar(15,15,50,28);
    outtextxy(18,18,"Quit");
    bar(52,15,85,28);
    outtextxy(57,18,"Win");
    bar(87,15,125,28);
    outtextxy(90,18,"ChPA");
}


void Draw(int x,int y,int x0,int y0)/*画出人物的图*/

    setlinestyle(0,0,1);
    setfillstyle(1,6);
    bar(x+1,y+1,x0-1,y0-1);
    setcolor(2);
    rectangle(x+2,y+2,x0-2,y0-2);
    setcolor(1);
    rectangle(x+3,y+3,x0-3,y0-3);
    setcolor(3);
    rectangle(x+4,y+4,x0-4,y0-4);
}
void Setxx(int n) /* 计算各人实际的坐标,并标记*/
{
    int i,j=0;
    for(i=0;i<10;i++)
    {
        xx[ i][0]=120+50*yy[n-1][j];
        j++;
        xx[ i][1]=120+50*yy[n-1][j];
        j++;
        xx[ i][2]=120+50*yy[n-1][j];
        j++;
        xx[ i][3]=120+50*yy[n-1][j];
        j++;
    }
    for(i=0,j=0;i<5;i++)
    {
        Signxx[ i][0]=Sign[n-1][j];
        j++;
        Signxx[ i][1]=Sign[n-1][j];
        j++;
        Signxx[ i][2]=Sign[n-1][j];
        j++;
        Signxx[ i][3]=Sign[n-1][j];
        j++;
    }
}


void DrawGraph(int i,int n)/*画出人物*/
{
    for(i=0;i<n;i++)
        switch(i)
        {
            case 0:Draw(xx[ i][0],xx[ i][1],xx[ i][2],xx[ i][3]);
                   DrawStr(cao1hk20,20,xx[ i][0]+20,xx[ i][1]+40,15);
                   DrawStr(cao2hk20,20,xx[ i][0]+60,xx[ i][1]+40,15);
                   break;
            case 1:Draw(xx[ i][0],xx[ i][1],xx[ i][2],xx[ i][3]);
                   DrawStr(zhanghk20,20,xx[ i][0]+20,xx[ i][1]+15,15);          if(xx[ i][2]-xx[ i][0]>=100)
                        DrawStr(feihk20,20,xx[ i][0]+55,xx[ i][1]+15,15);
                   else
                        DrawStr(feihk20,20,xx[ i][0]+20,xx[ i][1]+60,15);
                   break;
            case 2:Draw(xx[ i][0],xx[ i][1],xx[ i][2],xx[ i][3]);
                   DrawStr(zhaohk20,20,xx[ i][0]+20,xx[ i][1]+15,15);
                   if(xx[ i][2]-xx[ i][0]>=100)
                        DrawStr(yunhk20,20,xx[ i][0]+55,xx[ i][1]+15,15);
                   else
                        DrawStr(yunhk20,20,xx[ i][0]+20,xx[ i][1]+60,15);
                   break;
            case 3:Draw(xx[ i][0],xx[ i][1],xx[ i][2],xx[ i][3]);
                   DrawStr(mahk20,20,xx[ i][0]+20,xx[ i][1]+15,15);
                   if(xx[ i][2]-xx[ i][0]>=100)
                        DrawStr(chaohk20,20,xx[ i][0]+55,xx[ i][1]+15,15);
                   else
                        DrawStr(chaohk20,20,xx[ i][0]+20,xx[ i][1]+60,15);
                   break;
            case 4:Draw(xx[ i][0],xx[ i][1],xx[ i][2],xx[ i][3]);
                   DrawStr(huanghk20,20,xx[ i][0]+20,xx[ i][1]+15,15);
                   if(xx[ i][2]-xx[ i][0]>=100)
                        DrawStr(zhonghk20,20,xx[ i][0]+55,xx[ i][1]+15,15);
                   else
                        DrawStr(zhonghk20,20,xx[ i][0]+20,xx[ i][1]+60,15);
                   break;
            case 5:Draw(xx[ i][0],xx[ i][1],xx[ i][2],xx[ i][3]);
                   DrawStr(guanghk20,20,xx[ i][0]+20,xx[ i][1]+15,15);
                   if(xx[ i][2]-xx[ i][0]>=100)
                        DrawStr(yuhk20,20,xx[ i][0]+55,xx[ i][1]+15,15);
                   else
                        DrawStr(yuhk20,20,xx[ i][0]+20,xx[ i][1]+60,15);
                   break;
            case 6:Draw(xx[ i][0],xx[ i][1],xx[ i][2],xx[ i][3]);
                   DrawStr(binhk20,20,xx[ i][0]+15,xx[ i][1]+15,15);
                   break;
            case 7:Draw(xx[ i][0],xx[ i][1],xx[ i][2],xx[ i][3]);
                   DrawStr(zuhk20,20,xx[ i][0]+15,xx[ i][1]+15,15);
                   break;
            case 8:Draw(xx[ i][0],xx[ i][1],xx[ i][2],xx[ i][3]);
                   DrawStr(dinghk20,20,xx[ i][0]+15,xx[ i][1]+15,15);
                   break;
            case 9:Draw(xx[ i][0],xx[ i][1],xx[ i][2],xx[ i][3]);
                   DrawStr(yonghk20,20,xx[ i][0]+15,xx[ i][1]+15,15);
                   break;
        }
}



void UpdateSignxx(int n,int k) /*更新Signxx里面的数据*/
{
    if(n==0)
    {
        Signxx[(xx[n][1]-120)/50+1][(xx[n][0]-120)/50]=k;
        Signxx[(xx[n][1]-120)/50][(xx[n][0]-120)/50+1]=k;
    }
    Signxx[(xx[n][1]-120)/50][(xx[n][0]-120)/50]=k;
    Signxx[(xx[n][3]-120)/50-1][(xx[n][2]-120)/50-1]=k;
}



void StepNO(int step) /*输出走了多少步*/
{
    char str[4];
    setcolor(15);
    setfillstyle(1,5);
    bar(375,105,415,120);
    sprintf(str,"%d",step);
    outtextxy(380,110,str);
}



void DrawTXT()/*画出输入文本框*/
{
    setcolor(2);
    setfillstyle(1,14);    bar(270,40,450,100);
    rectangle(271,41,449,99);
    setcolor(1);
    rectangle(273,43,447,97);
    setlinestyle(0,0,3);
    outtextxy(305,47,"Enter you name");
    outtextxy(320,57,"(10 words)");
}


void WinnerWrite(int pass,int Step)/*记录赢家名字*/
{
    int i,j;
    int step,time,ps;
    long ad; /*用于记录存取地址*/
    FILE *fp;
    char name[11];
    if(((fp=fopen("d:\\win.win","r+"))==NULL) && ((fp=fopen("d:\\win.win","w"))==NULL))
    {
        setfillstyle(1,14);
        bar(65,35,180,60);
        setcolor(4);
        outtextxy(70,39,"Write Error!!");
        outtextxy(70,50,"Any key goon");
        getch();
    }
    else
    {   
        while(!feof(fp))
        {
            ad=ftell(fp);
            fscanf(fp,"%d %s %d %d",&ps,name,&step,&time);
            if(ps==pass)
            {
                if((step>Step) || (step==Step && time>tt1))
                {
                    DrawTXT();
                    for(i=0;i<10;i++)
                    {
                        name[ i]=getch();
                        DrawTXT();
                        if(name[ i]==8)
                            i-=2;
                        if(name[ i]==13)
                        {
                            name[i+1]='\0';
                            break;
                        }
                        name[i+1]='\0';
                        outtextxy(305,75,name);
                    }
                    fseek(fp,ad,0);
                    fprintf(fp,"%d %s %d %d\n",pass,name,Step,tt1);
                    break;

                }
            }
            if(feof(fp) && ps!=pass)
            {
                DrawTXT();
                for(i=0;i<10;i++)
                {
                    name[ i]=getch();
                    DrawTXT();
                    if(name[ i]==8)
                        i-=2;
                    if(name[ i]==13)
                    {
                        name[i+1]='\0';
                        break;
                    }
                    name[i+1]='\0';
                    outtextxy(305,75,name);
                }
                fprintf(fp,"%d %s %d %d\n",pass,name,Step,tt1);
            }
        }
    }
    fclose(fp);

}


void WinnerTXT()/*显示赢家记录*/
{
    int i;
    int ps,step,time;
    char name[11],str[5];
    FILE *fp;
    setcolor(15);
    if((fp=fopen("d:\\win.win","r"))==NULL)
        outtextxy(55,35,"Can't open win.win");
    else
    {
        setfillstyle(1,7);
        bar(52,30,252,235);
        bar(52,28,85,30);
        setcolor(15);
        rectangle(53,31,251,234);
        setcolor(2);
        rectangle(55,34,249,232);
        setcolor(5);
        outtextxy(57,35,"NO");
        outtextxy(110,35,"NAME");
        outtextxy(170,35,"STEP");
        outtextxy(215,35,"TIME");
        setcolor(15);
        for(i=0;!feof(fp);i++)
        {
            fscanf(fp,"%d %s %d %d\n",&ps,name,&step,&time);
            sprintf(str,"%d",ps);
            outtextxy(57,45+10*i,str); 
          outtextxy(80,45+10*i,name);
            sprintf(str,"%d",step);
            outtextxy(170,45+10*i,str);
            sprintf(str,"%d",time);
            outtextxy(220,45+10*i,str);
        }
    }
    fclose(fp);
}

void ChPATXT()/*选关*/
{
    int i;
    char str[3];
    setfillstyle(1,7);
    bar(87,28,125,221);
    setcolor(2);
    rectangle(88,29,124,220);
    setcolor(15);
    rectangle(90,31,122,218);
    setcolor(14);
    for(i=0;i<PASS;i++)
    {
        sprintf(str,"%d",i+1);
        outtextxy(95,30+10*i,str);
        str[2]='\0';
    }
}

void DrawCH(int i)/*显示所选中的*/
{
    setwritemode(1);
    setcolor(2);
    rectangle(89,28+10*i,123,38+10*i);
    setwritemode(0);
}

void WinTXT()/*赢了时的对话框*/
{
    setfillstyle(1,15);
    bar(230,190,380,270);
    setcolor(15);
    rectangle(232,192,378,268);
    setcolor(2);
    rectangle(234,194,376,266);
    setfillstyle(1,12);
    bar(236,196,374,264);
    outtextxy(270,210,"You Win");
    setcolor(15);
    setfillstyle(1,15);
    bar(281,246,329,259);
    rectangle(280,245,330,260);
    setcolor(2);
    rectangle(282,247,328,258);
    setcolor(0);
    outtextxy(286,250,"Colse");
}

void ExitTXT()/*退出*/
{
    setcolor(2);
    setfillstyle(1,14);
    bar(200,200,400,300);
    rectangle(201,201,399,299);
    setcolor(13);
    rectangle(203,203,397,297);
    outtextxy(250,230,"Do you exit?");
    setfillstyle(1,11);
    bar(230,270,280,290);
    bar(320,270,370,290);
    rectangle(231,271,279,289);
    rectangle(321,271,369,289);
    setcolor(2);
    outtextxy(232,277,"Yes(Y)");
    outtextxy(330,277,"No(N)");
}


/***********************主函数***************************/

main()
{   char str[2];
    int x,y,buttons,oldx=0,oldy=0; /*鼠标坐标和按键*/
    void far *ico;
    int t=-1,b,tx,ty; /*选中状态和其形状*/
    int mark=0;/*标记是否移动*/
    int pass=1;  /*当前的关数*/
    int key=0;/*键盘变量*/
    int i,j;/*定义循环变量*/
    int ch1,ch2;/*选关时的变量*/
    int FileT=0;/*标记菜单是否有效*/
    int Step=0;/*统计走了多步*/
    int gm=DETECT,gd;
    if(InitMouse(10,10,595,455)==0) /*判断有没有正确安装鼠标,并初始化*/
    {
        printf("Mouse or Mouse Driver Absent,P1ease install!");
        getch();
        exit(1);
    }
    initgraph(&gm,&gd,"");
    if((ico=farmalloc(imagesize(0,0,20,40)))==NULL)
    {
        printf("Memory error");
        getch();
        exit(1);
    }

    InitBack();
    Setxx(pass);
    DrawGraph(0,10);
    while(1)
    {
        NewMouseKeyTime(&x,&y,&buttons,&key);/*读取时间,鼠标,键盘*/
        putimage(oldx,oldy,ico,COPY_PUT);
        oldx=x;
        oldy=y;
        for(i=0;i<10;i++)/*判断当前所选中的人*/
        {
            if(x>xx[ i][0] && x<xx[ i][2] && y>xx[ i][1] && y<xx[ i][3] && buttons==1 && t<10)
            {
                setwritemode(1);
                setlinestyle(0,0,1);
                setcolor(15);
                if(t>0)
                    rectangle(xx[t][0]+6,xx[t][1]+6,xx[t][2]-6,xx[t][3]-6); 
              t=i;
                rectangle(xx[t][0]+6,xx[t][1]+6,xx[t][2]-6,xx[t][3]-6);
                setwritemode(0);
                break;
            }
        }
        if(key==TAB && FileT==0)/*用键盘TAB选择*/
        {
            setwritemode(1);
            setlinestyle(0,0,1);
            setcolor(15);
            if(t==-1)
            {
                t=0;
                rectangle(xx[t][0]+6,xx[t][1]+6,xx[t][2]-6,xx[t][3]-6);
            }
            else
            {
                rectangle(xx[t][0]+6,xx[t][1]+6,xx[t][2]-6,xx[t][3]-6);
                if(++t>9)
                    t=0;
                rectangle(xx[t][0]+6,xx[t][1]+6,xx[t][2]-6,xx[t][3]-6);
            }
            setwritemode(0);
        }
        if((Step==1 || Step==2) && (tim0.ti_hour==0 || tim0.ti_min==0 || tim0.ti_sec==0)) /*读取时间*/
            gettime(&tim0);
        if(((x<320 && x>120 && y<370 && y>120 && buttons==1) || (key!=0 && FileT==0)) && t>=0 && t<10) /*人物移动*/
        {
            if((xx[t][2]-xx[t][0])>=100)
                tx=2;
            else
                tx=1;
            if((xx[t][3]-xx[t][1])>=100)
                ty=2;
            else
                ty=1;
            if((x<xx[t][0] && y>xx[t][1] && y<xx[t][3]) || (key==KEY_LEFT && xx[t][0]>120)) /*向左移动*/
            {
                if(key==KEY_LEFT)
                    b=1;
                else
                    b=(xx[t][0]-x+50)/50;
                if(ty==1)
                    for(i=0,mark=0;i<b;i++)
                        if(Signxx[(xx[t][1]-120)/50][(xx[t][0]-120)/50-1-i]==1)
                        {
                            mark=1;
                            break;
                        }
                if(ty==2)
                    for(i=0,mark=0;i<b;i++)
                        if(Signxx[(xx[t][1]-120)/50][(xx[t][0]-120)/50-1-i]==1 ||
                           Signxx[(xx[t][1]-120)/50+1][(xx[t][0]-120)/50-1-i]==1)
                        {
                            mark=1;
                            break;
                        }
                if(mark==0)
                {
                    Step+=b;
                    StepNO(Step);
                    UpdateSignxx(t,0);
                    setfillstyle(1,7);
                    bar(xx[t][0],xx[t][1],xx[t][2],xx[t][3]);
                    xx[t][0]-=b*50;
                    xx[t][2]-=b*50;
                    DrawGraph(t,t+1);
                    UpdateSignxx(t,1);
                }
                if(key==KEY_LEFT)
                    rectangle(xx[t][0]+6,xx[t][1]+6,xx[t][2]-6,xx[t][3]-6);

            }
            if((x>xx[t][2] && y>xx[t][1] && y<xx[t][3])|| (key==KEY_RIGHT && xx[t][2]<320)) /*向右移动*/
            {
                if(key==KEY_RIGHT)
                    b=1;
                else
                    b=(x-xx[t][2]+50)/50;
                if(ty==1)
                    for(i=0,mark=0;i<b;i++)
                        if(Signxx[(xx[t][3]-120)/50-1][(xx[t][2]-120)/50+i]==1) 
                  {
                            mark=1;
                            break;
                        }
                if(ty==2)
                    for(i=0,mark=0;i<b;i++)
                        if(Signxx[(xx[t][3]-120)/50-1][(xx[t][2]-120)/50+i]==1 ||
                           Signxx[(xx[t][3]-120)/50-2][(xx[t][2]-120)/50+i]==1)
                        {
                            mark=1;
                            break;
                        }
                if(mark==0)
                {
                    Step+=b;
                    StepNO(Step);
                    UpdateSignxx(t,0);
                    setfillstyle(1,7);
                    bar(xx[t][0],xx[t][1],xx[t][2],xx[t][3]);
                    xx[t][0]+=b*50;
                    xx[t][2]+=b*50;
                    DrawGraph(t,t+1);
                    UpdateSignxx(t,1);
                }
                if(key==KEY_RIGHT)  
                    rectangle(xx[t][0]+6,xx[t][1]+6,xx[t][2]-6,xx[t][3]-6);
            }
            if((y<xx[t][1] && x>xx[t][0] && x<xx[t][2]) || (key==KEY_UP && xx[t][1]>120))/*向上移动*/
            {
                mark=0;
                if(key==KEY_UP)
                    b=1;
                else
                    b=(xx[t][1]-y+50)/50;
                if(tx==1)
                    for(i=0;i<b;i++)
                        if(Signxx[(xx[t][1]-120)/50-1-i][(xx[t][0]-120)/50]==1)
                        {
                            mark=1;
                            break;
                        }
                if(tx==2)
                    for(i=0;i<b;i++)
                        if(Signxx[(xx[t][1]-120)/50-1-i][(xx[t][0]-120)/50]==1 ||
                           Signxx[(xx[t][1]-120)/50-1-i][(xx[t][0]-120)/50+1]==1)
                        {
                            mark=1;
                            break;
                        }
                if(mark==0)
                {
                    Step+=b;
                    StepNO(Step);
                    UpdateSignxx(t,0);
                    setfillstyle(1,7);
                    bar(xx[t][0],xx[t][1],xx[t][2],xx[t][3]);
                    xx[t][1]-=b*50;
                    xx[t][3]-=b*50;
                    DrawGraph(t,t+1);
                    UpdateSignxx(t,1);
                }
                if(key==KEY_UP)
                    rectangle(xx[t][0]+6,xx[t][1]+6,xx[t][2]-6,xx[t][3]-6);
            }
            if((y>xx[t][3] && x>xx[t][0] && x<xx[t][2]) || (key==KEY_DOWN && xx[t][3]<370)) /*向下移动*/
            {
                mark=0;
                if(key==KEY_DOWN)
                    b=1;
                else
                    b=(y-xx[t][3]+50)/50;
                if(tx==1)
                    for(i=0;i<b;i++)
                        if(Signxx[(xx[t][3]-120)/50+i][(xx[t][2]-120)/50-1]==1)
                        {
                            mark=1;
                            break;
                        }
                if(tx==2)
                    for(i=0;i<b;i++) 
          if(Signxx[(xx[t][3]-120)/50+i][(xx[t][2]-120)/50-1]==1 ||
                           Signxx[(xx[t][3]-120)/50+i][(xx[t][2]-120)/50-2]==1)
                        {
                            mark=1;
                            break;
                        }
                if(mark==0)
                {
                    Step+=b;
                    StepNO(Step);
                    UpdateSignxx(t,0);
                    setfillstyle(1,7);
                    bar(xx[t][0],xx[t][1],xx[t][2],xx[t][3]);
                    xx[t][1]+=b*50;
                    xx[t][3]+=b*50;
                    DrawGraph(t,t+1);
                    UpdateSignxx(t,1);
                }
                if(key==KEY_DOWN)
                    rectangle(xx[t][0]+6,xx[t][1]+6,xx[t][2]-6,xx[t][3]-6);
            }
        }
        if(xx[0][0]==170 && xx[0][1]==270 && t<11) /*判断是否把曹操移出*/
        {   t=11;
            tim0.ti_hour=0;
            tim0.ti_min=0;
            tim0.ti_sec=0;
            WinTXT();
        }
        if(t==11 && (key==SPACE || (x>280 && y>245 && x<330 && y<260 && buttons==1)))/*曹操已经移出*/
        {
            WinnerWrite(pass,Step);
            if((++pass)>PASS) /*通版了*/
            {
                closegraph();
                farfree(ico);
                exit(1);
            }
            t=-1;
            Step=0;
            InitBack();
            Setxx(pass);
            DrawGraph(0,10);
        }
        if((x>52 && x<85 && y>15 && y<28 && buttons==1) || key==ALT_LW) /*是否按下Win*/
        {
            WinnerTXT();
            FileT=1;
        }
        else if((buttons==1 || key==SPACE) && FileT==1)
        {
            FileT=0;
            InitBack();
            DrawGraph(0,10);
        }
        if((x>87 && x<125 && y>15 && y<28 && buttons==1) || key==ALT_LC)/*是否按下ChPA*/
        {
            ChPATXT();
            FileT=2;
            ch1=-1;
            ch2=0;
            buttons=0;
        }
        if(((x>87 && x<125 && y>30 && y<220) || key!=0) && FileT==2) /*选关*/
        {
            if(x>87 && x<125 && y>30 && y<220)
                ch2=(y-30)/10;
            if(abs(ch2-ch1)>=1 || key==KEY_UP || key==KEY_DOWN)
            {
                if(key==KEY_UP && ch1>0)
                    ch2--;
                if(key==KEY_DOWN && ch1<18)
                    ch2++;
                if(ch1>=0)
                    DrawCH(ch1);
                ch1=ch2;
                DrawCH(ch1);
            }
            if((buttons==1 || key==ENTER) && ch1>=0)
            {
                FileT=0;
                pass=ch1+1;
                t=-1;
                Step=0;
                tim0.ti_hour=0;
                tim0.ti_min=0;
                tim0.ti_sec=0;
                InitBack();
                Setxx(pass);
                DrawGraph(0,10);
            }
        }
        if((buttons==1 || key==SPACE) && FileT==2)/*清除选关窗口*/
        {
            FileT=0;
            InitBack();
            DrawGraph(0,10);
        }
        if((x>15 && x<50 && y>15 && y<28 && buttons==1) || key==ESC) /*是否按下Quit*/
        {
            FileT=3;
            ExitTXT();
        }
        if(((x>320 && x<370 && y>270 && y<290) || key==KEY_LN) && FileT==3)
        {
            t=12;
            if(buttons==1 || key==KEY_LN)
            {
                t=-1;
                FileT=0;
                InitBack();
                DrawGraph(0,10);
                StepNO(Step);
            }
        }
        if(((x>230 && x<280 && y>270 && y<290) || key==KEY_LY) && FileT==3)
        {
            t=13;
            if(buttons==1 || key==KEY_LY)
            {
                farfree(ico);
                closegraph();
                exit(1);  /*退出*/
            }
        }
        getimage(x,y,x+20,y+25,ico);
        DrawMouse(x,y);
        key=0;
    }
}
视频教程列表
文章教程搜索
 
Photoshop推荐教程
Photoshop热门教程
看全部视频教程
购买方式/价格
购买视频教程: 咨询客服
tel:15972130058