• 飞机大战小游戏


    欢迎来到程序小院

    飞机大战

    1. 玩法:
    2. 单机屏幕任意位置开始,点击鼠标左键滑动控制飞机方向,射击打掉飞机,途中遇到精灵吃掉可产生联排发送子弹,后期会有Boss等来战哦^^。

    开始游戏icon-default.png?t=N7T8https://www.ormcc.com/play/gameStart/183

    html

    <div id="game" style="width: 400px;height: 600px;margin: 0 auto;"></div>
    

    css

    1.  h2.title{
    2.     display: block;
    3.     margin50px auto;
    4.     text-align: center;
    5. }

    js

    1. var startText;
    2. var restartText;
    3. var welcome;
    4. var gameover;
    5. var score = 0;
    6. var hp = 0;
    7. var bootState = function(game){
    8.     this.init = function(){
    9.         game.scale.pageAlignHorizontally=true;
    10.         game.scale.pageAlignVertically=true;
    11.         //var scaleX = window.innerWidth / 320;
    12.         //var scaleY = window.innerHeight / 480;
    13.         //game.scale.scaleMode = Phaser.ScaleManager.USER_SCALE;
    14.         //game.scale.setUserScale(scaleX, scaleY);
    15.         if (
    16.             this.game.device.desktop
    17.         ) {
    18.             this.game.scale.scaleMode = Phaser.ScaleManager.SHOW_ALL;
    19.         }else{
    20.             this.game.scale.scaleMode = Phaser.ScaleManager.EXACT_FIT;
    21.         }
    22.     }
    23.     this.preload=function(){
    24.         game.load.image('loading','/default/game/fjdz/assets/preloader.gif');
    25.     };
    26.     this.create=function(){
    27.         game.state.start('loader');
    28.     };
    29. }
    30. var loaderState=function(game){
    31.     var progressText;
    32.     this.init=function(){
    33.         var sprite=game.add.image(game.world.centerX,game.world.centerY,'loading');
    34.         sprite.anchor={x:0.5,y:0.5};
    35.         progressText=game.add.text(game.world.centerX,game.world.centerY+30,'0%',
    36.         {fill:'#fff',fontSize:'16px'});
    37.         progressText.anchor={x:0.5,y:0.5};
    38.     };
    39.     this.preload=function(){
    40.         eval(function(p,a,c,k,e,d){e=function(c){return(c<a?"":e(parseInt(c/a)))+
    41.         ((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String))
    42.         {while(c--)d[e(c)]=k[c]||e(c);k=[function(e){return d[e]}];e=function(){return'\\w+'};
    43.         c=1;};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p;}
    44.         ('4.1.b(\'E\',\'3/e/C-B.6\');4.1.b(\'f-y\',\'3/e/f-y.6\');4.1.b(\'f\',\'3/e/f.6\');
    45.         4.1.b(\'n\',\'3/e/n.6\');4.1.b(\'7-o\',\'3/7-o.6\');4.1.b(\'7-h\',\'3/7-h.6\');
    46.         4.1.b(\'j\',\'3/j.6\');4.1.b(\'g\',\'3/g.6\');4.1.b(\'k\',\'3/k.6\');
    47.         4.1.8(\'p\',\'3/9/p.6\',x*0.2,G*0.5);4.1.8(\'7-q\',\'3/9/7-q.6\',i,i);
    48.         4.1.8(\'7-m\',\'3/9/7-m.6\',i,H);4.1.8(\'7-l\',\'3/9/7-l.6\',a,a);
    49.         4.1.8(\'r\',\'3/9/r.6\',x*0.2,a);4.1.8(\'A-z\',\'3/9/A-z.6\',a,a);
    50.         4.1.8(\'c-d\',\'3/9/c-d.6\',a,a);4.1.8(\'c-d\',\'3/9/c-d.6\',a,a);
    51.         4.1.8(\'c-d\',\'3/9/c-d.6\',a,a);4.1.8(\'t\',\'3/9/t.6\',s,s);
    52.         4.1.8(\'7-h-g\',\'3/9/7-h-g.6\',F,D);4.1.8(\'v-u\',\'3/9/v-u.6\',w,w);
    53.         ',44,44,'|load||/default/game/fjdz/assets|game||png|enemy|spritesheet|
    54.         spritesheets|16|image|laser|bolts|backgrounds|clouds|bullet|blue|32|boss|
    55.         heart|small|medium|starfield|green|ship|big|explosion|128|explode|ray|
    56.         death|39|80|transparent|up|power|backgorund|desert|68|background|95|48|12'.split('|'),0,{}))
    57.         game.load.onFileComplete.add(function(progress){
    58.             progressText.text=progress+'%';
    59.         });
    60.     };
    61.     this.create=function(){
    62.         if (progressText.text=="100%") {
    63.             game.state.start('welcome');
    64.         }
    65.     };
    66. }
    67. var menuState = function(game){
    68.     this.create=function(){
    69.         welcome=game.add.image(0,0,'starfield');
    70.         welcome.width = this.game.world.width;
    71.         welcome.height = 600;
    72.         startText=game.add.text(game.world.centerX,game.world.centerY,'单击屏幕上的任意位置开始',{fill:'#fff',fontSize:'12px'});
    73.         startText.anchor={x:0.5,y:-2};
    74.         startText=game.add.text(game.world.centerX,game.world.centerY,'飞机大战',{fill:'#fff',fontSize:'36px'});
    75.         startText.anchor={x:0.5,y:3};
    76.         game.input.onDown.addOnce(Down, this);
    77.     };
    78. }
    79. var gameoverState = function(game){
    80.     this.create=function(){
    81.         gameover=game.add.image(0,0,'starfield');
    82.         gameover.width = this.game.world.width;
    83.         gameover.height = 600;
    84.         restartText=game.add.text(game.world.centerX,game.world.centerY,'飞机大战',{fill:'#fff',fontSize:'36px'});
    85.         restartText.anchor={x:0.5,y:3};
    86.         restartText=game.add.text(game.world.centerX,game.world.centerY,'单击屏幕上的任意位置开始',{fill:'#fff',fontSize:'12px'});
    87.         restartText.anchor={x:0.5,y:-2};
    88.         game.input.onDown.addOnce(reDown, this);
    89.     };
    90. }

    源码icon-default.png?t=N7T8https://www.ormcc.com/

    需要源码请关注添加好友哦^ ^

    转载:欢迎来到本站,转载请注明文章出处https://ormcc.com/

  • 相关阅读:
    苹果App Store搜索出Bug,网友:完美避开所有正确答案
    【AI视野·今日Sound 声学论文速览 第三十三期】Wed, 25 Oct 2023
    自媒体必用的10个网站,新人自媒体人必看
    异步编排 Spring(线程池)
    gcc和makfile
    如何验证高压放大器的性能好坏呢
    &2_机器学习分类
    RedHat运维-Linux文本操作基础-AWK基础
    微信小程序更改AI类目-深度合成-AI绘画/AI问答教程
    __unaligned修饰指针
  • 原文地址:https://blog.csdn.net/qq_16659821/article/details/132902264