当前位置: 首页>>代码示例>>Java>>正文


Java Rectangle.getHeight方法代码示例

本文整理汇总了Java中org.newdawn.slick.geom.Rectangle.getHeight方法的典型用法代码示例。如果您正苦于以下问题:Java Rectangle.getHeight方法的具体用法?Java Rectangle.getHeight怎么用?Java Rectangle.getHeight使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.newdawn.slick.geom.Rectangle的用法示例。


在下文中一共展示了Rectangle.getHeight方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: isInViewport

import org.newdawn.slick.geom.Rectangle; //导入方法依赖的package包/类
/**
 * Verifica qual a porcentagem de um determinado objeto de um determinado tamanho no viewport.
 * @param objCenter		Centro do corpo, em unidades do mundo.
 * @param halfWidth		Metade da largura do corpo, em unidades do mundo.
 * @param halfHeight	Metade da largura do corpo, em unidades do mundo.
 * @param offset		Extens�es da �rea de avalia��o de som.
 * @return				Porcentagem da �rea do objeto no viewport.
 */
public float isInViewport(Vec2 objCenter, float halfWidth, float halfHeight, Vec2 offset) {
	//Por padr�o, o fatro de som � 0.
	float factor = 0;

	//O corpo tem suas medidas convertidas para unidades de tela e sua posi��o no canto superior esquerdo.
	Vec2 wObjCenter = this.worldToScreen(objCenter);
	Vec2 size = new Vec2(this.convertWorldScaleInPixels(halfWidth), this.convertWorldScaleInPixels(halfHeight));
	size.x *= offset.x;
	size.y *= offset.y;
	Rectangle body = new Rectangle(wObjCenter.x - size.x, wObjCenter.y - size.y, size.x * 2, size.y * 2);
	
	//Primeiramente, verifica se os ret�ngulos interseccionaram.
	if (Utils.intersect(cam, body)) {
		/* Caso tenham interseccionado, verifica o fator de som
		 * de acordo com a �rea de r2 em r1.*/
		Rectangle overlap = Utils.getOverlapArea(cam, body);
		factor = (overlap.getWidth() * overlap.getHeight()) / (body.getWidth() * body.getHeight());
		
		//Normaliza o fator.
		if (factor > 1.0f) factor = 1.0f;
	}
	
	return factor;
}
 
开发者ID:intentor,项目名称:telyn,代码行数:33,代码来源:ViewportTransform.java

示例2: isSomethingBlocking

import org.newdawn.slick.geom.Rectangle; //导入方法依赖的package包/类
public boolean isSomethingBlocking(Rectangle rectangle) {
    	int x = (int)(rectangle.getX() / mTmxMap.getTilewidth());
    	int y = (int)(rectangle.getY() / mTmxMap.getTileheight());
    	int endX = (int)((rectangle.getX() + rectangle.getWidth()) / mTmxMap.getTilewidth());
    	int endY = (int)((rectangle.getY() + rectangle.getHeight()) / mTmxMap.getTileheight());
    	int mapX = mTmxMap.getWidth();
    	int mapY = mTmxMap.getHeight();
    	
//    	System.out.println(mapX + ", " + mapY);
    	if (x >= mapX || y >= mapY) {
    	    return true;
    	}
    	
    	for (; x < endX; ++x) {
        	for (; y < endY; ++y) {
        	    MapElement m = getMapElement(x, y);
        		if (m != null && m.isBlocking()) {
        			return true;
        		}
        	}
    	}
    	
    	return false;
    }
 
开发者ID:AlexMog,项目名称:MMO-Rulemasters-World,代码行数:25,代码来源:Map.java

示例3: intersect

import org.newdawn.slick.geom.Rectangle; //导入方法依赖的package包/类
/**
 * Verifica se houve interse��o entre dois ret�ngulos.
 * @param r1 Ret�ngulo 1.
 * @param r2 Ret�ngulo 2.
 * @return Valor booleano indicando se houve interse��o.
 */
public static boolean intersect(Rectangle r1, Rectangle r2) {
	/* Ocorre colis�o se:
	 * !(left > other.right || right < other.left ||
	 *	top > other.bottom || bottom < other.top)
	 */		
	return !((r1.getX() > (r2.getX() + r2.getWidth()) || (r1.getX() + r1.getWidth()) < r2.getX()) ||
			(r1.getY() > (r2.getY() + r2.getHeight()) || (r1.getY() + r1.getHeight()) < r2.getY()));		
}
 
开发者ID:intentor,项目名称:telyn,代码行数:15,代码来源:Utils.java

示例4: isInsideBox

import org.newdawn.slick.geom.Rectangle; //导入方法依赖的package包/类
int isInsideBox(){
    int mX = Mouse.getX(),
        mY = gc.getHeight()-Mouse.getY(),
        i = 0;
    for(Rectangle rect : rects){
        if (mX > rect.getX() && mX < rect.getX()+rect.getWidth() && mY > rect.getY() && mY < rect.getY()+rect.getHeight()){
            return i;
        }
        i++;
    }
    return -1;
}
 
开发者ID:Piratkopia13,项目名称:Pixel-Planet,代码行数:13,代码来源:GUI.java

示例5: getIndex

import org.newdawn.slick.geom.Rectangle; //导入方法依赖的package包/类
private int getIndex(Rectangle rectangle) {
  int index = -1;
  double verticalMidpoint = bounds.getX() + (bounds.getWidth() / 2);
  double horizontalMidpoint = bounds.getY() + (bounds.getHeight() / 2);
  Rectangle pRect = rectangle;

  // Object can completely fit within the top quadrants
  boolean topQuadrant = (pRect.getY() < horizontalMidpoint && pRect.getY() + pRect.getHeight() < horizontalMidpoint);
  // Object can completely fit within the bottom quadrants
  boolean bottomQuadrant = (pRect.getY() > horizontalMidpoint);

  // Object can completely fit within the left quadrants
  if (pRect.getX() < verticalMidpoint && pRect.getX() + pRect.getWidth() < verticalMidpoint) {
     if (topQuadrant) {
       index = 1;
     }
     else if (bottomQuadrant) {
       index = 2;
     }
   }
   // Object can completely fit within the right quadrants
   else if (pRect.getX() > verticalMidpoint) {
    if (topQuadrant) {
      index = 0;
    }
    else if (bottomQuadrant) {
      index = 3;
    }
  }

  return index;
}
 
开发者ID:jubilee145,项目名称:APFG,代码行数:33,代码来源:Quadtree.java


注:本文中的org.newdawn.slick.geom.Rectangle.getHeight方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。