level 5
芝芝751
楼主
帮我看看这个程序里都设计到C的什么知识,说重要的,大概给我说说,我在下边学习。多谢谢谢谢谢谢谢谢谢谢谢谢谢谢。#include
#include
#include
#include
#include
#define ESC27
#define BLACK0#
define HEIZHUAN1
#define BAIZHUAN2#
define TREE13
#define TREE24#
define TREE35
#define TREE46#
define BASE7
#define PLAYERSHOT1#
define NPCSHOT0
#define NPC10#
define NPC21
#define NPC32#
define PLAYER3
#define VIABLE1#
define NOVIABLE0
#define Y0#
define X1char MapData[72][84];char MapState[72][84];int *Base;int *Tank[4][4][2];int *Image[7];int *Shot[4];int *BirBg;int Direction[4][2]={-1,0,0,1,1,0,0,-1};int PosFirst[6][2]={1,1,1,41,1,81,70,36,70,40,70,46};int NextBg[4][3][2]={-2,-1,-2,0,-2,1,-1,2,0,2,1,2,2,1,2,0,2,-1,1,-2,0,-2,-1,-2};int TankBg[4][3][2]={1,-1,1,0,1,1,-1,-1,0,-1,1,-1,-1,-1,-1,0,-1,1,-1,1,0,1,1,1};int hei[4][2][2]={0,-1,0,1,-1,0,1,0,0,1,0,-1,1,0,-1,0};struct tank{ int d,hp,attack,define,i,si,interval,ShotInterval,type,CenterY,CenterX,now,ShotSpeed; struct tank *link;};typedef struct tank *PTANK;struct shot{ int y,x,d,attack,interval,type,i; struct shot *link;};typedef struct shot *PSHOT;PTANK NpcHead,PlayerHead;PSHOT NpcShotHead,PlayerShotHead;int *NpcBir,*PlayerBir,BNpcI,BPlayerI,BNpcY,BNpcX,BPlayerY,BPlayerX,BType,BNpcIntval,BPlayerIntval;int NowNpc=0,NowMaxNpc=6,SumNpc=30,SumNpcDead=0,chance=4,GameOver=0;int MaxNpcShot=6,NowNpcShot=0,MaxPlayerShot=4,NowPlayerShot=0;char CH='-1',str[6];FILE *fname,*fdata;void PPutImage(int *p,int l,int t,int r,int b);int *GGetImage(int l,int t,int r,int b);void DrawRetangle(int l,int t,int r,int b,int color);void ChuLiNpc(void);void ChuLiPlayer(void);void ChuLiNpcShot(void);void ChuLiPlayerShot(void);void ChuLiNpcBirth(void);void ChuLiPlayerBirth(void);void PutMap(void);void LoadMap(void);void LoadData(void);void ConstructNpc(int type);void ConstructPlayer(void);void ConstructNpcShot(PTANK p);void ConstructPlayerShot(PTANK p);int NpcBirth(void);void PlayerBirth(void);void AtiveGameOver(void);void init(void);void DrawRetangle(int l,int t,int r,int b,int color){ int x,y; for(y=t;y<=b;y++){ for(x=l;x<=r;x++){ putpixel(x,y,color); } }}int main(){int gm=DETECT,gd,i,y,x,*p,type,d,n;if((fname=fopen("name","r"))==NULL){printf("cannot open map file!\n");getch();exit(0);}printf("open map file success!\n");if((fdata=fopen("data","r"))==NULL){printf("cannot open data file!\n");getch();exit(0);}printf("open data file success!\n");getch();LoadData();initgraph(&gm,&gd,"");while(!GameOver) {LoadMap();init();PutMap();getch();while(!GameOver){ChuLiPlayerBirth();ChuLiNpcBirth();ChuLiPlayerShot();ChuLiNpcShot();ChuLiNpc();ChuLiPlayer();if(chance==0) GameOver=1;if(SumNpcDead==SumNpc) break;if(bioskey(1)) CH=bioskey(0);delay(2);}if(GameOver==1) {getch();break;}
2007年05月12日 08点05分
1
#include
#include
#include
#include
#define ESC27
#define BLACK0#
define HEIZHUAN1
#define BAIZHUAN2#
define TREE13
#define TREE24#
define TREE35
#define TREE46#
define BASE7
#define PLAYERSHOT1#
define NPCSHOT0
#define NPC10#
define NPC21
#define NPC32#
define PLAYER3
#define VIABLE1#
define NOVIABLE0
#define Y0#
define X1char MapData[72][84];char MapState[72][84];int *Base;int *Tank[4][4][2];int *Image[7];int *Shot[4];int *BirBg;int Direction[4][2]={-1,0,0,1,1,0,0,-1};int PosFirst[6][2]={1,1,1,41,1,81,70,36,70,40,70,46};int NextBg[4][3][2]={-2,-1,-2,0,-2,1,-1,2,0,2,1,2,2,1,2,0,2,-1,1,-2,0,-2,-1,-2};int TankBg[4][3][2]={1,-1,1,0,1,1,-1,-1,0,-1,1,-1,-1,-1,-1,0,-1,1,-1,1,0,1,1,1};int hei[4][2][2]={0,-1,0,1,-1,0,1,0,0,1,0,-1,1,0,-1,0};struct tank{ int d,hp,attack,define,i,si,interval,ShotInterval,type,CenterY,CenterX,now,ShotSpeed; struct tank *link;};typedef struct tank *PTANK;struct shot{ int y,x,d,attack,interval,type,i; struct shot *link;};typedef struct shot *PSHOT;PTANK NpcHead,PlayerHead;PSHOT NpcShotHead,PlayerShotHead;int *NpcBir,*PlayerBir,BNpcI,BPlayerI,BNpcY,BNpcX,BPlayerY,BPlayerX,BType,BNpcIntval,BPlayerIntval;int NowNpc=0,NowMaxNpc=6,SumNpc=30,SumNpcDead=0,chance=4,GameOver=0;int MaxNpcShot=6,NowNpcShot=0,MaxPlayerShot=4,NowPlayerShot=0;char CH='-1',str[6];FILE *fname,*fdata;void PPutImage(int *p,int l,int t,int r,int b);int *GGetImage(int l,int t,int r,int b);void DrawRetangle(int l,int t,int r,int b,int color);void ChuLiNpc(void);void ChuLiPlayer(void);void ChuLiNpcShot(void);void ChuLiPlayerShot(void);void ChuLiNpcBirth(void);void ChuLiPlayerBirth(void);void PutMap(void);void LoadMap(void);void LoadData(void);void ConstructNpc(int type);void ConstructPlayer(void);void ConstructNpcShot(PTANK p);void ConstructPlayerShot(PTANK p);int NpcBirth(void);void PlayerBirth(void);void AtiveGameOver(void);void init(void);void DrawRetangle(int l,int t,int r,int b,int color){ int x,y; for(y=t;y<=b;y++){ for(x=l;x<=r;x++){ putpixel(x,y,color); } }}int main(){int gm=DETECT,gd,i,y,x,*p,type,d,n;if((fname=fopen("name","r"))==NULL){printf("cannot open map file!\n");getch();exit(0);}printf("open map file success!\n");if((fdata=fopen("data","r"))==NULL){printf("cannot open data file!\n");getch();exit(0);}printf("open data file success!\n");getch();LoadData();initgraph(&gm,&gd,"");while(!GameOver) {LoadMap();init();PutMap();getch();while(!GameOver){ChuLiPlayerBirth();ChuLiNpcBirth();ChuLiPlayerShot();ChuLiNpcShot();ChuLiNpc();ChuLiPlayer();if(chance==0) GameOver=1;if(SumNpcDead==SumNpc) break;if(bioskey(1)) CH=bioskey(0);delay(2);}if(GameOver==1) {getch();break;}