本文整理汇总了Java中com.watabou.utils.Rect.width方法的典型用法代码示例。如果您正苦于以下问题:Java Rect.width方法的具体用法?Java Rect.width怎么用?Java Rect.width使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.watabou.utils.Rect
的用法示例。
在下文中一共展示了Rect.width方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: paint
import com.watabou.utils.Rect; //导入方法依赖的package包/类
@Override
public void paint(Level level) {
if (Math.min(width(), height()) > 3) {
Painter.fill(level, this, 1, Terrain.CHASM);
}
super.paint(level);
for (Room r : neigbours){
if (r instanceof BridgeRoom || r instanceof WalkwayRoom){
Rect i = intersect(r);
if (i.width() != 0){
i.left++;
i.right--;
} else {
i.top++;
i.bottom--;
}
Painter.fill(level, i.left, i.top, i.width()+1, i.height()+1, Terrain.CHASM);
}
}
}
示例2: 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;
}
}
示例3: 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;
}
示例4: placeDoors
import com.watabou.utils.Rect; //导入方法依赖的package包/类
private void placeDoors( Room r ) {
for (Room n : r.connected.keySet()) {
Room.Door door = r.connected.get( n );
if (door == null) {
Rect i = r.intersect( n );
if (i.width() == 0) {
door = new Room.Door(
i.left,
Random.Int( i.top + 1, i.bottom ) );
} else {
door = new Room.Door(
Random.Int( i.left + 1, i.right ),
i.top);
}
r.connected.put( n, door );
n.connected.put( r, door );
}
}
}
示例5: placeDoors
import com.watabou.utils.Rect; //导入方法依赖的package包/类
private void placeDoors( Room r ) {
for (Room n : r.connected.keySet()) {
Room.Door door = r.connected.get( n );
if (door == null) {
Rect i = r.intersect( n );
if (i.width() == 0) {
door = new Room.Door(
i.left,
Random.Int( i.top + 1, i.bottom ) );
} else {
door = new Room.Door(
Random.Int( i.left + 1, i.right ),
i.top);
}
r.connected.put( n, door );
n.connected.put( r, door );
}
}
}
示例6: placeDoors
import com.watabou.utils.Rect; //导入方法依赖的package包/类
private void placeDoors( Room r ) {
for (Room n : r.connected.keySet()) {
Room.Door door = r.connected.get( n );
if (door == null) {
Rect i = r.intersect( n );
if (i.width() == 0) {
door = new Room.Door(
i.left,
Random.IntRange( i.top + 1, i.bottom - 1 ) );
} else {
door = new Room.Door(
Random.IntRange( i.left + 1, i.right - 1 ),
i.top);
}
r.connected.put( n, door );
n.connected.put( r, door );
}
}
}
示例7: placeDoors
import com.watabou.utils.Rect; //导入方法依赖的package包/类
private void placeDoors( Room r ) {
for (Room n : r.connected.keySet()) {
Room.Door door = r.connected.get( n );
if (door == null) {
Rect i = r.intersect( n );
if (i.width() == 0) {
door = new Room.Door(
i.left,
Random.Int( i.top + 1, i.bottom ) );
} else {
door = new Room.Door(
Random.Int( i.left + 1, i.right ),
i.top);
}
r.connected.put( n, door );
n.connected.put( r, door );
}
}
}
示例8: paint
import com.watabou.utils.Rect; //导入方法依赖的package包/类
@Override
public void paint(Level level) {
if (Math.min(width(), height()) > 3) {
Painter.fill(level, this, 1, Terrain.CHASM);
}
super.paint(level);
for (Room r : neigbours){
if (r instanceof BridgeRoom || r instanceof RingBridgeRoom || r instanceof WalkwayRoom){
Rect i = intersect(r);
if (i.width() != 0){
i.left++;
i.right--;
} else {
i.top++;
i.bottom--;
}
Painter.fill(level, i.left, i.top, i.width()+1, i.height()+1, Terrain.CHASM);
}
}
}
示例9: 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;
}
}
示例10: 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;
}
示例11: placeDoors
import com.watabou.utils.Rect; //导入方法依赖的package包/类
private void placeDoors(Room r) {
for (Room n : r.connected.keySet()) {
Room.Door door = r.connected.get(n);
if (door == null) {
Rect i = r.intersect(n);
if (i.width() == 0) {
door = new Room.Door(
i.left,
Random.Int(i.top + 1, i.bottom));
} else {
door = new Room.Door(
Random.Int(i.left + 1, i.right),
i.top);
}
r.connected.put(n, door);
n.connected.put(r, door);
}
}
}
示例12: paint
import com.watabou.utils.Rect; //导入方法依赖的package包/类
@Override
public void paint(Level level) {
Painter.fill(level, this, 1, Terrain.CHASM);
super.paint(level);
for (Room r : neigbours){
if (r instanceof BridgeRoom || r instanceof RingBridgeRoom || r instanceof WalkwayRoom){
Rect i = intersect(r);
if (i.width() != 0){
i.left++;
i.right--;
} else {
i.top++;
i.bottom--;
}
Painter.fill(level, i.left, i.top, i.width()+1, i.height()+1, Terrain.CHASM);
}
}
}
示例13: 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);
}
}
示例14: 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;
}
示例15: 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 );
}
}