📄 tank041.c
字号:
}
}
/*第一视角*/
if(key[KEY_F1])
{
display_mode=1;
}
/*鼠标视角*/
if(key[KEY_F2])
{
display_mode=2;
}
/*自由相机视角*/
if(key[KEY_F3])
{
display_mode=3;
}
if(key[KEY_F5]){
display_math_player=1;
}
if(key[KEY_F6]){
display_math_player=0;
}
if(key[KEY_F7]){
display_LEI_DA=1;
}
if(key[KEY_F8]){
display_LEI_DA=0;
}
if(key[KEY_F12]) {
save_bitmap("000.bmp", buffer, pallete); /*拷贝屏幕*/
}
/*开火射击*/
if(key[KEY_SPACE]){
PLAYER[0].fire=1;
}
if(key[KEY_X])
{
display_NPC_HP=1;
}
if(key[KEY_Z])
{
display_NPC_HP=0;
}
if(key[KEY_1])
{
PLAYER[0].weapon_number=1; /*武器 120mm坦克炮*/
}
if(key[KEY_2])
{
PLAYER[0].weapon_number=2; /*武器 30mm机关炮*/
}
if(key[KEY_3])
{
PLAYER[0].weapon_number=3; /*武器 12.7mm机枪*/
}
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
/*检测 NPC 1 死亡没有 核设施*/
if( PLAYER[1].LIVE==0 )
{
WAIT_GAME_EXIT=1; WIN=0;
}
/*--------------------------------------------------*/
if(WAIT_GAME_EXIT!=1)
{
/*复活玩家0*/
if(PLAYER_RISE==1&&PLAYER[0].LIVE==0)
{
PLAYER[0].LIVE=1;
INIT_PLAYER_ID(0,1); /*初始化ID 单位属性*/
PLAYER[0].MAP_A=Xrand(1,MAP_A_MAX-2); /*随机产生MAP坐标*/
PLAYER[0].MAP_B=Xrand(1,MAP_B_MAX-2);
PLAYER[0].kind=1;
INIT_PLAYER(0); /*初始化其他属性*/
PLAYER_RISE=0;
PLAYER_RISE_TIME=5;
for(i=1;i< NPC_max_num ;i++) /*检测是否和其他的NPC重叠*/
{
if(PLAYER[0].MAP_A==PLAYER[i].MAP_A && PLAYER[0].MAP_B==PLAYER[i].MAP_B)
{
PLAYER[0].LIVE=0; /*重新准备复活*/
PLAYER_RISE=1;
PLAYER_RISE_TIME=0;
break;
}
}
if(PLAYER[0].LIVE==1)
{
adage_N=0; /*停止显示格言*/
play_sample(unit_ready, 255, pan, pitch, FALSE); /*声音 有新人员了*/
}
}
/*--------------------------------------------------*/
/*复活敌人*/
if(ENEMY_RISE==1 && V==0 && ENEMY_N < ENEMY_SUM)
{
for(n=2;n<NPC_max_num;n++) /*初始化玩家 敌人NPC*/
{
if(PLAYER[n].LIVE==0)
{
PLAYER[n].LIVE=1;
i=Xrand(2,4); /*2~4 都是 敌人的ID*/
INIT_PLAYER_ID(n,i); /*初始化ID 单位属性*/
RAND_NPC_AB(n); /*随机得出NPC的AB 屏幕边缘*/
PLAYER[n].kind=2; /*设置为 敌方*/
INIT_PLAYER(n); /*初始化其他属性*/
ENEMY_RISE=0;
ENEMY_RISE_TIME=5;
for(i=0;i< NPC_max_num ;i++) /*检测是否和其他的NPC重叠*/
{
if(n==i) continue;
if(PLAYER[n].MAP_A==PLAYER[i].MAP_A && PLAYER[n].MAP_B==PLAYER[i].MAP_B)
{
PLAYER[n].LIVE=0;
ENEMY_RISE=1;
ENEMY_RISE_TIME=0;
break;
}
}
if(PLAYER[n].LIVE==1) ENEMY_N++;
break;
}
}
}
/*--------------------------------------------------*/
/*信号弹出现后 复活友军*/
if(FRIEND_RISE==1 && V==1 && FRIEND_N < FRIEND_SUM)
{
for(n=2;n<NPC_max_num;n++) /*初始化玩家 NPC*/
{
if(PLAYER[n].LIVE==0)
{
PLAYER[n].LIVE=1;
INIT_PLAYER_ID(n,1); /*初始化ID 单位属性 坦克1*/
RAND_NPC_AB(n); /*随机得出NPC的AB 屏幕边缘*/
PLAYER[n].kind=1; /*设置为 友军*/
INIT_PLAYER(n); /*初始化其他属性*/
FRIEND_RISE=0;
FRIEND_RISE_TIME=5;
for(i=0;i< NPC_max_num ;i++) /*检测是否和其他的NPC重叠*/
{
if(n==i) continue;
if(PLAYER[n].MAP_A==PLAYER[i].MAP_A && PLAYER[n].MAP_B==PLAYER[i].MAP_B)
{
PLAYER[n].LIVE=0;
FRIEND_RISE=1;
FRIEND_RISE_TIME=0;
break;
}
}
if(PLAYER[n].LIVE==1) FRIEND_N++;
break;
}
}
}
/*---------------------------*/
} /*if(WAIT_GAME_EXIT!=1)*/
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
/*++++++++++++++++++++++对玩家的事件处理+++++++++++++++++++++++++++*/
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
for(n=0;n<NPC_max_num;n++)
{
if(PLAYER[n].LIVE==0) /*玩家不存在*/
{
;
}
/*###########################################*/
if(PLAYER[n].LIVE==1) /*玩家存在*/
{
if(PLAYER[n].HP<=0) /*生命值为0 死亡*/
{
PLAYER[n].LIVE=0;
/*激活自爆*/
if(PLAYER[n].ID<10)
{
PLAYER[n].weapon_number=4; /*武器 死亡大炸弹*/
}
else if (PLAYER[n].ID==10 )
{
PLAYER[n].weapon_number=6; /*武器 原子弹*/
}
PLAYER[n].player_XROF=0; /*待发时间为0*/
PLAYER[n].opx=PLAYER[n].X1; /*瞄准自己*/
PLAYER[n].opy=PLAYER[n].Y1;
PLAYER[n].fire=1; /*开火*/
if(n==0)
{
adage_N=Xrand(1,20); /*当玩家死亡的时候 随机产生格言编号*/
if(A_BOMB_LIVE!=1) /*防止听不见原子弹爆炸声*/
play_sample(unit_lost, 255, pan, pitch, FALSE); /*女声 人员死亡*/
PLAYER_DEAD++;/*玩家死亡次数*/
}
if(PLAYER[n].kind==2) ENEMY_N--;
/*if(PLAYER[n].kind==1 && n!=0) FRIEND_N--; 友军不继续复活*/
}
/*------------------------*/
/*建筑物根据毁伤程度改变贴图角度*/
if(PLAYER[n].ID>=10)
{
if(PLAYER[n].HP==0) jj=0; /*防止除数为0*/
else
{
ii=PLAYER[n].MAX_HP/PLAYER[n].HP ; /*换算100 float */
jj=100 / ii;
}
if(jj<=80 && jj>=35) PLAYER[n].angle[0]=33;
else if(jj<=34 && jj>=0) PLAYER[n].angle[0]=56;
}
/*------------------------*/
/*让NPC随机动起来*/
if(n!=0 && PLAYER[n].ID<10) /*不是玩家 和 建筑物*/
{
if(PLAYER[n].whether_have_whither==0)
{
PLAYER[n].whither_x=MAP_X0 + ( Xrand(4,MAP_B_MAX-4) * 32 ) + 15; /*目的地x 随机产生MAP坐标*/
PLAYER[n].whither_y=MAP_Y0 + ( Xrand(4,MAP_A_MAX-4) * 32 ) + 15; /*目的地y*/
PLAYER[n].o_angle[0]=ASK_a(PLAYER[n].X1,PLAYER[n].Y1,PLAYER[n].whither_x,PLAYER[n].whither_y);
PLAYER[n].o_angle[1]=ASK_a(PLAYER[n].X1,PLAYER[n].Y1,PLAYER[n].whither_x,PLAYER[n].whither_y);
PLAYER[n].whether_have_whither=1; /*是否有目的地*/
}
}
/*------------------------*/
if(PLAYER[n].whether_have_whither == 1) /*有目的地*/
{
PLAYER[n].forward=1; /*前进*/
PLAYER[n].move=1;
/*接近目的地*/
if(DZ(PLAYER[n].X1,PLAYER[n].Y1,PLAYER[n].whither_x,PLAYER[n].whither_y)<= 10)
{PLAYER[n].whether_have_whither=0; PLAYER[n].move=0;}
}
/*------------------------*/
/*NPC的视觉判断*/
if(n!=0 && PLAYER[n].ID<10)
{
cc=0;
for(pp=0;pp< NPC_max_num ;pp++)
{
if(n==pp) continue;
else
{
if(PLAYER[n].kind!=PLAYER[pp].kind) /*种类不同*/
{
if(NPC_CAN_SEE(n,pp)==1)
{
if(PLAYER[n].Alert==0) { PLAYER[n].Alert=1; PLAYER[n].A_TIME=50; }
PLAYER[n].o_angle[1]=ASK_a(PLAYER[n].X1,PLAYER[n].Y1,PLAYER[pp].X1,PLAYER[pp].Y1); /*改变角度*/
if(PLAYER[n].HP>= PLAYER[n].MAX_HP / 2 )PLAYER[n].move=0; /*NPC有一半的血就停止移动 攻击对方 */
cc++;
break;
}
else /*没看见*/
{
if(PLAYER[n].A_TIME==0 && PLAYER[n].Alert==0 ) /*防止移动到视野外,炮台还是对着原处 补丁*/
{
PLAYER[n].o_angle[1]=ASK_a(PLAYER[n].X1,PLAYER[n].Y1,PLAYER[n].whither_x,PLAYER[n].whither_y);
PLAYER[n].A_TIME=50;
}
}
}
}
}
if(cc==0) PLAYER[n].Alert=0; /*cc是个补丁 防止开火不停止*/
}
/*------------------------*/
if(PLAYER[n].ID<10)
{
/*本身角度变化*/
if(PLAYER[n].o_angle[0]!=PLAYER[n].angle[0]) /*目标角!=当前角*/
{
Xa(&PLAYER[n].angle[0],&PLAYER[n].o_angle[0],PLAYER[n].X_SPEED); /*改变角度*/
PLAYER[n].move=0;
}
/*炮塔角度变化*/
if(PLAYER[n].o_angle[1]!=PLAYER[n].angle[1]) /*目标角!=当前角*/
{
Xa(&PLAYER[n].angle[1],&PLAYER[n].o_angle[1],PLAYER[n].X_SPEED); /*改变角度*/
}
}
/*------------------------*/
/*------------------------*/
if( PLAYER[n].move==1 )
{
/*------------------------*/
if(PLAYER[n].forward==1) /*前进*/
{
MOVE_TO3(PLAYER[n].angle[0],&PLAYER[n].X1,&PLAYER[n].Y1,PLAYER[n].Speed);
PLAYER[n].forward=0;
}
/*------------------------*/
if(PLAYER[n].backward==1) /*后退*/
{
i=PLAYER[n].angle[0]-180;
if(i==0) i=360; /*i临时的 使角度不为180-180=0*/
MOVE_TO3(i,&PLAYER[n].X1,&PLAYER[n].Y1,PLAYER[n].Speed);
PLAYER[n].backward=0;
}
PLAYER[n].MAP_A=ASK_MAP_AB(PLAYER[n].X1,PLAYER[n].Y1,MAP_X0,MAP_Y0,32,2); /*得到新的MAP的位置*/
PLAYER[n].MAP
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -