📄 booty.java
字号:
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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -