use of com.watabou.utils.Point in project pixel-dungeon by watabou.
the class StandardPainter method paintBridge.
private static void paintBridge(Level level, Room room) {
fill(level, room.left + 1, room.top + 1, room.width() - 1, room.height() - 1, !Dungeon.bossLevel() && !Dungeon.bossLevel(Dungeon.depth + 1) && Random.Int(3) == 0 ? Terrain.CHASM : Terrain.WATER);
Point door1 = null;
Point door2 = null;
for (Point p : room.connected.values()) {
if (door1 == null) {
door1 = p;
} else {
door2 = p;
}
}
if ((door1.x == room.left && door2.x == room.right) || (door1.x == room.right && door2.x == room.left)) {
int s = room.width() / 2;
drawInside(level, room, door1, s, Terrain.EMPTY_SP);
drawInside(level, room, door2, s, Terrain.EMPTY_SP);
fill(level, room.center().x, Math.min(door1.y, door2.y), 1, Math.abs(door1.y - door2.y) + 1, Terrain.EMPTY_SP);
} else if ((door1.y == room.top && door2.y == room.bottom) || (door1.y == room.bottom && door2.y == room.top)) {
int s = room.height() / 2;
drawInside(level, room, door1, s, Terrain.EMPTY_SP);
drawInside(level, room, door2, s, Terrain.EMPTY_SP);
fill(level, Math.min(door1.x, door2.x), room.center().y, Math.abs(door1.x - door2.x) + 1, 1, Terrain.EMPTY_SP);
} else if (door1.x == door2.x) {
fill(level, door1.x == room.left ? room.left + 1 : room.right - 1, Math.min(door1.y, door2.y), 1, Math.abs(door1.y - door2.y) + 1, Terrain.EMPTY_SP);
} else if (door1.y == door2.y) {
fill(level, Math.min(door1.x, door2.x), door1.y == room.top ? room.top + 1 : room.bottom - 1, Math.abs(door1.x - door2.x) + 1, 1, Terrain.EMPTY_SP);
} else if (door1.y == room.top || door1.y == room.bottom) {
drawInside(level, room, door1, Math.abs(door1.y - door2.y), Terrain.EMPTY_SP);
drawInside(level, room, door2, Math.abs(door1.x - door2.x), Terrain.EMPTY_SP);
} else if (door1.x == room.left || door1.x == room.right) {
drawInside(level, room, door1, Math.abs(door1.x - door2.x), Terrain.EMPTY_SP);
drawInside(level, room, door2, Math.abs(door1.y - door2.y), Terrain.EMPTY_SP);
}
}
use of com.watabou.utils.Point in project pixel-dungeon by watabou.
the class WeakFloorPainter method paint.
public static void paint(Level level, Room room) {
fill(level, room, Terrain.WALL);
fill(level, room, 1, Terrain.CHASM);
Room.Door door = room.entrance();
door.set(Room.Door.Type.REGULAR);
if (door.x == room.left) {
for (int i = room.top + 1; i < room.bottom; i++) {
drawInside(level, room, new Point(room.left, i), Random.IntRange(1, room.width() - 2), Terrain.EMPTY_SP);
}
} else if (door.x == room.right) {
for (int i = room.top + 1; i < room.bottom; i++) {
drawInside(level, room, new Point(room.right, i), Random.IntRange(1, room.width() - 2), Terrain.EMPTY_SP);
}
} else if (door.y == room.top) {
for (int i = room.left + 1; i < room.right; i++) {
drawInside(level, room, new Point(i, room.top), Random.IntRange(1, room.height() - 2), Terrain.EMPTY_SP);
}
} else if (door.y == room.bottom) {
for (int i = room.left + 1; i < room.right; i++) {
drawInside(level, room, new Point(i, room.bottom), Random.IntRange(1, room.height() - 2), Terrain.EMPTY_SP);
}
}
}
use of com.watabou.utils.Point in project pixel-dungeon by watabou.
the class SurfaceScene method create.
@Override
public void create() {
super.create();
Music.INSTANCE.play(Assets.HAPPY, true);
Music.INSTANCE.volume(1f);
uiCamera.visible = false;
int w = Camera.main.width;
int h = Camera.main.height;
Archs archs = new Archs();
archs.reversed = true;
archs.setSize(w, h);
add(archs);
float vx = align((w - SKY_WIDTH) / 2);
float vy = align((h - SKY_HEIGHT - BUTTON_HEIGHT) / 2);
Point s = Camera.main.cameraToScreen(vx, vy);
viewport = new Camera(s.x, s.y, SKY_WIDTH, SKY_HEIGHT, defaultZoom);
Camera.add(viewport);
Group window = new Group();
window.camera = viewport;
add(window);
boolean dayTime = !Dungeon.nightMode;
Sky sky = new Sky(dayTime);
sky.scale.set(SKY_WIDTH, SKY_HEIGHT);
window.add(sky);
if (!dayTime) {
for (int i = 0; i < NSTARS; i++) {
float size = Random.Float();
ColorBlock star = new ColorBlock(size, size, 0xFFFFFFFF);
star.x = Random.Float(SKY_WIDTH) - size / 2;
star.y = Random.Float(SKY_HEIGHT) - size / 2;
star.am = size * (1 - star.y / SKY_HEIGHT);
window.add(star);
}
}
float range = SKY_HEIGHT * 2 / 3;
for (int i = 0; i < NCLOUDS; i++) {
Cloud cloud = new Cloud((NCLOUDS - 1 - i) * (range / NCLOUDS) + Random.Float(range / NCLOUDS), dayTime);
window.add(cloud);
}
int nPatches = (int) (sky.width() / GrassPatch.WIDTH + 1);
for (int i = 0; i < nPatches * 4; i++) {
GrassPatch patch = new GrassPatch((i - 0.75f) * GrassPatch.WIDTH / 4, SKY_HEIGHT + 1, dayTime);
patch.brightness(dayTime ? 0.7f : 0.4f);
window.add(patch);
}
Avatar a = new Avatar(Dungeon.hero.heroClass);
a.x = PixelScene.align((SKY_WIDTH - a.width) / 2);
a.y = SKY_HEIGHT - a.height;
window.add(a);
final Pet pet = new Pet();
pet.rm = pet.gm = pet.bm = 1.2f;
pet.x = SKY_WIDTH / 2 + 2;
pet.y = SKY_HEIGHT - pet.height;
window.add(pet);
window.add(new TouchArea(sky) {
protected void onClick(Touch touch) {
pet.jump();
}
;
});
for (int i = 0; i < nPatches; i++) {
GrassPatch patch = new GrassPatch((i - 0.5f) * GrassPatch.WIDTH, SKY_HEIGHT, dayTime);
patch.brightness(dayTime ? 1.0f : 0.8f);
window.add(patch);
}
Image frame = new Image(Assets.SURFACE);
frame.frame(0, 0, FRAME_WIDTH, FRAME_HEIGHT);
frame.x = vx - FRAME_MARGIN_X;
frame.y = vy - FRAME_MARGIN_TOP;
add(frame);
if (dayTime) {
a.brightness(1.2f);
pet.brightness(1.2f);
} else {
frame.hardlight(0xDDEEFF);
}
RedButton gameOver = new RedButton("Game Over") {
protected void onClick() {
Game.switchScene(TitleScene.class);
}
};
gameOver.setSize(SKY_WIDTH - FRAME_MARGIN_X * 2, BUTTON_HEIGHT);
gameOver.setPos(frame.x + FRAME_MARGIN_X * 2, frame.y + frame.height + 4);
add(gameOver);
Badges.validateHappyEnd();
fadeIn();
}
use of com.watabou.utils.Point in project pixel-dungeon by watabou.
the class MagicWellPainter method paint.
public static void paint(Level level, Room room) {
fill(level, room, Terrain.WALL);
fill(level, room, 1, Terrain.EMPTY);
Point c = room.center();
set(level, c.x, c.y, Terrain.WELL);
@SuppressWarnings("unchecked") Class<? extends WellWater> waterClass = (Class<? extends WellWater>) Random.element(WATERS);
WellWater water = (WellWater) level.blobs.get(waterClass);
if (water == null) {
try {
water = waterClass.newInstance();
} catch (Exception e) {
water = null;
}
}
water.seed(c.x + Level.WIDTH * c.y, 1);
level.blobs.put(waterClass, water);
room.entrance().set(Room.Door.Type.REGULAR);
}
use of com.watabou.utils.Point in project pixel-dungeon by watabou.
the class PassagePainter method paint.
public static void paint(Level level, Room room) {
pasWidth = room.width() - 2;
pasHeight = room.height() - 2;
int floor = level.tunnelTile();
ArrayList<Integer> joints = new ArrayList<Integer>();
for (Point door : room.connected.values()) {
joints.add(xy2p(room, door));
}
Collections.sort(joints);
int nJoints = joints.size();
int perimeter = pasWidth * 2 + pasHeight * 2;
int start = 0;
int maxD = joints.get(0) + perimeter - joints.get(nJoints - 1);
for (int i = 1; i < nJoints; i++) {
int d = joints.get(i) - joints.get(i - 1);
if (d > maxD) {
maxD = d;
start = i;
}
}
int end = (start + nJoints - 1) % nJoints;
int p = joints.get(start);
do {
set(level, p2xy(room, p), floor);
p = (p + 1) % perimeter;
} while (p != joints.get(end));
set(level, p2xy(room, p), floor);
for (Room.Door door : room.connected.values()) {
door.set(Room.Door.Type.TUNNEL);
}
}
Aggregations