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


Java Rect类代码示例

本文整理汇总了Java中com.watabou.utils.Rect的典型用法代码示例。如果您正苦于以下问题:Java Rect类的具体用法?Java Rect怎么用?Java Rect使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: paint

import com.watabou.utils.Rect; //导入依赖的package包/类
@Override
public void paint(Level level) {

	Painter.fill( level, this, Terrain.WALL );

	Painter.fill( level, this, 1, Terrain.CHASM );

	ArrayList<Rect> platforms = new ArrayList<>();
	splitPlatforms( new Rect(left+2, top+2, right-2, bottom-2), platforms);

	for (Rect platform : platforms){
		Painter.fill( level, platform.left, platform.top, platform.width()+1, platform.height()+1, Terrain.EMPTY_SP);
	}

	for (Door door : connected.values()) {
		door.set( Door.Type.REGULAR );
		Painter.drawInside(level, this, door, 2, Terrain.EMPTY_SP);
	}

}
 
开发者ID:G2159687,项目名称:ESPD,代码行数:21,代码来源:PlatformRoom.java

示例2: 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);
		}
	}
}
 
开发者ID:G2159687,项目名称:ESPD,代码行数:24,代码来源:WalkwayRoom.java

示例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;
	}
}
 
开发者ID:G2159687,项目名称:ESPD,代码行数:17,代码来源:Room.java

示例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;
}
 
开发者ID:G2159687,项目名称:ESPD,代码行数:24,代码来源:Room.java

示例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 );
			ArrayList<Point> doorSpots = new ArrayList<>();
			for (Point p : i.getPoints()){
				if (r.canConnect(p) && n.canConnect(p))
					doorSpots.add(p);
			}
			door = new Room.Door(Random.element(doorSpots));

			r.connected.put( n, door );
			n.connected.put( r, door );
		}
	}
}
 
开发者ID:G2159687,项目名称:ESPD,代码行数:19,代码来源:RegularPainter.java

示例6: initRooms

import com.watabou.utils.Rect; //导入依赖的package包/类
protected boolean initRooms() {

		rooms = new ArrayList<>();
		split( new Rect( 0, 0, width() - 1, height() - 1 ) );
		
		if (rooms.size() < 8) {
			return false;
		}

		Room[] ra = rooms.toArray( new Room[0] );
		for (int i=0; i < ra.length-1; i++) {
			for (int j=i+1; j < ra.length; j++) {
				ra[i].addNeigbour( ra[j] );
			}
		}
		
		return true;
	}
 
开发者ID:mango-tree,项目名称:UNIST-pixel-dungeon,代码行数:19,代码来源:RegularLevel.java

示例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 );
		}
	}
}
 
开发者ID:mango-tree,项目名称:UNIST-pixel-dungeon,代码行数:22,代码来源:RegularLevel.java

示例8: initRooms

import com.watabou.utils.Rect; //导入依赖的package包/类
protected boolean initRooms() {
	rooms = new HashSet<Room>();
	split( new Rect( 0, 0, WIDTH - 1, HEIGHT - 1 ) );
	
	if (rooms.size() < 8) {
		return false;
	}
	
	Room[] ra = rooms.toArray( new Room[0] );
	for (int i=0; i < ra.length-1; i++) {
		for (int j=i+1; j < ra.length; j++) {
			ra[i].addNeigbour( ra[j] );
		}
	}
	
	return true;
}
 
开发者ID:kurtyu,项目名称:PixelDungeonTC,代码行数:18,代码来源:RegularLevel.java

示例9: 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 );
		}
	}
}
 
开发者ID:kurtyu,项目名称:PixelDungeonTC,代码行数:22,代码来源:RegularLevel.java

示例10: initRooms

import com.watabou.utils.Rect; //导入依赖的package包/类
protected boolean initRooms() {
	rooms = new HashSet<Room>();
	split( new Rect( 0, 0, WIDTH - 1, HEIGHT - 1 ) );
	
	if (rooms.size() < 8) {
		return false;
	}
	
	Room[] ra = rooms.toArray( new Room[0] );
	for (int i=0; i < ra.length-1; i++) {
		for (int j=i+1; j < ra.length; j++) {
			ra[i].addNeighbour(ra[j]);
		}
	}
	
	return true;
}
 
开发者ID:ConsideredHamster,项目名称:YetAnotherPixelDungeon,代码行数:18,代码来源:RegularLevel.java

示例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.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 );
		}
	}
}
 
开发者ID:ConsideredHamster,项目名称:YetAnotherPixelDungeon,代码行数:22,代码来源:RegularLevel.java

示例12: initRooms

import com.watabou.utils.Rect; //导入依赖的package包/类
protected boolean initRooms() {

        rooms = new HashSet<>();
        split( new Rect( 0, 0, WIDTH - 1, HEIGHT - 1 ) );

        if (rooms.size() < 8) {
            return false;
        }

        Room[] ra = rooms.toArray( new Room[0] );
        for (int i=0; i < ra.length-1; i++) {
            for (int j=i+1; j < ra.length; j++) {
                ra[i].addNeigbour( ra[j] );
            }
        }

        return true;
    }
 
开发者ID:FthrNature,项目名称:unleashed-pixel-dungeon,代码行数:19,代码来源:InfiniteLevel.java

示例13: 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 );
        }
    }
}
 
开发者ID:FthrNature,项目名称:unleashed-pixel-dungeon,代码行数:22,代码来源:InfiniteLevel.java

示例14: initRooms

import com.watabou.utils.Rect; //导入依赖的package包/类
protected boolean initRooms() {

		rooms = new HashSet<>();
		split( new Rect( 0, 0, WIDTH - 1, HEIGHT - 1 ) );
		
		if (rooms.size() < 8) {
			return false;
		}

		Room[] ra = rooms.toArray( new Room[0] );
		for (int i=0; i < ra.length-1; i++) {
			for (int j=i+1; j < ra.length; j++) {
				ra[i].addNeigbour( ra[j] );
			}
		}
		
		return true;
	}
 
开发者ID:FthrNature,项目名称:unleashed-pixel-dungeon,代码行数:19,代码来源:RegularLevel.java

示例15: initRooms

import com.watabou.utils.Rect; //导入依赖的package包/类
protected boolean initRooms() {

		rooms = new HashSet<Room>();
		split( new Rect( 0, 0, WIDTH - 1, HEIGHT - 1 ) );
		
		if (rooms.size() < 8) {
			return false;
		}

		Room[] ra = rooms.toArray( new Room[0] );
		for (int i=0; i < ra.length-1; i++) {
			for (int j=i+1; j < ra.length; j++) {
				ra[i].addNeigbour( ra[j] );
			}
		}
		
		return true;
	}
 
开发者ID:wolispace,项目名称:soft-pixel-dungeon,代码行数:19,代码来源:RegularLevel.java


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