芝芝751 芝芝751
http://ole.photo.qq.com/?file=0AD70E06DA5BB0D40B4659EAE25EA853C2F18270CF744E91F84E75058A8A2424
关注数: 0 粉丝数: 5 发帖数: 902 关注贴吧数: 17
谁能给我说说C语言有硬件相关(嵌入)附带我写的游戏 需要学什么知识?以下的不是最后的版本。有空在发改进的吧。。#include #include #include #define NULL 0#define LEO sizeof(struct car)struct car{int speed,x1,x2,y1,y2;int *a;struct car *next;};char str1[30],str2[30],str3[30];int score=0,pass=0;int l=60,t=180,r=70,d=190;int ax[]={2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2};int a0[]={1,1,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,3,3,3,3,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1};int a1[]={1,1,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,3,3,3,3,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1};int a2[]={1,1,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,3,3,3,3,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1};int a3[]={1,1,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,3,3,3,3,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1};void main(){/*errorcode=graphresult();if(errorcode!=grok) { printf("Grapherrormsg(errorcode)"); printf("press any key to halt:"); getch(); exit(1); }*/struct car *great(int a[]);struct car *newcarfun(int a[],int speed, int m,int n,int zb);struct car *insert(struct car *head,struct car *newcar);void PPutImage(int *a,int l,int t,int r,int d);void print(struct car *head,int a[]);void map();void score1();int tag(struct car *head, int t,int l,int r,int d );struct car *del_car(struct car *head,int num);int i, h;char key;struct car *head ,*newpoint;int driver=CGA,mode=CGAC0;initgraph(&driver,&mode,""); map(); head=great(a1); PPutImage(a0,l,t,r,d); print(head,ax); for(i=0;;i++) { PPutImage(ax,l,t,r,d); if(bioskey(1)) { key=bioskey(0); switch(key){ case 'a': l+=-1;r+=-1;break; case 'd': l+=1;r+=1;break; case 'w': t+=-1;d+=-1;break; case 's': t+=1;d+=1;break; case 'e' : exit (0); default: ; } }if(i%29==0) { newpoint=newcarfun(a1,1,10,10,70); head=insert(head,newpoint);outtextxy(250,50,str3);outtextxy(250,110,str3); score1(); }if(i%37==0) { newpoint=newcarfun(a2,3,10,10,130); head=insert(head,newpoint);outtextxy(250,50,str3);outtextxy(250,110,str3); score1(); }if(i%13==0) { newpoint=newcarfun(a3,5,10,10,180); head=insert(head,newpoint);outtextxy(250,50,str3);
高手进 帮我看看这个程序里都设计到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;}
1 下一页