Search in sources :

Example 6 with Archs

use of com.shatteredpixel.shatteredpixeldungeon.ui.Archs in project shattered-pixel-dungeon-gdx by 00-Evan.

the class SurfaceScene method create.

@Override
public void create() {
    super.create();
    Music.INSTANCE.play(Assets.HAPPY, true);
    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) / 2f);
    float vy = align((h - SKY_HEIGHT - BUTTON_HEIGHT) / 2f);
    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 = Calendar.getInstance().get(Calendar.HOUR_OF_DAY) >= 7;
    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);
    // Removing semitransparent contour
    a.am = 2;
    a.aa = -1;
    a.x = (SKY_WIDTH - a.width) / 2;
    a.y = SKY_HEIGHT - a.height;
    align(a);
    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;
    align(pet);
    window.add(pet);
    window.add(new TouchArea(sky) {

        protected void onClick(NoosaInputProcessor.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(Messages.get(this, "exit")) {

        protected void onClick() {
            Game.switchScene(RankingsScene.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) Image(com.watabou.noosa.Image) Point(com.watabou.utils.Point) Archs(com.shatteredpixel.shatteredpixeldungeon.ui.Archs) TouchArea(com.watabou.noosa.TouchArea) NoosaInputProcessor(com.watabou.input.NoosaInputProcessor) Camera(com.watabou.noosa.Camera) RedButton(com.shatteredpixel.shatteredpixeldungeon.ui.RedButton) ColorBlock(com.watabou.noosa.ColorBlock)

Example 7 with Archs

use of com.shatteredpixel.shatteredpixeldungeon.ui.Archs in project shattered-pixel-dungeon-gdx by 00-Evan.

the class TitleScene method create.

@Override
public void create() {
    super.create();
    Music.INSTANCE.play(Assets.THEME, true);
    uiCamera.visible = false;
    int w = Camera.main.width;
    int h = Camera.main.height;
    Archs archs = new Archs();
    archs.setSize(w, h);
    add(archs);
    Image title = BannerSprites.get(BannerSprites.Type.PIXEL_DUNGEON);
    add(title);
    float topRegion = Math.max(95f, h * 0.45f);
    title.x = (w - title.width()) / 2f;
    if (SPDSettings.landscape())
        title.y = (topRegion - title.height()) / 2f;
    else
        title.y = 16 + (topRegion - title.height() - 16) / 2f;
    align(title);
    placeTorch(title.x + 22, title.y + 46);
    placeTorch(title.x + title.width - 22, title.y + 46);
    Image signs = new Image(BannerSprites.get(BannerSprites.Type.PIXEL_DUNGEON_SIGNS)) {

        private float time = 0;

        @Override
        public void update() {
            super.update();
            am = Math.max(0f, (float) Math.sin(time += Game.elapsed));
            if (time >= 1.5f * Math.PI)
                time = 0;
        }

        @Override
        public void draw() {
            Blending.setLightMode();
            super.draw();
            Blending.setNormalMode();
        }
    };
    signs.x = title.x + (title.width() - signs.width()) / 2f;
    signs.y = title.y;
    add(signs);
    DashboardItem btnBadges = new DashboardItem(Messages.get(this, "badges"), 3) {

        @Override
        protected void onClick() {
            ShatteredPixelDungeon.switchNoFade(BadgesScene.class);
        }
    };
    add(btnBadges);
    DashboardItem btnAbout = new DashboardItem(Messages.get(this, "about"), 1) {

        @Override
        protected void onClick() {
            ShatteredPixelDungeon.switchNoFade(AboutScene.class);
        }
    };
    add(btnAbout);
    DashboardItem btnPlay = new DashboardItem(Messages.get(this, "play"), 0) {

        @Override
        protected void onClick() {
            if (GamesInProgress.checkAll().size() == 0) {
                TitleScene.this.add(new WndStartGame(1));
            } else {
                ShatteredPixelDungeon.switchNoFade(StartScene.class);
            }
        }
    };
    add(btnPlay);
    DashboardItem btnRankings = new DashboardItem(Messages.get(this, "rankings"), 2) {

        @Override
        protected void onClick() {
            ShatteredPixelDungeon.switchNoFade(RankingsScene.class);
        }
    };
    add(btnRankings);
    if (SPDSettings.landscape()) {
        btnRankings.setPos(w / 2 - btnRankings.width(), topRegion);
        btnBadges.setPos(w / 2, topRegion);
        btnPlay.setPos(btnRankings.left() - btnPlay.width(), topRegion);
        btnAbout.setPos(btnBadges.right(), topRegion);
    } else {
        btnPlay.setPos(w / 2 - btnPlay.width(), topRegion);
        btnRankings.setPos(w / 2, btnPlay.top());
        btnBadges.setPos(w / 2 - btnBadges.width(), btnPlay.top() + DashboardItem.SIZE);
        btnAbout.setPos(w / 2, btnBadges.top());
    }
    BitmapText version = new BitmapText("v " + Game.version + "", pixelFont);
    version.measure();
    version.hardlight(0xCCCCCC);
    version.x = w - version.width();
    version.y = h - version.height();
    add(version);
    Button changes = new ChangesButton();
    changes.setPos(w - changes.width(), h - version.height() - changes.height());
    add(changes);
    int pos = 0;
    PrefsButton btnPrefs = new PrefsButton();
    btnPrefs.setRect(pos, 0, 16, 16);
    add(btnPrefs);
    pos += btnPrefs.width();
    LanguageButton btnLang = new LanguageButton();
    btnLang.setRect(pos, 0, 14, 16);
    add(btnLang);
    ExitButton btnExit = new ExitButton();
    btnExit.setPos(w - btnExit.width(), 0);
    add(btnExit);
    UpdateNotification updInfo = new UpdateNotification();
    updInfo.setPos(0, h - updInfo.height());
    add(updInfo);
    fadeIn();
}
Also used : LanguageButton(com.shatteredpixel.shatteredpixeldungeon.ui.LanguageButton) UpdateNotification(com.shatteredpixel.shatteredpixeldungeon.ui.UpdateNotification) ExitButton(com.shatteredpixel.shatteredpixeldungeon.ui.ExitButton) ChangesButton(com.shatteredpixel.shatteredpixeldungeon.ui.ChangesButton) Image(com.watabou.noosa.Image) WndStartGame(com.shatteredpixel.shatteredpixeldungeon.windows.WndStartGame) Archs(com.shatteredpixel.shatteredpixeldungeon.ui.Archs) BitmapText(com.watabou.noosa.BitmapText) PrefsButton(com.shatteredpixel.shatteredpixeldungeon.ui.PrefsButton) ExitButton(com.shatteredpixel.shatteredpixeldungeon.ui.ExitButton) ChangesButton(com.shatteredpixel.shatteredpixeldungeon.ui.ChangesButton) LanguageButton(com.shatteredpixel.shatteredpixeldungeon.ui.LanguageButton) Button(com.watabou.noosa.ui.Button) PrefsButton(com.shatteredpixel.shatteredpixeldungeon.ui.PrefsButton)

Aggregations

Archs (com.shatteredpixel.shatteredpixeldungeon.ui.Archs)7 ExitButton (com.shatteredpixel.shatteredpixeldungeon.ui.ExitButton)6 RenderedText (com.watabou.noosa.RenderedText)5 Image (com.watabou.noosa.Image)4 Badges (com.shatteredpixel.shatteredpixeldungeon.Badges)1 GamesInProgress (com.shatteredpixel.shatteredpixeldungeon.GamesInProgress)1 Rankings (com.shatteredpixel.shatteredpixeldungeon.Rankings)1 Flare (com.shatteredpixel.shatteredpixeldungeon.effects.Flare)1 Ankh (com.shatteredpixel.shatteredpixeldungeon.items.Ankh)1 DewVial (com.shatteredpixel.shatteredpixeldungeon.items.DewVial)1 Honeypot (com.shatteredpixel.shatteredpixeldungeon.items.Honeypot)1 Stylus (com.shatteredpixel.shatteredpixeldungeon.items.Stylus)1 Torch (com.shatteredpixel.shatteredpixeldungeon.items.Torch)1 PlateArmor (com.shatteredpixel.shatteredpixeldungeon.items.armor.PlateArmor)1 CloakOfShadows (com.shatteredpixel.shatteredpixeldungeon.items.artifacts.CloakOfShadows)1 DriedRose (com.shatteredpixel.shatteredpixeldungeon.items.artifacts.DriedRose)1 EtherealChains (com.shatteredpixel.shatteredpixeldungeon.items.artifacts.EtherealChains)1 HornOfPlenty (com.shatteredpixel.shatteredpixeldungeon.items.artifacts.HornOfPlenty)1 TalismanOfForesight (com.shatteredpixel.shatteredpixeldungeon.items.artifacts.TalismanOfForesight)1 TimekeepersHourglass (com.shatteredpixel.shatteredpixeldungeon.items.artifacts.TimekeepersHourglass)1