Search in sources :

Example 21 with Image

use of com.watabou.noosa.Image in project pixel-dungeon-remix by NYRDS.

the class CustomLayerTilemap method tile.

@Override
public Image tile(int pos) {
    ArrayList<Image> imgs = new ArrayList<>();
    if (data[pos] >= 0) {
        Image img = new Image(getTexture());
        img.frame(getTileset().get(data[pos]));
        imgs.add(img);
    }
    for (CustomLayerTilemap layer : mLayers) {
        if (layer.data[pos] >= 0) {
            Image img = new Image(layer.getTexture());
            img.frame(layer.getTileset().get(layer.data[pos]));
            imgs.add(img);
        }
    }
    if (!imgs.isEmpty()) {
        return new CompositeImage(imgs);
    }
    return null;
}
Also used : CompositeImage(com.watabou.noosa.CompositeImage) ArrayList(java.util.ArrayList) Image(com.watabou.noosa.Image) CompositeImage(com.watabou.noosa.CompositeImage)

Example 22 with Image

use of com.watabou.noosa.Image in project pixel-dungeon-remix by NYRDS.

the class NewFireball method createChildren.

@Override
protected void createChildren() {
    sparks = new Group();
    add(sparks);
    bLight = new Image(Assets.FIREBALL);
    bLight.frame(BLIGHT);
    bLight.origin.set(bLight.width / 2);
    bLight.angularSpeed = -120;
    add(bLight);
    emitter = new Emitter();
    emitter.pour(new Emitter.Factory() {

        @Override
        public void emit(Emitter emitter, int index, float x, float y) {
            Flame p = (Flame) emitter.recycle(Flame.class);
            p.reset();
            p.x = x - p.width / 2;
            p.y = y - p.height / 2;
        }
    }, 0.1f);
    add(emitter);
    fLight = new Image(Assets.FIREBALL);
    fLight.frame(FLIGHT);
    fLight.origin.set(fLight.width / 2);
    fLight.angularSpeed = 360;
    add(fLight);
    bLight.texture.filter(Texture.LINEAR, Texture.LINEAR);
}
Also used : Group(com.watabou.noosa.Group) Emitter(com.watabou.noosa.particles.Emitter) Image(com.watabou.noosa.Image)

Example 23 with Image

use of com.watabou.noosa.Image in project pixel-dungeon-remix by NYRDS.

the class StartScene method create.

