本文整理汇总了Java中com.watabou.utils.Rect.height方法的典型用法代码示例。如果您正苦于以下问题:Java Rect.height方法的具体用法?Java Rect.height怎么用?Java Rect.height使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.watabou.utils.Rect
的用法示例。
在下文中一共展示了Rect.height方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: curConnections
import com.watabou.utils.Rect; //导入方法依赖的package包/类
public int curConnections(int direction){
if (direction == ALL) {
return connected.size();
} else {
int total = 0;
for (Room r : connected.keySet()){
Rect i = intersect( r );
if (direction == LEFT && i.width() == 0 && i.left == left) total++;
else if (direction == TOP && i.height() == 0 && i.top == top) total++;
else if (direction == RIGHT && i.width() == 0 && i.right == right) total++;
else if (direction == BOTTOM && i.height() == 0 && i.bottom == bottom) total++;
}
return total;
}
}
示例2: canConnect
import com.watabou.utils.Rect; //导入方法依赖的package包/类
public boolean canConnect( Room r ){
Rect i = intersect( r );
boolean foundPoint = false;
for (Point p : i.getPoints()){
if (canConnect(p) && r.canConnect(p)){
foundPoint = true;
break;
}
}
if (!foundPoint) return false;
if (i.width() == 0 && i.left == left)
return canConnect(LEFT) && r.canConnect(LEFT);
else if (i.height() == 0 && i.top == top)
return canConnect(TOP) && r.canConnect(TOP);
else if (i.width() == 0 && i.right == right)
return canConnect(RIGHT) && r.canConnect(RIGHT);
else if (i.height() == 0 && i.bottom == bottom)
return canConnect(BOTTOM) && r.canConnect(BOTTOM);
else
return false;
}
示例3: curConnections
import com.watabou.utils.Rect; //导入方法依赖的package包/类
public int curConnections(int direction){
if (direction == ALL) {
return connected.size();
} else {
int total = 0;
for (Room r : connected.keySet()){
Rect i = intersect( r );
if (direction == LEFT && i.width() == 0 && i.left == left) total++;
else if (direction == TOP && i.height() == 0 && i.top == top) total++;
else if (direction == RIGHT && i.width() == 0 && i.right == right) total++;
else if (direction == BOTTOM && i.height() == 0 && i.bottom == bottom) total++;
}
return total;
}
}
示例4: canConnect
import com.watabou.utils.Rect; //导入方法依赖的package包/类
public boolean canConnect( Room r ){
Rect i = intersect( r );
boolean foundPoint = false;
for (Point p : i.getPoints()){
if (canConnect(p) && r.canConnect(p)){
foundPoint = true;
break;
}
}
if (!foundPoint) return false;
if (i.width() == 0 && i.left == left)
return canConnect(LEFT) && r.canConnect(LEFT);
else if (i.height() == 0 && i.top == top)
return canConnect(TOP) && r.canConnect(TOP);
else if (i.width() == 0 && i.right == right)
return canConnect(RIGHT) && r.canConnect(RIGHT);
else if (i.height() == 0 && i.bottom == bottom)
return canConnect(BOTTOM) && r.canConnect(BOTTOM);
else
return false;
}
示例5: splitPlatforms
import com.watabou.utils.Rect; //导入方法依赖的package包/类
private void splitPlatforms( Rect curPlatform, ArrayList<Rect> allPlatforms ){
int curArea = (curPlatform.width()+1) * (curPlatform.height()+1);
//chance to split scales between 0% and 100% between areas of 25 and 36
if (Random.Float() < (curArea-25)/11f){
if (curPlatform.width() > curPlatform.height() ||
(curPlatform.width() == curPlatform.height() && Random.Int(2) == 0)){
//split the platform
int splitX = Random.IntRange( curPlatform.left+2, curPlatform.right-2);
splitPlatforms( new Rect( curPlatform.left, curPlatform.top, splitX-1, curPlatform.bottom) , allPlatforms);
splitPlatforms( new Rect( splitX+1, curPlatform.top, curPlatform.right, curPlatform.bottom) , allPlatforms);
//add a bridge between
int bridgeY = Random.NormalIntRange(curPlatform.top, curPlatform.bottom);
allPlatforms.add( new Rect( splitX - 1, bridgeY, splitX + 1, bridgeY));
} else {
//split the platform
int splitY = Random.IntRange( curPlatform.top+2, curPlatform.bottom-2);
splitPlatforms( new Rect( curPlatform.left, curPlatform.top, curPlatform.right, splitY-1) , allPlatforms);
splitPlatforms( new Rect( curPlatform.left, splitY+1, curPlatform.right, curPlatform.bottom) , allPlatforms);
//add a bridge between
int bridgeX = Random.NormalIntRange(curPlatform.left, curPlatform.right);
allPlatforms.add( new Rect( bridgeX, splitY-1, bridgeX, splitY+1));
}
} else {
allPlatforms.add(curPlatform);
}
}
示例6: addNeigbour
import com.watabou.utils.Rect; //导入方法依赖的package包/类
public boolean addNeigbour( Room other ) {
if (neigbours.contains(other))
return true;
Rect i = intersect( other );
if ((i.width() == 0 && i.height() >= 2) ||
(i.height() == 0 && i.width() >= 2)) {
neigbours.add( other );
other.neigbours.add( this );
return true;
}
return false;
}
示例7: addNeigbour
import com.watabou.utils.Rect; //导入方法依赖的package包/类
public void addNeigbour( Room other ) {
Rect i = intersect( other );
if ((i.width() == 0 && i.height() >= 3) ||
(i.height() == 0 && i.width() >= 3)) {
neigbours.add( other );
other.neigbours.add( this );
}
}
示例8: addNeigbour
import com.watabou.utils.Rect; //导入方法依赖的package包/类
public void addNeigbour( Room other ) {
Rect i = intersect( other );
if ((i.width() == 0 && i.height() >= 3) ||
(i.height() == 0 && i.width() >= 3)) {
neigbours.add( other );
other.neigbours.add( this );
}
}
示例9: addNeighbour
import com.watabou.utils.Rect; //导入方法依赖的package包/类
public void addNeighbour(Room other) {
Rect i = intersect( other );
if ((i.width() == 0 && i.height() >= 3) ||
(i.height() == 0 && i.width() >= 3)) {
neighbours.add(other);
other.neighbours.add(this);
}
}
示例10: splitPlatforms
import com.watabou.utils.Rect; //导入方法依赖的package包/类
private void splitPlatforms( Rect curPlatform, ArrayList<Rect> allPlatforms ){
int curArea = (curPlatform.width()+1) * (curPlatform.height()+1);
//chance to split scales between 0% and 100% between areas of 25 and 36
if (Random.Float() < (curArea-25)/11f){
if (curPlatform.width() > curPlatform.height() ||
(curPlatform.width() == curPlatform.height() && Random.Int(2) == 0)){
//split the platform
int splitX = Random.IntRange( curPlatform.left+2, curPlatform.right-2);
splitPlatforms( new Rect( curPlatform.left, curPlatform.top, splitX-1, curPlatform.bottom) , allPlatforms);
splitPlatforms( new Rect( splitX+1, curPlatform.top, curPlatform.right, curPlatform.bottom) , allPlatforms);
//add a bridge between
int bridgeY = Random.NormalIntRange(curPlatform.top, curPlatform.bottom);
allPlatforms.add( new Rect( splitX - 1, bridgeY, splitX + 1, bridgeY));
} else {
//split the platform
int splitY = Random.IntRange( curPlatform.top+2, curPlatform.bottom-2);
splitPlatforms( new Rect( curPlatform.left, curPlatform.top, curPlatform.right, splitY-1) , allPlatforms);
splitPlatforms( new Rect( curPlatform.left, splitY+1, curPlatform.right, curPlatform.bottom) , allPlatforms);
//add a bridge between
int bridgeX = Random.NormalIntRange(curPlatform.left, curPlatform.right);
allPlatforms.add( new Rect( bridgeX, splitY-1, bridgeX, splitY+1));
}
} else {
allPlatforms.add(curPlatform);
}
}
示例11: addNeigbour
import com.watabou.utils.Rect; //导入方法依赖的package包/类
public boolean addNeigbour( Room other ) {
if (neigbours.contains(other))
return true;
Rect i = intersect( other );
if ((i.width() == 0 && i.height() >= 2) ||
(i.height() == 0 && i.width() >= 2)) {
neigbours.add( other );
other.neigbours.add( this );
return true;
}
return false;
}
示例12: addNeighbor
import com.watabou.utils.Rect; //导入方法依赖的package包/类
public void addNeighbor(Room other ) {
Rect i = intersect( other );
if ((i.width() == 0 && i.height() >= 3) ||
(i.height() == 0 && i.width() >= 3)) {
neighbours.add( other );
other.neighbours.add( this );
}
}
示例13: addNeigbour
import com.watabou.utils.Rect; //导入方法依赖的package包/类
public boolean addNeigbour( Room other ) {
if (neigbours.contains(other))
return true;
Rect i = intersect( other );
if ((i.width() == 0 && i.height() >= 2) ||
(i.height() == 0 && i.width() >= 2)) {
neigbours.add( other );
other.neigbours.add( this );
return true;
}
return false;
}
示例14: createWalls
import com.watabou.utils.Rect; //导入方法依赖的package包/类
private void createWalls( Level level, Rect area ){
if (Math.max(area.width()+1, area.height()+1) < 5
|| Math.min(area.width()+1, area.height()+1) < 3){
return;
}
int tries = 10;
//splitting top/bottom
if (area.width() > area.height() || (area.width() == area.height() && Random.Int(2) == 0)){
do{
int splitX = Random.IntRange(area.left+2, area.right-2);
if (level.map[splitX + level.getWidth()*(area.top-1)] == Terrain.WALL
&& level.map[splitX + level.getWidth()*(area.bottom+1)] == Terrain.WALL){
tries = 0;
Painter.drawLine(level, new Point(splitX, area.top), new Point(splitX, area.bottom), Terrain.WALL);
int spaceTop = Random.IntRange(area.top, area.bottom-1);
Painter.set(level, splitX, spaceTop, Terrain.EMPTY);
Painter.set(level, splitX, spaceTop+1, Terrain.EMPTY);
createWalls(level, new Rect(area.left, area.top, splitX-1, area.bottom));
createWalls(level, new Rect(splitX+1, area.top, area.right, area.bottom));
}
} while (--tries > 0);
//splitting left/right
} else {
do{
int splitY = Random.IntRange(area.top+2, area.bottom-2);
if (level.map[area.left-1 + level.getWidth()*splitY] == Terrain.WALL
&& level.map[area.right+1 + level.getWidth()*splitY] == Terrain.WALL){
tries = 0;
Painter.drawLine(level, new Point(area.left, splitY), new Point(area.right, splitY), Terrain.WALL);
int spaceLeft = Random.IntRange(area.left, area.right-1);
Painter.set(level, spaceLeft, splitY, Terrain.EMPTY);
Painter.set(level, spaceLeft+1, splitY, Terrain.EMPTY);
createWalls(level, new Rect(area.left, area.top, area.right, splitY-1));
createWalls(level, new Rect(area.left, splitY+1, area.right, area.bottom));
}
} while (--tries > 0);
}
}
示例15: joinRooms
import com.watabou.utils.Rect; //导入方法依赖的package包/类
protected boolean joinRooms( Level l, Room r, Room n ) {
if (!(r instanceof EmptyRoom && n instanceof EmptyRoom)) {
return false;
}
Rect w = r.intersect( n );
if (w.left == w.right) {
if (w.bottom - w.top < 3) {
return false;
}
if (w.height()+1 == Math.max( r.height(), n.height() )) {
return false;
}
if (r.width() + n.width() > 10) {
return false;
}
w.top += 1;
w.bottom -= 0;
w.right++;
Painter.fill( l, w.left, w.top, 1, w.height(), Terrain.EMPTY );
} else {
if (w.right - w.left < 3) {
return false;
}
if (w.width()+1 == Math.max( r.width(), n.width() )) {
return false;
}
if (r.height() + n.height() > 10) {
return false;
}
w.left += 1;
w.right -= 0;
w.bottom++;
Painter.fill( l, w.left, w.top, w.width(), 1, Terrain.EMPTY );
}
return true;
}