本文整理汇总了Java中com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter.drawLine方法的典型用法代码示例。如果您正苦于以下问题:Java Painter.drawLine方法的具体用法?Java Painter.drawLine怎么用?Java Painter.drawLine使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter
的用法示例。
在下文中一共展示了Painter.drawLine方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: paint
import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter; //导入方法依赖的package包/类
@Override
public void paint(Level level) {
Painter.fill( level, this, Terrain.WALL );
Painter.fill(level, this, 1, Terrain.EMPTY);
Door entrance = entrance();
Point center = center();
if (entrance.x == left || entrance.x == right){
Painter.drawLine(level,
new Point(center.x, top+1),
new Point(center.x, bottom-1),
Terrain.BOOKSHELF);
if (entrance.x == left) {
Painter.fill(level, center.x+1, top+1, right-center.x-1, height()-2, Terrain.EMPTY_SP);
} else {
Painter.fill(level, left+1, top+1, center.x-left-1, height()-2, Terrain.EMPTY_SP);
}
} else {
Painter.drawLine(level,
new Point(left+1, center.y),
new Point(right-1, center.y),
Terrain.BOOKSHELF);
if (entrance.y == top) {
Painter.fill(level, left+1, center.y+1, width()-2, bottom-center.y-1, Terrain.EMPTY_SP);
} else {
Painter.fill(level, left+1, top+1, width()-2, center.y-top-1, Terrain.EMPTY_SP);
}
}
level.addItemToSpawn(new PotionOfLiquidFlame());
int dropPos;
do{
dropPos = level.pointToCell(random());
} while (level.map[dropPos] != Terrain.EMPTY_SP);
level.drop( new StoneOfEnchantment(), dropPos);
entrance.set(Door.Type.HIDDEN);
}
示例2: paint
import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter; //导入方法依赖的package包/类
@Override
public void paint(Level level) {
Painter.fill( level, this, Terrain.WALL );
Painter.fill( level, this, 1, Terrain.GRASS );
Painter.fill( level, this, 2, Terrain.HIGH_GRASS );
if (Math.min(width(), height()) >= 7){
Painter.fill( level, this, 3, Terrain.GRASS );
}
Point center = center();
//place at least 2 plants for rooms with at least 9 in one dimensions
if (Math.max(width(), height()) >= 9){
//place 4 plants for very large rooms
if (Math.min(width(), height()) >= 11) {
Painter.drawLine(level, new Point(left+2, center.y), new Point(right-2, center.y), Terrain.HIGH_GRASS);
Painter.drawLine(level, new Point(center.x, top+2), new Point(center.x, bottom-2), Terrain.HIGH_GRASS);
level.plant( randomSeed(), level.pointToCell(new Point(center.x-1, center.y-1)));
level.plant( randomSeed(), level.pointToCell(new Point(center.x+1, center.y-1)));
level.plant( randomSeed(), level.pointToCell(new Point(center.x-1, center.y+1)));
level.plant( randomSeed(), level.pointToCell(new Point(center.x+1, center.y+1)));
//place 2 plants otherwise
//left/right
} else if (width() > height() || (width() == height() && Random.Int(2) == 0)){
Painter.drawLine(level, new Point(center.x, top+2), new Point(center.x, bottom-2), Terrain.HIGH_GRASS);
level.plant( randomSeed(), level.pointToCell(new Point(center.x-1, center.y)));
level.plant( randomSeed(), level.pointToCell(new Point(center.x+1, center.y)));
//top/bottom
} else {
Painter.drawLine(level, new Point(left+2, center.y), new Point(right-2, center.y), Terrain.HIGH_GRASS);
level.plant( randomSeed(), level.pointToCell(new Point(center.x, center.y-1)));
level.plant( randomSeed(), level.pointToCell(new Point(center.x, center.y+1)));
}
//place just one plant for smaller sized rooms
} else {
level.plant( randomSeed(), level.pointToCell(center));
}
for (Door door : connected.values()) {
door.set( Door.Type.REGULAR );
}
super.paint(level);
}
示例3: createWalls
import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter; //导入方法依赖的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.width()*(area.top-1)] == Terrain.WALL
&& level.map[splitX + level.width()*(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.width()*splitY] == Terrain.WALL
&& level.map[area.right+1 + level.width()*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);
}
}