Search in sources :

Example 6 with Point

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);
    }
}
Also used : Point(com.watabou.utils.Point) Point(com.watabou.utils.Point)

Example 7 with Point

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);
        }
    }
}
Also used : Point(com.watabou.utils.Point) Room(com.watabou.pixeldungeon.levels.Room) Point(com.watabou.utils.Point)

Example 8 with Point

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();
}
Also used : Group(com.watabou.noosa.Group) Point(com.watabou.utils.Point) Touch(com.watabou.input.Touchscreen.Touch) Image(com.watabou.noosa.Image) Point(com.watabou.utils.Point) Archs(com.watabou.pixeldungeon.ui.Archs) TouchArea(com.watabou.noosa.TouchArea) Camera(com.watabou.noosa.Camera) RedButton(com.watabou.pixeldungeon.ui.RedButton) ColorBlock(com.watabou.noosa.ColorBlock)

Example 9 with Point

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);
}
Also used : WellWater(com.watabou.pixeldungeon.actors.blobs.WellWater) Point(com.watabou.utils.Point)

Example 10 with Point

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);
    }
}
Also used : ArrayList(java.util.ArrayList) Point(com.watabou.utils.Point) Room(com.watabou.pixeldungeon.levels.Room) Point(com.watabou.utils.Point)

Aggregations

Point (com.watabou.utils.Point)18 Room (com.watabou.pixeldungeon.levels.Room)11 IronKey (com.watabou.pixeldungeon.items.keys.IronKey)6 Camera (com.watabou.noosa.Camera)2 Touch (com.watabou.input.Touchscreen.Touch)1 ColorBlock (com.watabou.noosa.ColorBlock)1 Group (com.watabou.noosa.Group)1 Image (com.watabou.noosa.Image)1 TouchArea (com.watabou.noosa.TouchArea)1 Alchemy (com.watabou.pixeldungeon.actors.blobs.Alchemy)1 SacrificialFire (com.watabou.pixeldungeon.actors.blobs.SacrificialFire)1 WellWater (com.watabou.pixeldungeon.actors.blobs.WellWater)1 Statue (com.watabou.pixeldungeon.actors.mobs.Statue)1 Item (com.watabou.pixeldungeon.items.Item)1 Archs (com.watabou.pixeldungeon.ui.Archs)1 RedButton (com.watabou.pixeldungeon.ui.RedButton)1 ArrayList (java.util.ArrayList)1