⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pardata.java

📁 是男人就撑过20秒,我写到了手机上,算法什么的都还未完工,但已能运行.加了个简单的时钟,可是不太准确,呵呵.
💻 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 + -