当前位置:文档之家› c语言坦克大战源代码

c语言坦克大战源代码


3,24,9,1,6,10,1,7,10,2,8,10, 2,9,10,1,10,10,1,11,10,3,16,10, 3,17,10,3,20,10,3,21,10,3,22, 10,3,23,10,3,24,10,3,3,11,3,4,11, 3,5,11,3,6,11,3,7,11,2,8,11, 2,9,11,3,10,11,3,11,11,3,12,11, 3,13,11,3,14,11,3,15,11,3,16, 11,3,17,11,3,3,12,3,4,12,3,5,12, 3,6,12,3,7,12,2,8,12,2,9,12,3, 10,12,3,11,12,3,12,12,3,13,12, 3,14,12,3,15,12,3,16,12,3,17, 12,3,3,13,1,8,13,1,9,13,1,14,13, 1,15,13,1,21,13,1,22,13,3,25,13, 3,26,13,1,1,14,1,2,14,1,8,14, 1,9,14,1,14,14,1,15,14,1,21, 14,1,22,14,3,25,14,3,26,14,3,1,15, 3,2,15,3,3,15,3,4,15,3,6,15,3,7, 15,3,8,15,3,9,15,3,10,15, 3,11,15,1,14,15,1,15,15,2,19,15, 2,20,15,1,21,15,1,22,15,3,25,15, 3,26,15,3,1,16,3,2,16,3,3,16,3, 4,16,3,6,16,3,7,16,3,8,16,
0x21,0x08,0x02,0x00,0x7F,0xF8,0x02,0x08, 0x04,0x08,0x08,0x08,0x10,0x28,0x20,0x10, };
/*****地**********图*********一************号***********/ /*坐标含义:地图块类型,横坐标,纵坐标 地图一 地图块类型:3 海水,2 草地,1 栅栏 .该地图使用 vb 得到的*/ int map1[]={2,7,1,3,8,1,3,9,1,3, 19,1,3,20,1,2,7,2,3,8,2,3,9,2, 3,19,2,3,20,2,3,1,3,3,2,3,3,3, 3,3,4,3,2,7,3,3,8,3, 3,9,3,3,12,3,3,13,3,3,14,3,3, 15,3,3,16,3,3,17,3,3,18,3,
3,9,16,3,10,16,3,11,16,1,14,16, 1,15,16,2,19,16,2,20,16,3,21,16, 3,22,16,2,23,16,2,24,16,3,25,16, 3,26,16,1,4,17,1,5,17,1,6,17, 2,8,17,2,9,17,2,10,17,2,11,17,2, 12,17,2,13,17,1,14,17,1,15,17, 2,16,17,2,17,17,1,18,17,3,19,17, 3,20,17,3,21,17,3,22,17,2,23,17, 2,24,17,3,25,17,3,26,17,1,4,18, 1,5,18,1,6,18,2,8,18,2,9,18, 2,10,18,2,11,18,2,12,18,2,13,18, 1,18,18,3,19,18,3,20,18,3,21,18, 3,22,18,3,3,19,3,4,19,3,5,19,3,6, 19,3,7,19
/*一些图形,“杀”代表 player2,“我是李勇”代表 player1*/
char sha[]={ /* 以下是 '杀' 的 16 点阵宋体 字模,32 byte */ 0x00,0x20,0x18,0x20,0x06,0x40,0x01,0x80, 0x02,0x60,0x0C,0x30,0x31,0x10,0x01,0x00, 0x7F,0xFE,0x01,0x00,0x09,0x20,0x09,0x10, 0x11,0x08,0x21,0x08,0x05,0x00,0x02,0x00, }; char wo[]={ /* 以下是 '我' 的 16 点阵宋体 字模,32 byte */ 0x06,0x40,0x38,0x50,0x08,0x48,0x08,0x48, 0x08,0x40,0xFF,0xFE,0x08,0x40,0x08,0x48, 0x0E,0x28,0x38,0x30,0
/*定义 global 变量*******************************************/
/*子弹的属性*/ struct myboom{
/*如果子弹 life 为 0 则代表子弹没有发射*/ int life; int x,y; int direction; }; /*子弹们的初始属性*/ struct myboom iboom[NUM]= {{0},{0}};
#include<stdio.h> #include<string.h> #include<stdlib.h> #include<graphics.h> /*定义鼠标键值常量*/ #define ESC 0x011b/*玩家 1 坦克按键*/ #define UP 0x4800 #define DOWN 0x5000 #define LEFT 0x4b00 #define RIGHT 0x4d00 #define ENTER 0x1c0d #define up 0x1177/*玩家 2 坦克按键*/
c 语言坦克大战源代码
/*游戏的整体思路大概是这样的? 首先是欢迎界面,然后进入游戏界面,最后是 gameover 的界面。 本来打算做单人游戏,后来发现让敌人自主移动比较困难,所以改成了双人游戏?
layer1 控制按键是 up,down,left,right,enter,player2 控制按键是 a,s,d,w,space。 */
xC8,0x20,0x08,0x50, 0x09,0x92,0x08,0x0A,0x28,0x06,0x10,0x02, }; char shi[]={ /* 以下是 '是' 的 16 点阵宋体 字模,32 byte */ 0x00,0x00,0x0F,0xF0,0x08,0x10,0x0F,0xF0, 0x08,0x10,0x0F,0xF0,0x00,0x00,0xFF,0xFE, 0x01,0x00,0x09,0x00,0x09,0xF8,0x09,0x00, 0x15,0x00,0x23,0x00,0x40,0xFE,0x00,0x00, }; char li[]={ /* 以下是 '李' 的 16 点阵宋体 字模,32 byte */ 0x01,0x00,0x01,0x00,0x7F,0xFC,0x03,0x80, 0x05,0x40,0x09,0x30,0x31,0x0E,0xDF,0xE4, 0x00,0x80,0x01,0x00,0x7F,0xFE,0x01,0x00, 0x01,0x00,0x01,0x00,0x05,0x00,0x02,0x00, }; char yong[]={ /* 以下是 '勇' 的 16 点阵宋体 字模,32 byte */ 0x3F,0xF0,0x02,0x60,0x01,0x80,0x3F,0xF8, 0x21,0x08,0x3F,0xF8,0x21,0x08,0x3F,0xF8,
#define down 0x1f73 #define left 0x1e61 #define right 0x2064 #define fire 0x246a
/*定义游戏常量*/ /*双人游戏*/ #define NUM 2 /*坦克宽度*/ #define WIDTH 20 /*坦克的数量,宽度*/
/*坦克的属性*/ struct mytank{ int life; int x,y; int direction; };
/*坦克们的初始属性*/ struct mytank itank[NUM]= {{3,10*WIDTH,22*WIDTH},{1,440,40}}; pre[NUM][2]={ {10*WIDTH,22*WIDTH},{440,40}};
/*xy[0]代表自己的坦克; xy[1]及以后代表敌军; 坦克坐标*/ /*存被子弹覆盖的图像*/ void *boom_save[NUM]; /*malloc 开辟图像空间的大小*/ int size; /*动画显示*/ void *save[NUM]; /*后来加上的。。用来让坦克一点一点的动*/ void *isave[NUM+1]; /*储存敌人移动方向*/ int direction=RIGHT; /*接受键盘输入*/ int input[NUM]={DOWN}; ;/*存子弹的图像*/ void *boomimg; void *iboomimg[NUM];/**/ void loading();
/*声明函数************************************/ void draw(int what); void move(int direction); int canmove(int direction,int which); void byebye(int mode); void init(); int welcome(); void write(char *mat,int matsize,int x,int y,int color); void tank(int x,int y,int which,int direction); void wall(int mode,int x,int y); int choose(); void boom(int direction,int prex,int prey,int width); int howmove(); void imove(int direction,int which,int can); void iboommove(int which); void shoot(int which,int direction); void getInitImg(); void drawboom(); void snake(); void isGameOver();
相关主题