v0.8.0: made diamond painter patterns generic
This commit is contained in:
parent
633e3d3db5
commit
1d6c6523b2
|
@ -138,6 +138,29 @@ public abstract class Painter {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void fillDiamond(Level level, Rect rect, int value ) {
|
||||||
|
fillDiamond( level, rect.left, rect.top, rect.width(), rect.height(), value );
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void fillDiamond(Level level, Rect rect, int m, int value ) {
|
||||||
|
fillDiamond( level, rect.left + m, rect.top + m, rect.width() - m*2, rect.height() - m*2, value );
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void fillDiamond(Level level, int x, int y, int w, int h, int value){
|
||||||
|
|
||||||
|
//we want the end width to be w, and the width will grow by a total of (h-2 - h%2)
|
||||||
|
int diamondWidth = w - (h-2 - h%2);
|
||||||
|
//but starting width cannot be smaller than 2 on even width, 3 on odd width.
|
||||||
|
diamondWidth = Math.max(diamondWidth, w%2 == 0 ? 2 : 3);
|
||||||
|
|
||||||
|
for (int i = 0; i <= h; i++){
|
||||||
|
Painter.fill( level, x + (w - diamondWidth)/2, y+i, diamondWidth, h-2*i, value);
|
||||||
|
diamondWidth += 2;
|
||||||
|
if (diamondWidth > w) break;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public static Point drawInside( Level level, Room room, Point from, int n, int value ) {
|
public static Point drawInside( Level level, Room room, Point from, int n, int value ) {
|
||||||
|
|
||||||
Point step = new Point();
|
Point step = new Point();
|
||||||
|
|
|
@ -33,16 +33,7 @@ public class DiamondGooRoom extends GooBossRoom {
|
||||||
public void paint(Level level) {
|
public void paint(Level level) {
|
||||||
Painter.fill( level, this, Terrain.WALL );
|
Painter.fill( level, this, Terrain.WALL );
|
||||||
|
|
||||||
//we want the end width to be width()-2, and the width will grow by a total of (height()-4 - height()%2)
|
Painter.fillDiamond( level, this, 1, Terrain.EMPTY);
|
||||||
int diamondWidth = width()-2 - (height()-4 - height()%2);
|
|
||||||
//but starting width cannot be smaller than 2 on even width, 3 on odd width.
|
|
||||||
diamondWidth = Math.max(diamondWidth, width()%2 == 0 ? 2 : 3);
|
|
||||||
|
|
||||||
for (int i = 1; i < height(); i++){
|
|
||||||
Painter.fill( level, left + (width() - diamondWidth)/2, top+i, diamondWidth, height()-2*i, Terrain.EMPTY);
|
|
||||||
diamondWidth += 2;
|
|
||||||
if (diamondWidth >= width()) break;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (Door door : connected.values()) {
|
for (Door door : connected.values()) {
|
||||||
door.set( Door.Type.REGULAR );
|
door.set( Door.Type.REGULAR );
|
||||||
|
|
Loading…
Reference in New Issue
Block a user