@Override
public void create() {
    super.create();
    Badges.loadGlobal();
    uiCamera.setVisible(false);
    int w = Camera.main.width;
    int h = Camera.main.height;
    if (PixelDungeon.landscape()) {
        width = WIDTH_L;
        height = HEIGHT_L;
    } else {
        width = WIDTH_P;
        height = HEIGHT_P;
    }
    float left = (w - width) / 2;
    float top = (h - height) / 2;
    bottom = h - top;
    Archs archs = new Archs();
    archs.setSize(w, h);
    add(archs);
    Image title = BannerSprites.get(Type.SELECT_YOUR_HERO);
    title.setScale(0.85f, 0.85f);
    title.x = align((w - title.width()) / 2);
    title.y = align(top);
    add(title);
    buttonX = left;
    buttonY = bottom - BUTTON_HEIGHT;
    btnNewGame = new GameButton(Game.getVar(R.string.StartScene_New)) {

        @Override
        protected void onClick() {
            if (GamesInProgress.check(curShield.cl) != null) {
                StartScene.this.add(new WndOptions(Game.getVar(R.string.StartScene_Really), Game.getVar(R.string.StartScene_Warning), Game.getVar(R.string.StartScene_Yes), Game.getVar(R.string.StartScene_No)) {

                    @Override
                    protected void onSelect(int index) {
                        if (index == 0) {
                            selectDifficulty();
                        }
                    }
                });
            } else {
                selectDifficulty();
            }
        }
    };
    add(btnNewGame);
    btnLoad = new GameButton(Game.getVar(R.string.StartScene_Load)) {

        @Override
        protected void onClick() {
            InterlevelScene.mode = InterlevelScene.Mode.CONTINUE;
            Game.switchScene(InterlevelScene.class);
            Dungeon.heroClass = curShield.cl;
        }
    };
    add(btnLoad);
    float centralHeight = buttonY - title.y - title.height();
    int usableClasses = 0;
    shields.clear();
    for (HeroClass cl : HeroClass.values()) {
        if (cl.allowed()) {
            usableClasses++;
            ClassShield shield = new ClassShield(cl);
            shields.add(shield);
            add(shield);
        }
    }
    if (PixelDungeon.landscape()) {
        float shieldW = width / usableClasses;
        float shieldH = Math.min(centralHeight, shieldW);
        top = title.y + title.height + (centralHeight - shieldH) / 2;
        int i = 0;
        for (ClassShield shield : shields) {
            shield.setRect(left + i * shieldW, top, shieldW, shieldH);
            i++;
        }
        ChallengeButton challenge = new ChallengeButton();
        challenge.setPos(w / 2 - challenge.width() / 2, 0);
        add(challenge);
    } else {
        int classesPerRow = 4;
        float shieldW = width / (classesPerRow);
        float shieldH = shieldW * 1.2f;
        top = title.y + title.height() + shieldH * 0.25f;
        int i = 0;
        int j = 0;
        for (ClassShield shield : shields) {
            if (j == 0 && i == 1) {
                i += 2;
            }
            shield.setRect(left + i * shieldW, top + (shieldH * 1.5f) * j, shieldW, shieldH);
            i++;
            if (i == classesPerRow) {
                j++;
                i = 0;
            }
        }
        ChallengeButton challenge = new ChallengeButton();
        challenge.setPos(w / 2 - challenge.width() / 2, top + shieldH * 0.5f - challenge.height() / 2);
        add(challenge);
    }
    unlock = PixelScene.createMultiline(GuiProperties.titleFontSize());
    add(unlock);
    huntressUnlocked = Badges.isUnlocked(Badges.Badge.BOSS_SLAIN_3) || (PixelDungeon.donated() >= 1);
    elfUnlocked = Badges.isUnlocked(Badges.Badge.BOSS_SLAIN_4) || (PixelDungeon.donated() >= 2);
    gnollUnlocked = Badges.isUnlocked(Badges.Badge.GNOLL_UNLOCKED) || (PixelDungeon.donated() >= 3);
    ExitButton btnExit = new ExitButton();
    btnExit.setPos(Camera.main.width - btnExit.width(), 0);
    add(btnExit);
    for (ClassShield shield : shields) {
        if (shield.cl == HeroClass.values()[PixelDungeon.lastClass()]) {
            updateShield(shield);
            return;
        }
    }
    if (curShield == null) {
        updateShield(shields.get(0));
    }
    fadeIn();
}
Also used : WndOptions(com.watabou.pixeldungeon.windows.WndOptions) Archs(com.watabou.pixeldungeon.ui.Archs) ExitButton(com.watabou.pixeldungeon.ui.ExitButton) HeroClass(com.watabou.pixeldungeon.actors.hero.HeroClass) Image(com.watabou.noosa.Image)

Example 24 with Image

use of com.watabou.noosa.Image in project pixel-dungeon-remix by NYRDS.

the class SurfaceScene method create.

