📄 tank041.c
字号:
int adage_N=0; /*格言编号*/
int TimeM; /*时间 分*/
int TimeS; /*时间 秒*/
int V=0; /*增援信号 1触发增援*/
int alert01x=0,alert02x=0; /*警报声音判断 防止在1秒钟内重复发声*/
int PLAYER_RISE_TIME=5,PLAYER_RISE=0;
int ENEMY_RISE_TIME=5,ENEMY_RISE=0;
int FRIEND_RISE_TIME=5,FRIEND_RISE=0;
int ENEMY_N , FRIEND_N; /*记录数量*/
int WIN=0;
int WAIT_GAME_EXIT=0, WAIT_GAME_EXIT_TIME=10;
int EXIT_MISSION_SOUND=0; /*任务结束声音 开关*/
int PLAYER_KILL=0;/*玩家杀敌数*/
int PLAYER_DEAD=0;/*玩家死亡次数*/
char tt[50];
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
allegro_init(); /*初始化 Allegro 库*/
install_keyboard(); /*初始化键盘*/
install_mouse(); /*初始化鼠标*/
VGA_RESET(); /*图形模式初始化*/
LoadCharLib(); /*加载中文字库*/
/*
gettime(&t); 取系统时间
R=t.ti_hund; R=毫秒
*/
srand(R); /*产生真正的随机数种子*/
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
/*初始化地图*/
load_file("map/Z0.M",&MAP0[0][0]); /*加载Z 障碍地图*/
load_file("map/B0.M",&MAP1[0][0]); /*加载B 背景地图*/
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
load_config_file("rule/CONFIG.TXT"); /* 读取游戏配置文件 */
load_weapon_file("rule/weapon.txt"); /* 读取武器配置文件 */
load_unit_file("rule/unit.txt"); /* 读取游戏单位配置文件 */
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
if((bmp=load_bmp("pic/LOGO.BMP",pallete))==NULL) /*加载图位文件*/
{printf("Can't open file pic/LOGO.BMP !!!");
return;
}
if((TANK_01=load_bmp("pic/TANK_01.BMP",pallete))==NULL) /*加载图位文件*/
{printf("Can't open file pic/TANK_01.BMP !!!");
return;
}
if((TANK_02=load_bmp("pic/TANK_02.BMP",pallete))==NULL) /*加载图位文件*/
{printf("Can't open file pic/TANK_02.BMP !!!");
return;
}
if((TANK_03=load_bmp("pic/TANK_03.BMP",pallete))==NULL) /*加载图位文件*/
{printf("Can't open file pic/TANK_03.BMP !!!");
return;
}
if((TANK_04=load_bmp("pic/TANK_04.BMP",pallete))==NULL) /*加载图位文件*/
{printf("Can't open file pic/TANK_04.BMP !!!");
return;
}
if((BUILD_01=load_bmp("pic/BUILD_01.BMP",pallete))==NULL) /*加载图位文件*/
{printf("Can't open file pic/BUILD_01.BMP !!!");
return;
}
if((BBD_01=load_bmp("pic/BB120mm.BMP",pallete))==NULL) /*加载图位文件*/
{printf("Can't open file pic/BB120mm.BMP !!!");
return;
}
if((BBD_02=load_bmp("pic/BB30mm.BMP",pallete))==NULL) /*加载图位文件*/
{printf("Can't open file pic/BB30mm.BMP !!!");
return;
}
if((BAO_01=load_bmp("pic/BAO_01.BMP",pallete))==NULL) /*加载图位文件*/
{printf("Can't open file pic/BAO_01.BMP !!!");
return;
}
if((BAO_02=load_bmp("pic/BAO_02.BMP",pallete))==NULL) /*加载图位文件*/
{printf("Can't open file pic/BAO_02.BMP !!!");
return;
}
if((BAO_03=load_bmp("pic/BAO_03.BMP",pallete))==NULL) /*加载图位文件*/
{printf("Can't open file pic/BAO_03.BMP !!!");
return;
}
if((BAO_04=load_bmp("pic/BAO_04.BMP",pallete))==NULL) /*加载图位文件*/
{printf("Can't open file pic/BAO_04.BMP !!!");
return;
}
if((BAO_05=load_bmp("pic/BAO_05.BMP",pallete))==NULL) /*加载图位文件*/
{printf("Can't open file pic/BAO_05.BMP !!!");
return;
}
if((BAO_06=load_bmp("pic/BAO_06.BMP",pallete))==NULL) /*加载图位文件*/
{printf("Can't open file pic/BAO_06.BMP !!!");
return;
}
if((BAO_07=load_bmp("pic/BAO_07.BMP",pallete))==NULL) /*加载图位文件*/
{printf("Can't open file pic/BAO_07.BMP !!!");
return;
}
if((bmp_mouse=load_bmp("pic/mouse.BMP",pallete))==NULL) /*鼠标图位文件*/
{printf("Can't open file pic/mouse.BMP !!!");
return;
}
if((CURSOR_01=load_bmp("pic/CURSOR_01.BMP",pallete))==NULL) /*鼠标图位文件*/
{printf("Can't open file pic/CURSOR_01.BMP !!!");
return;
}
if((map001=load_bmp("pic/map/001.BMP",pallete))==NULL)
{printf("Can't open file pic/map/001.BMP !!!");
return;
}
if((alert_bmp=load_bmp("pic/alert.BMP",pallete))==NULL)
{printf("Can't open file pic/alert.BMP !!!");
return;
}
if((LEI_DA_shadow=load_bmp("pic/LEI_DA_shadow.BMP",pallete))==NULL)
{printf("Can't open file pic/LEI_DA_shadow.BMP !!!");
return;
}
if((COVER=load_bmp("pic/COVER.BMP",pallete))==NULL) /*加载图位文件*/
{printf("Can't open file pic/COVER.BMP !!!");
return;
}
if((COVER2=load_bmp("pic/COVER2.BMP",pallete))==NULL) /*加载图位文件*/
{printf("Can't open file pic/COVER2.BMP !!!");
return;
}
if((COVER_YUAN=load_bmp("pic/COVER_YUAN.BMP",pallete))==NULL) /*加载图位文件*/
{printf("Can't open file pic/COVER_YUAN.BMP !!!");
return;
}
if((JLS_BMP=load_bmp("pic/JIANG_LUO_SAN.BMP",pallete))==NULL) /*加载图位文件*/
{printf("Can't open file pic/JIANG_LUO_SAN.BMP !!!");
return;
}
if((BOMB_ALERT=load_bmp("pic/BOMB_ALERT.BMP",pallete))==NULL) /*加载图位文件*/
{printf("Can't open file pic/BOMB_ALERT.BMP !!!");
return;
}
if((BOMB_ALERT2=load_bmp("pic/BOMB_ALERT2.BMP",pallete))==NULL) /*加载图位文件*/
{printf("Can't open file pic/BOMB_ALERT2.BMP !!!");
return;
}
if((PLANE_BMP=load_bmp("pic/PLANE.BMP",pallete))==NULL) /*加载图位文件*/
{printf("Can't open file pic/PLANE.BMP !!!");
return;
}
if((PLANE_shadow=load_bmp("pic/PLANE_shadow.BMP",pallete))==NULL) /*加载图位文件*/
{printf("Can't open file pic/PLANE_shadow.BMP !!!");
return;
}
if((GoodsBox=load_bmp("pic/GoodsBox.BMP",pallete))==NULL) /*加载图位文件*/
{printf("Can't open file pic/GoodsBox.BMP !!!");
return;
}
if((bmp_score=load_bmp("pic/Number.BMP",pallete))==NULL) /*加载图位文件*/
{printf("Can't open file pic/Number.BMP !!!");
return;
}
if((button_bmp=load_bmp("pic/button_bmp.BMP",pallete))==NULL) /*加载图位文件*/
{printf("Can't open file pic/button_bmp.BMP !!!");
return;
}
if((earth_map_bmp=load_bmp("pic/earth_map_bmp.BMP",pallete))==NULL) /*加载图位文件*/
{printf("Can't open file pic/earth_map_bmp.BMP !!!");
return;
}
if((failed_bmp=load_bmp("pic/failed_bmp.BMP",pallete))==NULL) /*加载图位文件*/
{printf("Can't open file pic/failed_bmp.BMP !!!");
return;
}
if((succeed_bmp=load_bmp("pic/succeed_bmp.BMP",pallete))==NULL) /*加载图位文件*/
{printf("Can't open file pic/succeed_bmp.BMP !!!");
return;
}
set_palette(pallete); /*加载调色板*/
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
/*初始化声音组件, 成功则返回零*/
install_sound(DIGI_AUTODETECT, MIDI_NONE, "");
BAO_SOUND_04 = load_sample("sound/BAO_SOUND_04.wav"); /*从文件读入一个采样声音, 返回它的指针*/
if (!BAO_SOUND_04) {
printf("Error reading WAV file\n");
END=1;
}
BAO_SOUND_05 = load_sample("sound/BAO_SOUND_05.wav"); /*从文件读入一个采样声音, 返回它的指针*/
if (!BAO_SOUND_05) {
printf("Error reading WAV file\n");
END=1;
}
_30mm_fire = load_sample("sound/_30mm_fire.wav"); /*从文件读入一个采样声音, 返回它的指针*/
if (!_30mm_fire) {
printf("Error reading WAV file\n");
END=1;
}
gun_fire = load_sample("sound/gun_fire.wav"); /*从文件读入一个采样声音, 返回它的指针*/
if (!gun_fire) {
printf("Error reading WAV file\n");
END=1;
}
tank_fire = load_sample("sound/tank_fire.wav"); /*从文件读入一个采样声音, 返回它的指针*/
if (!tank_fire) {
printf("Error reading WAV file\n");
END=1;
}
A_BOMB_sound = load_sample("sound/A_BOMB.wav"); /*从文件读入一个采样声音, 返回它的指针*/
if (!A_BOMB_sound) {
printf("Error reading WAV file\n");
END=1;
}
YiHa = load_sample("sound/YiHa.wav"); /*从文件读入一个采样声音, 返回它的指针*/
if (!YiHa) {
printf("Error reading WAV file\n");
END=1;
}
Wheee = load_sample("sound/Wheee.wav"); /*从文件读入一个采样声音, 返回它的指针*/
if (!Wheee) {
printf("Error reading WAV file\n");
END=1;
}
eat_sound = load_sample("sound/eat.wav"); /*从文件读入一个采样声音, 返回它的指针*/
if (!eat_sound) {
printf("Error reading WAV file\n");
END=1;
}
start_sound = load_sample("sound/start_sound.wav"); /*从文件读入一个采样声音, 返回它的指针*/
if (!start_sound) {
printf("Error reading WAV file\n");
END=1;
}
start_music = load_sample("sound/start_music.wav"); /*从文件读入一个采样声音, 返回它的指针*/
if (!start_music) {
printf("Error reading WAV file\n");
END=1;
}
unit_ready = load_sample("sound/unit_ready.wav"); /*从文件读入一个采样声音, 返回它的指针*/
if (!unit_ready) {
printf("Error reading WAV file\n");
END=1;
}
unit_lost = load_sample("sound/unit_lost.wav"); /*从文件读入一个采样声音, 返回它的指针*/
if (!unit_lost) {
printf("Error reading WAV file\n");
END=1;
}
gameover_sound = load_sample("sound/gameover.wav"); /*从文件读入一个采样声音, 返回它的指针*/
if (!gameover_sound) {
printf("Error reading WAV file\n");
END=1;
}
yes_sir_sound = load_sample("sound/yessir.wav"); /*从文件读入一个采样声音, 返回它的指针*/
if (!yes_sir_sound) {
printf("Error reading WAV file\n");
END=1;
}
ok_sound = load_sample("sound/ok.wav"); /*从文件读入一个采样声音, 返回它的指针*/
if (!ok_sound) {
printf("Error reading WAV file\n");
END=1;
}
yeah_sound = load_sample("sound/yeah.wav"); /*从文件读入一个采样声音, 返回它的指针*/
if (!yeah_sound) {
printf("Error reading WAV file\n");
END=1;
}
move_out_sound = load_sample("sound/move_out.wav"); /*从文件读入一个采样声音, 返回它的指针*/
if (!move_out_sound) {
printf("Error reading WAV file\n");
END=1;
}
roger_sound = load_sample("sound/roger.wav"); /*从文件读入一个采样声音, 返回它的指针*/
if (!roger_sound) {
printf("Error reading WAV file\n");
END=1;
}
reinfor_sound = load_sample("sound/reinfor.wav"); /*从文件读入一个采样声音, 返回它的指针*/
if (!reinfor_sound) {
printf("Error reading WAV file\n");
END=1;
}
alert01_sound = load_sample("sound/alert01.wav"); /*从文件读入一个采样声音, 返回它的指针*/
if (!alert01_sound) {
printf("Error reading WAV file\n");
END=1;
}
alert02_sound = load_sample("sound/alert02.wav"); /*从文件读入一个采样声音, 返回它的指针*/
if (!alert02_sound) {
printf("Error reading WAV file\n");
END=1;
}
bomb_attack_sound = load_sample("sound/bomb_attack_sound.wav"); /*从文件读入一个采样声音, 返回它的指针*/
if (!bomb_attack_sound) {
printf("Error reading WAV file\n");
END=1;
}
win_sound = load_sample("sound/win_sound.wav"); /*从文件读入一个采样声音, 返回它的指针*/
if (!win_sound) {
printf("Error reading WAV file\n");
END=1;
}
failed_sound = load_sample("sound/failed_sound.wav"); /*从文件读入一个采样声音, 返回它的指针*/
if (!failed_sound) {
printf("Error reading WAV file\n");
END=1;
}
win_sound2 = load_sample("sound/win_sound2.wav"); /*从文件读入一个采样声音, 返回它的指针*/
if (!win_sound2) {
printf("Error reading WAV file\n");
END=1;
}
failed_sound2 = load_sample("sound/failed_sound2.wav"); /*从文件读入一个采样声音, 返回它的指针*/
if (!failed_sound2) {
printf("Error reading WAV file\n");
END=1;
}
yes_sir_sound_02 = load_sample("sound/yessir2.wav"); /*从文件读入一个采样声音, 返回它的指针*/
if (!yes_sir_sound_02) {
printf("Error reading WAV file\n");
END=1;
}
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
/*爆炸贴图初始化 常数*/
/*120mm*/
BAO_BMP[1].BAO_fram_time=3; /*每帧的时间*/
BAO_BMP[1].BAO_MAX_fram=9; /*最大帧数*/
BAO_BMP[1].BMP_X=45; /*每帧的图象大小*/
BAO_BMP[1].BMP_Y=33;
/*30mm*/
BAO_BMP[2].BAO_fram_time=3; /*每帧的时间*/
BAO_BMP[2].BAO_MAX_fram=7; /*最大帧数*/
BAO_BMP[2].BMP_X=32; /*每帧的图象大小*/
BAO_BMP[2].BMP_Y=32;
/*机枪*/
BAO_BMP[3].BAO_fram_time=2; /*每帧的时间*/
BAO_BMP[3].BAO_MAX_fram=8; /*最大帧数*/
BAO_BMP[3].BMP_X=15; /*每帧的图象大小*/
BAO_BMP[3].BMP_Y=15;
/*死亡大炸弹*/
BAO_BMP[4].BAO_fram_time=4; /*每帧的时间*/
BAO_BMP[4].BAO_MAX_fram=6; /*最大帧数*/
BAO_BMP[4].BMP_X=36; /*每帧的图象大小*/
BAO_BMP[4].BMP_Y=33;
/*地狱火*/
BAO_BMP[5].BAO_fram_time=4; /*每帧的时间*/
BAO_BMP[5].BAO_MAX_fram=10; /*最大帧数*/
BAO_BMP[5].BMP_X=72; /*每帧的图象大小*/
BAO_BMP[5].BMP_Y=72;
/*原子弹*/
BAO_BMP[6].BAO_fram_time=4; /*每帧的时间*/
BAO_BMP[6].BAO_MAX_fram=26; /*最大帧数*/
BAO_BMP[6].BMP_X=152; /*每帧的图象大小*/
BAO_BMP[6].BMP_Y=158;
/*信号弹*/
BAO_BMP[7].BAO_fram_time=17; /*每帧的时间*/
BAO_BMP[7].BAO_MAX_fram=28; /*最大帧数*/
BAO_BMP[7].BMP_X=42; /*每帧的图象大小*/
BAO_BMP[7].BMP_Y=31;
/*++++++++++++++++++++ GAME 开始 ++++++++++++++++++++++++++++*/
START:;
/*+++++++++++++++++++++初始化子弹++++++++++++++++++++++++++++*/
for(n=0;n<BB_max_num;n++) /*玩家子弹初始化*/
{
BB[n].RUN=0;
BB[n].weapon_number=-1;
BB[n].Speed=0;
BB[n].Warhead_number=-1;
BB[n].NPC_number=-1;
}
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
for(n=0;n<BAO_max_num;n++) /*爆炸初始化*/
{
BAO[n].LIVE=0;
BAO[n].x=0;
BAO[n].y=0;
BAO[n].nonce_fram=1;
BAO[n].fram_time=0;
BAO[n].weapon_number=0; /*武器编号*/
}
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
/*光标初始化*/
GUANG_BIAO.LIVE=0;
GUANG_BIAO.x=0; /*当前坐标X*/
GUANG_BIAO.y=0; /*当前坐标Y*/
GUANG_BIAO.nonce_fram=1; /*当前帧号*/
GUANG_BIAO.fram_MAX_time=5;
GUANG_BIAO.fram_time=GUANG_BIAO.fram_MAX_time; /*每帧记时*/
GUANG_BIAO.MAX_fram=3; /*最大帧数*/
GUANG_BIAO.number=1; /*图片编号*/
GUANG_BIAO.BMP_X=33; /*单位图片大小*/
GUANG_BIAO.BMP_Y=33;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -