Search in sources :

Example 1 with Image

use of com.watabou.noosa.Image in project PD-classes by watabou.

the class BitmaskEmitter method emit.

@Override
protected void emit(int index) {
    RectF frame = ((Image) target).frame();
    float ofsX = frame.left * mapW;
    float ofsY = frame.top * mapH;
    float x, y;
    do {
        x = Random.Float(frame.width()) * mapW;
        y = Random.Float(frame.height()) * mapH;
    } while ((map.bitmap.getPixel((int) (x + ofsX), (int) (y + ofsY)) & 0x000000FF) == 0);
    factory.emit(this, index, target.x + x * target.scale.x, target.y + y * target.scale.y);
}
Also used : RectF(android.graphics.RectF) Image(com.watabou.noosa.Image)

Example 2 with Image

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

the class StartScene method create.

@Override
public void create() {
    super.create();
    Badges.loadGlobal();
    uiCamera.visible = false;
    int w = Camera.main.width;
    int h = Camera.main.height;
    float width, 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;
    float bottom = h - top;
    Archs archs = new Archs();
    archs.setSize(w, h);
    add(archs);
    Image title = BannerSprites.get(Type.SELECT_YOUR_HERO);
    title.x = align((w - title.width()) / 2);
    title.y = align(top);
    add(title);
    buttonX = left;
    buttonY = bottom - BUTTON_HEIGHT;
    btnNewGame = new GameButton(TXT_NEW) {

        @Override
        protected void onClick() {
            if (GamesInProgress.check(curClass) != null) {
                StartScene.this.add(new WndOptions(TXT_REALLY, TXT_WARNING, TXT_YES, TXT_NO) {

                    @Override
                    protected void onSelect(int index) {
                        if (index == 0) {
                            startNewGame();
                        }
                    }
                });
            } else {
                startNewGame();
            }
        }
    };
    add(btnNewGame);
    btnLoad = new GameButton(TXT_LOAD) {

        @Override
        protected void onClick() {
            InterlevelScene.mode = InterlevelScene.Mode.CONTINUE;
            Game.switchScene(InterlevelScene.class);
        }
    };
    add(btnLoad);
    float centralHeight = buttonY - title.y - title.height();
    HeroClass[] classes = { HeroClass.WARRIOR, HeroClass.MAGE, HeroClass.ROGUE, HeroClass.HUNTRESS };
    for (HeroClass cl : classes) {
        ClassShield shield = new ClassShield(cl);
        shields.put(cl, shield);
        add(shield);
    }
    if (PixelDungeon.landscape()) {
        float shieldW = width / 4;
        float shieldH = Math.min(centralHeight, shieldW);
        top = title.y + title.height + (centralHeight - shieldH) / 2;
        for (int i = 0; i < classes.length; i++) {
            ClassShield shield = shields.get(classes[i]);
            shield.setRect(left + i * shieldW, top, shieldW, shieldH);
        }
        ChallengeButton challenge = new ChallengeButton();
        challenge.setPos(w / 2 - challenge.width() / 2, top + shieldH - challenge.height() / 2);
        add(challenge);
    } else {
        float shieldW = width / 2;
        float shieldH = Math.min(centralHeight / 2, shieldW * 1.2f);
        top = title.y + title.height() + centralHeight / 2 - shieldH;
        for (int i = 0; i < classes.length; i++) {
            ClassShield shield = shields.get(classes[i]);
            shield.setRect(left + (i % 2) * shieldW, top + (i / 2) * shieldH, shieldW, shieldH);
        }
        ChallengeButton challenge = new ChallengeButton();
        challenge.setPos(w / 2 - challenge.width() / 2, top + shieldH - challenge.height() / 2);
        add(challenge);
    }
    unlock = new Group();
    add(unlock);
    if (!(huntressUnlocked = Badges.isUnlocked(Badges.Badge.BOSS_SLAIN_3))) {
        BitmapTextMultiline text = PixelScene.createMultiline(TXT_UNLOCK, 9);
        text.maxWidth = (int) width;
        text.measure();
        float pos = (bottom - BUTTON_HEIGHT) + (BUTTON_HEIGHT - text.height()) / 2;
        for (BitmapText line : text.new LineSplitter().split()) {
            line.measure();
            line.hardlight(0xFFFF00);
            line.x = PixelScene.align(w / 2 - line.width() / 2);
            line.y = PixelScene.align(pos);
            unlock.add(line);
            pos += line.height();
        }
    }
    ExitButton btnExit = new ExitButton();
    btnExit.setPos(Camera.main.width - btnExit.width(), 0);
    add(btnExit);
    curClass = null;
    updateClass(HeroClass.values()[PixelDungeon.lastClass()]);
    fadeIn();
    Badges.loadingListener = new Callback() {

        @Override
        public void call() {
            if (Game.scene() == StartScene.this) {
                PixelDungeon.switchNoFade(StartScene.class);
            }
        }
    };
}
Also used : WndOptions(com.watabou.pixeldungeon.windows.WndOptions) Group(com.watabou.noosa.Group) ExitButton(com.watabou.pixeldungeon.ui.ExitButton) Image(com.watabou.noosa.Image) BitmapTextMultiline(com.watabou.noosa.BitmapTextMultiline) Callback(com.watabou.utils.Callback) Archs(com.watabou.pixeldungeon.ui.Archs) BitmapText(com.watabou.noosa.BitmapText) HeroClass(com.watabou.pixeldungeon.actors.hero.HeroClass)

Example 3 with Image

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

the class BuffIndicator method layout.

@Override
protected void layout() {
    clear();
    SparseArray<Image> newIcons = new SparseArray<Image>();
    for (Buff buff : ch.buffs()) {
        int icon = buff.icon();
        if (icon != NONE) {
            Image img = new Image(texture);
            img.frame(film.get(icon));
            img.x = x + members.size() * (SIZE + 2);
            img.y = y;
            add(img);
            newIcons.put(icon, img);
        }
    }
    for (Integer key : icons.keyArray()) {
        if (newIcons.get(key) == null) {
            Image icon = icons.get(key);
            icon.origin.set(SIZE / 2);
            add(icon);
            add(new AlphaTweener(icon, 0, 0.6f) {

                @Override
                protected void updateValues(float progress) {
                    super.updateValues(progress);
                    image.scale.set(1 + 5 * progress);
                }

                ;
            });
        }
    }
    icons = newIcons;
}
Also used : SparseArray(com.watabou.utils.SparseArray) AlphaTweener(com.watabou.noosa.tweeners.AlphaTweener) Image(com.watabou.noosa.Image) Buff(com.watabou.pixeldungeon.actors.buffs.Buff)

Example 4 with Image

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

the class HeroSprite method avatar.

public static Image avatar(HeroClass cl, int armorTier) {
    RectF patch = tiers().get(armorTier);
    Image avatar = new Image(cl.spritesheet());
    RectF frame = avatar.texture.uvRect(1, 0, FRAME_WIDTH, FRAME_HEIGHT);
    frame.offset(patch.left, patch.top);
    avatar.frame(frame);
    return avatar;
}
Also used : RectF(android.graphics.RectF) Image(com.watabou.noosa.Image)

Example 5 with Image

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

the class DungeonTilemap method tile.

public static Image tile(int index) {
    Image img = new Image(instance.texture);
    img.frame(instance.tileset.get(index));
    return img;
}
Also used : Image(com.watabou.noosa.Image)

Aggregations

Image (com.watabou.noosa.Image)18 Touch (com.watabou.input.Touchscreen.Touch)4 TouchArea (com.watabou.noosa.TouchArea)4 Archs (com.watabou.pixeldungeon.ui.Archs)4 BitmapText (com.watabou.noosa.BitmapText)3 BitmapTextMultiline (com.watabou.noosa.BitmapTextMultiline)3 Group (com.watabou.noosa.Group)3 ExitButton (com.watabou.pixeldungeon.ui.ExitButton)3 RectF (android.graphics.RectF)2 AlphaTweener (com.watabou.noosa.tweeners.AlphaTweener)2 Flare (com.watabou.pixeldungeon.effects.Flare)2 RedButton (com.watabou.pixeldungeon.ui.RedButton)2 Intent (android.content.Intent)1 Camera (com.watabou.noosa.Camera)1 ColorBlock (com.watabou.noosa.ColorBlock)1 NinePatch (com.watabou.noosa.NinePatch)1 TextureFilm (com.watabou.noosa.TextureFilm)1 BitmaskEmitter (com.watabou.noosa.particles.BitmaskEmitter)1 Emitter (com.watabou.noosa.particles.Emitter)1 Buff (com.watabou.pixeldungeon.actors.buffs.Buff)1