飞机大战-3

来源:互联网 发布:java thread getname 编辑:程序博客网 时间:2024/04/27 18:15

今天主要是敌方飞机的创建,下落;

  1. 前面已建飞机的父类call;


    1. //创建飞机父类
      > function commonPlane(hp,x,y,sizeX,sizeY,score,dietime,sudu,bombplane,srcImage){
      > this.hp=hp;//血量
      > this.planeX=x;
      > this.planeY=y;
      > this.planeSizex=sizeX;
      > this.planeSizey=sizeY
      > this.score=score;
      > this.dietime=dietime;
      > this.dietimes=0;//主要是飞机爆炸消失能看见过程,
      > this.planeisdie=false;//在后面有做判断,子弹与敌方飞机的判断函数里planeisdie=true;
      > this.bombplane=bombplane;//爆炸图片
      > this.planeSrcImage=srcImage;
      > this.sudu=sudu;//速度的变化用分数来决定;
      > this.init=function(){
      > this.oImg=document.createElement("img");
      > this.oImg.style.left=this.planeX+"px";
      > this.oImg.style.top=this.planeY+"px";
      > this.oImg.src=srcImage;
      > main.appendChild(this.oImg);
      > }
      > this.init();
      > this.moveEnemy=function(){
      > this.oImg.style.top=parseInt(this.oImg.style.top)+this.sudu+"px"
      > }
      > }

      2、 敌方飞机: function enemyPlane(hp,x,y,sizeX,sizeY,score,dietime,sudu,bombplane,srcImage){
      commonPlane.call(this,hp,random(x,y),-100,sizeX,sizeY,score,dietime,sudu,boomimage,imagesrc);
      }
  2. 敌方的飞机类型分为大中小,要随机下落;//飞机的随机下落,大中小飞机出现频率的下落,自己试吧!

    1. 这里涉及到随机数的产生;
      1. function random(min,max){
        return Math.floor(min+Math.random()*(max-min));
        }
  3. 下落到一定位置还是要删除(图片,数组);

    1. main.removeChild(enemys[i].oImg);
      enemys.splice(i,1);

这里写图片描述
这里写图片描述
这里写图片描述

0 0
原创粉丝点击