摘要:飞机战争是一款经典的飞行射击游戏,为玩家提供了不同的射击体验。 易于触摸屏控制,按并握住触摸屏,向左和向右移动以自动攻击敌人,上下移动以避免强大的敌人。 游戏中必须做的所有玩家都是驱动最新的战斗机并对敌人发动攻击。
飞机战争是一款经典的飞行射击游戏,为玩家提供了不同的射击体验。 易于触摸屏控制,按并握住触摸屏,向左和向右移动以自动攻击敌人,上下移动以避免强大的敌人。 游戏中必须做的所有玩家都是驱动最新的战斗机并对敌人发动攻击。
Today, I'm using C++ to complete the popular mini-program, the Aircraft Wars mini-game, popular all over the world ~ PS: Easyx Graphics Library #include
Development Tools VS2013
All the code is a bit difficult to see, so I cut most of the main code.主要目的是确保每个人都了解实施该项目的逻辑思想。我希望您能理解,本文底部的完整代码/编译器/图形库位于主电影开始的文章底部。主电影开始:步骤1:Open VS2013,创建一个项目,并将准备好的材料资源放在同一级别的目录中(可以在文章的底部收集),如图所示。
Step 2: Write the basic framework, look at the pixels of the background image, create a graphic window with the same pixels, add the next image,
Step 3: Set up music, player, player, enemy castration #include #include //#pragma注释(lib,“ winmm.lib”)//加载多媒体设备库#define win_width 591 #define win_height 864 img_bullet [2];图像img_enemy [2];结构平面{int x; int y;布尔国旗; // .. DEAD INT宽度; int height;} player,pbull [player_bullet],敌人[敌人plane_num]; intgraph(win_width,win_height); //随机数种子Srand(getTickCount()); // 2,帖子背景图像// 2.1 bk loadImage(&bk,“ ./images/background.jpg”); loadImage(&ymg_player [0],” ./images/planeboom_1.jpg");loadimage(&img_player [1],“ ./images/planeboom_1.jpg”); loadImage(&img_player [2],“ ./images/planeboom_1.jpg)”。 /images/planeboom_2.jpg"); loadimage(&img_bullet [0],“ ./images/bullet1.jpg”))loadImage(&img_bullet [1],“ ./images/bullet.jpg”); loadImage(&ymg_enemy [0],“ ./images/enemy_1.jpg”); loadImage(&yimmemy(&Immemy [)endages],“音乐首先打开音乐,然后是音乐mcisendstring(“ open ./images/game_music.mp3 alias bgm”,0,0,0,0); mcisendstring; mcisendstring; mcIsendstring(“ play bgm repote”,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0) i <player_bullet; = 52;//透明地图如果(player.flag){putimage(player.x,player.y和img_player [0],notrsrcirase); putimage(player.x,player.y和&img_player [1],srcInvert);}(pbull [i] .flag){putimage(pbull [i] .x,pbull [i] .y] .y。 contimage(pbull [i] .x,pbull [i] .y和img_bullet [1],srcinvert); Enemyplane_num; i ++){if(emeny [i] .flag){putimage(emeny [i] .y和img_enemy [0],notrsrcerase); contimage(i] .x,Emeny [i] .y&img_enemy [1],srcinvert); creatbullet(){for(int i = 0; i <player_bullet; i ++){if(! pbull [i] .y = player.y; pbull [i] .flag = true;}}}} emenyyplane_num; i ++){if(!emeny [i] .flag){emeny [i] .x = rand()%(win_width - emeny [i] .width);敌人[i] .y = 0;敌人[i] .flag = true;休息;}}}}} void enemymove(int speed){for(int i = 0; i win_height){处理if(getAsynckeyState(vk_up)&& move = 0(getAsynckeyState(vk_down)&& player.y+player.y+player.height = 0){player.x - = speed;} //正确移动if(getAsynckeynckeystate(vk_right)(vk_right)&& player.x+player.x+player.dhige.x+player.wun.width/22th/22th/22th/22th/22th/2200) “枪”,0,0,0);[i] .x = rand()%(win_width -敌人[i] .width);敌人[i] .y = 0;敌人[i] .flag = true;休息;}}} void enemymove(int speed){for(int i = 0; i <emenyyplane_num; i ++){if(emeny flag; y [i]。
// bulletmove(int speed){int i = 0; i = 0; if(getasynckeystate(vk_up) && player.y> = 0) {player.y - = speed;} // Go down if(getasynckeystate(vk_down) && player.y+height = 0) {player.x - = speed;} // player.x+player.width/2200) {mcisendstring( "Close Gun", 0, 0, 0); McIsendstring(“ Open/images/f_gun.mp3别名枪”,0,0,0); mcisendstring(“ play gun”,0,0,0,0); // bullet bulter creatbullet(); t1 = t2;} t2;} t2 = getTickcount(getTickcount() .flag)持续;
评论前必须登录!
注册