booty.java

来自「手机RPG游戏」· Java 代码 · 共 55 行

JAVA
55
字号
package obj;import javax.microedition.lcdui.*;import main.*;import java.util.Random;public class Booty extends Bullet{public  int bootyId;private  int idnum;//图片的总数,用来产生随机数。private  int time=0;private  int n=Cntrl.load.bootyNatality;//执行多少次后出现一个奖品   public Booty(int xp,int yp,int sw,int sh) {   super( xp, yp, 0, 0, sw, sh);   idnum=Cntrl.load.bootyImg.length;   this.screenW=sw;   }   public boolean getAlive(){     return alive&&xPos>0&&xPos<screenW+(xPos)&&yPos>0&&yPos<screenH;   }   public void DrawSelf(Graphics g){     if(0==time%n){       bootyId=new Random().nextInt(idnum);       img=Cntrl.load.bootyImg[bootyId];       xPos=new Random().nextInt(this.screenW);       yPos=2;       time=1;       this.alive=true;     }     if(getAlive())     { this.bootyMove();       g.drawImage(img,xPos,yPos,Graphics.LEFT|Graphics.TOP);     }     else {time++;}//有一个存在时就不加 }   private void bootyMove(){     ySpeed=bootyId+1;     //xPos+=xSpeed;     yPos+=ySpeed;    }private void hit(){   this.alive=false;//如果碰撞成功就消失.    }}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?