@Override
public void create() {
    super.create();
    Music.INSTANCE.play(Assets.HAPPY, true);
    Music.INSTANCE.volume(1f);
    uiCamera.setVisible(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 - WIDTH) / 2);
    float vy = align((h - HEIGHT) / 2);
    Point s = Camera.main.cameraToScreen(vx, vy);
    viewport = new Camera(s.x, s.y, WIDTH, 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(WIDTH, 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(WIDTH) - size / 2;
            star.y = Random.Float(HEIGHT) - size / 2;
            star.am = size * (1 - star.y / HEIGHT);
            window.add(star);
        }
    }
    float range = 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, HEIGHT + 1, dayTime);
        patch.brightness(dayTime ? 0.7f : 0.4f);
        window.add(patch);
    }
    Avatar a = new Avatar(Dungeon.hero.heroClass);
    a.x = PixelScene.align((WIDTH - a.width) / 2);
    a.y = HEIGHT - a.height + 1;
    window.add(a);
    final Pet pet = new Pet();
    pet.rm = pet.gm = pet.bm = 1.2f;
    pet.x = WIDTH / 2 + 2;
    pet.y = HEIGHT - pet.height;
    window.add(pet);
    if (dayTime) {
        a.brightness(1.2f);
        pet.brightness(1.2f);
    }
    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, HEIGHT, dayTime);
        patch.brightness(dayTime ? 1.0f : 0.8f);
        window.add(patch);
    }
    Image frame = new Image(Assets.SURFACE);
    if (!dayTime) {
        frame.hardlight(0xDDEEFF);
    }
    frame.frame(0, 0, 88, 125);
    frame.x = vx - 4;
    frame.y = vy - 9;
    add(frame);
    RedButton gameOver = new RedButton(TXT_GAME_OVER) {

        protected void onClick() {
            Game.switchScene(TitleScene.class);
        }
    };
    gameOver.setSize(WIDTH - 10, 20);
    gameOver.setPos(5 + frame.x + 4, frame.y + frame.height + 4);
    add(gameOver);
    Badges.validateHappyEnd();
    Dungeon.gameOver();
    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 25 with Image

use of com.watabou.noosa.Image in project pixel-dungeon-remix by NYRDS.

the class Lightning method update.

@Override
public void update() {
    super.update();
    if ((life -= Game.elapsed) < 0) {
        killAndErase();
        if (callback != null) {
            callback.call();
        }
    } else {
        float alpha = life / DURATION;
        for (int i = 0; i < length - 1; i++) {
            float sx = cx[i];
            float sy = cy[i];
            float ex = cx[i + 1];
            float ey = cy[i + 1];
            float x2 = (sx + ex) / 2 + Random.Float(-4, +4);
            float y2 = (sy + ey) / 2 + Random.Float(-4, +4);
            float dx = x2 - sx;
            float dy = y2 - sy;
            Image arc = arcsS[i];
            arc.am = alpha;
            arc.angle = (float) (Math.atan2(dy, dx) * A);
            arc.Scale().x = (float) Math.sqrt(dx * dx + dy * dy) / arc.width;
            dx = ex - x2;
            dy = ey - y2;
            arc = arcsE[i];
            arc.am = alpha;
            arc.angle = (float) (Math.atan2(dy, dx) * A);
            arc.Scale().x = (float) Math.sqrt(dx * dx + dy * dy) / arc.width;
            arc.x = x2 - arc.origin.x;
            arc.y = y2 - arc.origin.x;
        }
    }
}
Also used : Image(com.watabou.noosa.Image)

Aggregations

Image (com.watabou.noosa.Image)63 TouchArea (com.watabou.noosa.TouchArea)10 Group (com.watabou.noosa.Group)8 Archs (com.watabou.pixeldungeon.ui.Archs)8 Touch (com.watabou.input.Touchscreen.Touch)7 BitmapText (com.watabou.noosa.BitmapText)6 Emitter (com.watabou.noosa.particles.Emitter)6 AlphaTweener (com.watabou.noosa.tweeners.AlphaTweener)6 ExitButton (com.watabou.pixeldungeon.ui.ExitButton)6 Archs (com.shatteredpixel.shatteredpixeldungeon.ui.Archs)4 NinePatch (com.watabou.noosa.NinePatch)4 Text (com.watabou.noosa.Text)4 Flare (com.watabou.pixeldungeon.effects.Flare)4 Point (com.watabou.utils.Point)4 ExitButton (com.shatteredpixel.shatteredpixeldungeon.ui.ExitButton)3 NoosaInputProcessor (com.watabou.input.NoosaInputProcessor)3 TextureFilm (com.watabou.noosa.TextureFilm)3 RedButton (com.watabou.pixeldungeon.ui.RedButton)3 RectF (android.graphics.RectF)2 Flare (com.shatteredpixel.shatteredpixeldungeon.effects.Flare)2