飞机大战2.zip

  • during000
    了解作者
  • C/C++
    开发工具
  • 766KB
    文件大小
  • zip
    文件格式
  • 0
    收藏次数
  • 1 积分
    下载积分
  • 2
    下载次数
  • 2021-02-21 15:47
    上传日期
基于EGE的飞机大战,有3个关卡,3种飞机,DEVc++上可以跑
飞机大战2.zip
  • 打飞机
  • 打飞机改进.cpp
    9KB
  • background.jpg
    15.4KB
  • 打飞机改进.exe
    2.4MB
  • planeboom.jpg
    3.7KB
  • sboss.jpg
    37.4KB
  • bullet.jpg
    761B
  • enemy.jpg
    32.3KB
  • bboss.jpg
    34.4KB
  • plane.jpg
    3KB
内容介绍
#include<bits/stdc++.h> #include<graphics.h> #include<windows.h> #include<conio.h> #define high 30 #define width 20 #define enemynumber 5 using namespace std; int score,k=0,flag=0,blood,bullet_x,bullet_y,position_x,position_y,enemymove,step=1,speed=10;//k为子弹数 int sbossblood,sboss_x,sboss_y,sbossflag1=0,sbossappearflag=0,sbossdieflag=0;//小boss int bbossblood,bboss_x,bboss_y,bbossflag=0;//大boss int canvas[width+2][high+2]={0};//0为空格,1为飞机,2为子弹,3为敌机 ,4为小boss,5为大boss PIMAGE background,enemyplane,plane,sboss,bboss,bullet,planeboom; struct enemy{ int x; int y; }enemy[enemynumber]; /*void gotoxy(int x,int y){//光标移动函数 HANDLE handle=GetStdHandle(STD_OUTPUT_HANDLE); COORD pos; pos.X = x; pos.Y = y; SetConsoleCursorPosition(handle,pos); } /*void hidecursor(){ CONSOLE_CURSOR_INFO cursor_info={1,0}; SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE),&cursor_info); } */ void startup(){//初始化 int i; position_x=width/2;//飞机位置 position_y=high/2; canvas[position_x][position_y]=1; for(i=0;i<=enemynumber-1;i++){ enemy[i].x=rand()%width;//敌机 enemy[i].y=rand()%2; canvas[enemy[i].x][enemy[i].y]=3; } score=0;blood=10; xyprintf(0,0,"wasd上左下右移动"); xyprintf(0,20,"空格发射子弹"); xyprintf(0,40,"按p可以暂停"); background=newimage(); enemyplane=newimage(); sboss=newimage(); bboss=newimage(); bullet=newimage(); plane=newimage(); planeboom=newimage(); getimage(background,"background.jpg"); getimage(enemyplane,"enemy.jpg"); getimage(sboss,"sboss.jpg"); getimage(bboss,"bboss.jpg"); getimage(bullet,"bullet.jpg"); getimage(plane,"plane.jpg"); getimage(planeboom,"planeboom.jpg"); putimage(0,60,plane);xyprintf(20,60,"你的飞机"); putimage(0,80,enemyplane);xyprintf(20,80,"普通敌机"); putimage(0,100,sboss);xyprintf(20,100,"小boss"); putimage(0,120,bboss);xyprintf(20,120,"大boss"); xyprintf(80,290,"请将输入法切换至英文小写"); xyprintf(140,315,"按任意键继续"); getch(); } void show(){//显示画面 int i,j; //system("cls"); putimage(0,0,background); //gotoxy(0,0); //hidecursor(); for(i=0;i<=width-1;i++){ for(j=0;j<=high-1;j++){ switch(canvas[i][j]){ case 0: break; case 1:putimage(i*20,j*20,plane); break; case 2:putimage(i*20,j*20,bullet); break; case 3:putimage(i*20,j*20,enemyplane); break; case 4:putimage(i*20,j*20,sboss); break; case 5:putimage(i*20,j*20,bboss); break; } } } xyprintf(5,605,"得分:%d 血量:%d",score,blood); Sleep(20); } void sbossappear(){ sbossblood=5; sboss_x=rand()%(width-1); sboss_y=0; canvas[sboss_x][sboss_y]=4; } void bbossappear(){ bbossblood=10; bboss_x=rand()%(width-1); bboss_y=0; bbossflag=1; canvas[bboss_x][bboss_y]=5; } void sbossmove(){ int ff,yy,i; canvas[sboss_x][sboss_y]=0; ff=rand()%3; switch(ff){ case 0:sboss_y++; break; case 1:sboss_y++; sboss_x--; break; case 2:sboss_y++; sboss_x++; break; } if(sboss_x==-1)sboss_x++; if(sboss_x==width)sboss_x--; for(i=0;i<enemynumber;i++){ if(canvas[sboss_x][sboss_y]==2){ if(sboss_x>0&&canvas[sboss_x-1][sboss_y]!=2){ sboss_x--; }else if(sboss_x<width&&canvas[sboss_x+1][sboss_y]!=2){ sboss_x++; }else if(sboss_y>0&&canvas[sboss_x][sboss_y-1]!=2){ sboss_y--; }else{ sboss_y++; } } } if(sboss_y==high){ sboss_y=0; } canvas[sboss_x][sboss_y]=4; } void bbossmove(){ int ff,yy,i; canvas[bboss_x][bboss_y]=0; ff=rand()%3; switch(ff){ case 0:bboss_y++; break; case 1:bboss_y++; bboss_x--; break; case 2:bboss_y++; bboss_x++; break; } if(bboss_x==-1)bboss_x++; if(bboss_x==width)bboss_x--; for(i=0;i<enemynumber;i++){ if(canvas[bboss_x][bboss_y]==2){ if(bboss_x>0&&canvas[bboss_x-1][bboss_y]!=2){ bboss_x--; }else if(bboss_x<width&&canvas[bboss_x+1][bboss_y]!=2){ bboss_x++; }else if(bboss_y>0&&canvas[bboss_x][bboss_y-1]!=2){ bboss_y--; }else{ bboss_y++; } } } if(bboss_y==high){ bboss_y=0; } canvas[bboss_x][bboss_y]=5; } void updateWithoutInput(){//与用户输入无关更新 int i,j,k,bulletflag=0,l,xx,yy,ff,kk,ii; for(i=0;i<=width-1;i++){ for(j=0;j<=high-1;j++){ if(canvas[i][j]==2){ for(k=0;k<enemynumber;k++){ if((i==enemy[k].x)&&(j==enemy[k].y)){ score++; if(score>=20&&step==1){ step++; xyprintf(170,315,"第2关"); getch(); }else if(score>=40&&step==2){ step++; xyprintf(170,315,"第3关"); getch(); } //下一关 canvas[enemy[k].x][enemy[k].y]=0; do{ kk=1; enemy[k].x=rand()%width; enemy[k].y=rand()%2; for(ii=0;ii<enemynumber;ii++){ if(enemy[ii].x==enemy[k].x&&(enemy[ii].y==enemy[k].y||enemy[ii].y+1==enemy[k].y)&&ii!=k){ kk=0; } } }while(kk==0); bulletflag=1; canvas[i][j]=0; } } if((i==sboss_x)&&(j==sboss_y)){ sbossblood--; bulletflag=1; canvas[i][j]=4; if(sbossblood==0){ score=score+3; canvas[i][j]=0; sbossflag1=0; if(score>=35&&sbossappearflag==1){ sbossdieflag=1; } if(score>=20&&step==1){ step++; xyprintf(170,315,"第2关"); getch(); }else if(score>=40&&step==2){ step++; xyprintf(170,315,"第3关"); getch(); } //下一关 } } if((i==bboss_x)&&(j==bboss_y)){ bbossblood--; bulletflag=1; canvas[i][j]=5; if(bbossblood==0){ score=score+5; canvas[i][j]=0; bbossflag=0; flag=1; } } if(j>0&&bulletflag==0){ canvas[i][j-1]=2; }else if(bulletflag==1){ bulletflag=0; } canvas[i][j]=0; } } } if(step==3&&bbossflag==0&&sbossdieflag==1&&sbossflag1==0){ bbossappear(); bbossflag=1; } if(score==25&&sbossflag1==0){//小boss sbossappear(); sbossflag1=1; }else if(score>=35&&sbossflag1==0&&sbossappearflag==0&&bbossflag==0){ sbossappear(); sbossappearflag=1; } if(speed<10){ speed++; } if(speed==10){ for(i=0;i<enemynumber;i++){ canvas[enemy[i].x][enemy[i].y]=0; if(enemy[i].y==high){ enemy[i].y=0; } enemy[i].y++;//敌机下移 canvas[enemy[i].x][enemy[i].y]=3; } if(sbossflag1==1||(sbossappearflag==1&&sbossdieflag==0)){ sbossmove(); } if(bbossflag==1){ bbossmove(); } speed=0; } for(i=0;i<enemynumber;i++){ if((enemy[i].x==position_x)&&(enemy[i].y==position_y)){ blood--; canvas[position_x][position_y]=1; enemy[i].x=rand()%width; enemy[i].y=rand()%2; } } if((position_x==sboss_x)&&(position_y==sboss_y)){ blood=blood-2; position_x=position_x+2; if(position_x>=width){ position_x-=4; } canvas[position_x][position_y]=1; } if((position_x==bboss_x)&&(position_y==bboss_y)){ blood=blood-3; position_x=position_x+2; if(position_x>=width){ position_x-=4; } canvas[position_x][position_y]=1; } } void updateWithInput(){//与用户输入有关更新 char input; if(kbhit()){ input=getch(); if(input=='a'&&position_x>0){ canvas[position_x][position_y]=0; position_x--; canvas[position_x][position_y]=1; }else if(input=='d'&&position_x<width-1){ canvas[position_x][position_y]=0; position_x++; canvas[position_x][position_y]=1; }else if(in
评论
    相关推荐
    • 飞机大战.rar
      飞机大战用python编写出来的,简单易操作,可以自行修改,dsvdsvds
    • 飞机大战easyX.zip
      基于easyX飞机大战的教程视频,素材及源代码
    • 飞机大战.zip
      基于EGE的飞机大战,有背景音乐,有3个关卡
    • 飞机大战.rar
      飞机大战,一块python开发的软件,源码都在里面,可以尝试玩玩
    • 飞机大战.rar
      一个类似于飞机大战的小游戏,仅供参考。啦啦啦啦啦啦啦
    • 飞机大战.zip
      最基本的飞机大战python代码,适合初学者
    • 飞机大战游戏.zip
      一个小游戏代码,基于html编写的小程序,主要适合初学者学习并且进行练习
    • 飞机大战.zip
      建立一个飞机大战的小游戏,内部包含了所有的源代码,仅供大家参考,需要了解相关方面的可以对我进行咨询,相互探讨
    • 飞机大战.zip
      这款小游戏相信许多朋友早就已经玩过,但这个游戏是如何编写的呢,本文为大家介绍一下用Java如何编写飞机大战游戏,仅供参考。
    • snowglobe-src-viewer-2.0.0-r0.tar.gz
      国外的开源游戏引擎,能够承载上千人,属于社交类的游戏