本文整理汇总了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;
}
示例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;
}
示例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()));
}
示例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;
}
示例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;
}