zonrect.java

来自「基于J2ME 开发的冒险类手机游戏」· Java 代码 · 共 46 行

JAVA
46
字号
package zonja;

public class ZonRect {

	public ZonRect() {
		super();
		// TODO Auto-generated constructor stub
	}
	
	public int x;
	public int y;
	public int dx;
	public int dy;
	
	public void setRect(int x, int y, int dx, int dy){
		this.x = x;
		this.y = y;
		this.dx = dx;
		this.dy = dy;
	}
	
	public static boolean checkRectCollisdes(ZonRect rectA, ZonRect rectB){
		if ((rectA.x + rectA.dx > rectB.x) && (rectA.y + rectA.dy > rectB.y)
				&& (rectB.x + rectB.dx > rectA.x) && (rectB.y + rectB.dy > rectA.y)){
			return true;
		} else {
			return false;
		}		
	}
	
	public static boolean checkDropCollides(ZonRect rectMain, ZonRect rectObj){
		if ((rectMain.x + rectMain.dx > rectObj.x && 
				rectMain.x + rectMain.dx < rectObj.x + rectObj.dx && 
				rectMain.y + rectMain.dy > rectObj.y && 
				rectMain.y + rectMain.dy < rectObj.y + rectObj.dy)
				|| (rectMain.x > rectObj.x && 
						rectMain.x < rectObj.x + rectObj.dx && 
						rectMain.y + rectMain.dy > rectObj.y && 
						rectMain.y + rectMain.dy < rectObj.y + rectObj.dy)){
			return true;
		} else {
			return false;
		}
	}
}

⌨️ 快捷键说明

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