📄 pardata.java
字号:
import javax.microedition.lcdui.*;
public class pardata {
private int x_pos,y_pos;
private int x_vel,y_vel;
private int screenWidth;
private int screenHeight;
private Image parti;
pardata(int drawX,int drawY,int xVel,int yVel,int width,int height){
this.x_pos = drawX;
this.y_pos = drawY;
this.x_vel = xVel;
this.y_vel = yVel;
this.screenWidth = width;
this.screenHeight = height;
}
void updateParticle(int timedel){
this.x_pos += this.x_vel*(timedel/20);
this.y_pos += this.y_vel*(timedel/20);
if(this.x_pos<0)
this.x_pos=screenWidth;
if(this.x_pos>screenWidth)
this.x_pos=0;
if(this.y_pos>screenHeight)
this.y_pos=0;
if(this.y_pos<0)
this.y_pos=screenHeight;
}
void drawParticle(Graphics g,Image img){
try{
if(parti==null)
parti=img;
g.drawImage(img,this.x_pos,this.y_pos,Graphics.TOP|Graphics.LEFT);
}catch(Exception e){}
}
/*int getX(){
return this.x_pos;
}
int getY(){
return this.y_pos;
}*/
boolean isHit(Image img,int x,int y){
if((x<=this.x_pos && x+img.getWidth()>=this.x_pos) || (x>this.x_pos && x<this.x_pos+this.parti.getWidth())){
if((y<=this.y_pos && y+img.getHeight()>=this.y_pos) || (y>this.y_pos && y<this.y_pos+this.parti.getHeight()))
return true;
}
return false;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -