Search in sources :

Example 46 with PointF

use of com.watabou.utils.PointF in project shattered-pixel-dungeon-gdx by 00-Evan.

the class DungeonTilemap method screenToTile.

// wall assist is used to make raised perspective tapping a bit easier.
// If the pressed tile is a wall tile, the tap can be 'bumped' down into a none-wall tile.
// currently this happens if the bottom 1/4 of the wall tile is pressed.
public int screenToTile(int x, int y, boolean wallAssist) {
    PointF p = camera().screenToCamera(x, y).offset(this.point().negate()).invScale(SIZE);
    // snap to the edges of the tilemap
    p.x = GameMath.gate(0, p.x, Dungeon.level.width() - 0.001f);
    p.y = GameMath.gate(0, p.y, Dungeon.level.height() - 0.001f);
    int cell = (int) p.x + (int) p.y * Dungeon.level.width();
    if (wallAssist && map != null && DungeonTileSheet.wallStitcheable(map[cell])) {
        if (cell + mapWidth < size && p.y % 1 >= 0.75f && !DungeonTileSheet.wallStitcheable(map[cell + mapWidth])) {
            cell += mapWidth;
        }
    }
    return cell;
}
Also used : PointF(com.watabou.utils.PointF) Point(com.watabou.utils.Point)

Example 47 with PointF

use of com.watabou.utils.PointF in project shattered-pixel-dungeon-gdx by 00-Evan.

the class MobSprite method fall.

public void fall() {
    origin.set(width / 2, height - DungeonTilemap.SIZE / 2);
    angularSpeed = Random.Int(2) == 0 ? -720 : 720;
    parent.add(new ScaleTweener(this, new PointF(0, 0), FALL_TIME) {

        @Override
        protected void onComplete() {
            MobSprite.this.killAndErase();
            parent.erase(this);
        }

        @Override
        protected void updateValues(float progress) {
            super.updateValues(progress);
            am = 1 - progress;
        }
    });
}
Also used : ScaleTweener(com.watabou.noosa.tweeners.ScaleTweener) PointF(com.watabou.utils.PointF)

Example 48 with PointF

use of com.watabou.utils.PointF in project shattered-pixel-dungeon-gdx by 00-Evan.

the class MissileSprite method setup.

// TODO it might be nice to have a source and destination angle, to improve thrown weapon visuals
private void setup(PointF from, PointF to, Item item, Callback listener) {
    originToCenter();
    this.callback = listener;
    point(from);
    PointF d = PointF.diff(to, from);
    speed.set(d).normalize().scale(SPEED);
    angularSpeed = DEFAULT_ANGULAR_SPEED;
    for (Class<? extends Item> cls : ANGULAR_SPEEDS.keySet()) {
        if (cls.isAssignableFrom(item.getClass())) {
            angularSpeed = ANGULAR_SPEEDS.get(cls);
            break;
        }
    }
    angle = 135 - (float) (Math.atan2(d.x, d.y) / 3.1415926 * 180);
    if (d.x >= 0) {
        flipHorizontal = false;
        updateFrame();
    } else {
        angularSpeed = -angularSpeed;
        angle += 90;
        flipHorizontal = true;
        updateFrame();
    }
    float speed = SPEED;
    if (item instanceof Dart && Dungeon.hero.belongings.weapon instanceof Crossbow) {
        speed *= 3f;
    }
    PosTweener tweener = new PosTweener(this, to, d.length() / speed);
    tweener.listener = this;
    parent.add(tweener);
}
Also used : Crossbow(com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.Crossbow) PosTweener(com.watabou.noosa.tweeners.PosTweener) PointF(com.watabou.utils.PointF) Dart(com.shatteredpixel.shatteredpixeldungeon.items.weapon.missiles.darts.Dart)

Example 49 with PointF

use of com.watabou.utils.PointF in project pixel-dungeon-remix by NYRDS.

the class MissileSprite method reset.

public void reset(int from, int to, Item item, Callback listener) {
    revive();
    view(item);
    this.callback = listener;
    point(DungeonTilemap.tileToWorld(from));
    PointF dest = DungeonTilemap.tileToWorld(to);
    PointF d = PointF.diff(dest, point());
    speed.set(d).normalize().scale(SPEED);
    if (item.isFliesStraight()) {
        angularSpeed = 0;
        angle = 135 - (float) (Math.atan2(d.x, d.y) / 3.1415926 * 180);
    } else {
        angularSpeed = item.isFliesFastRotating() ? 1440 : 720;
    }
    PosTweener tweener = new PosTweener(this, dest, d.length() / SPEED);
    tweener.listener = this;
    getParent().add(tweener);
}
Also used : PosTweener(com.watabou.noosa.tweeners.PosTweener) PointF(com.watabou.utils.PointF)

Example 50 with PointF

use of com.watabou.utils.PointF in project pixel-dungeon-remix by NYRDS.

the class CharSprite method bloodBurstA.

public void bloodBurstA(PointF from, int damage) {
    if (getVisible()) {
        PointF c = center();
        int n = (int) Math.min(9 * Math.sqrt((double) damage / ch.ht()), 9);
        Splash.at(c, PointF.angle(from, c), 3.1415926f / 2, blood(), n);
    }
}
Also used : PointF(com.watabou.utils.PointF)

Aggregations

PointF (com.watabou.utils.PointF)56 Emitter (com.watabou.noosa.particles.Emitter)9 ScaleTweener (com.watabou.noosa.tweeners.ScaleTweener)5 Point (com.watabou.utils.Point)5 RectF (android.graphics.RectF)3 PosTweener (com.watabou.noosa.tweeners.PosTweener)3 ArrayList (java.util.ArrayList)2 Char (com.shatteredpixel.shatteredpixeldungeon.actors.Char)1 Lightning (com.shatteredpixel.shatteredpixeldungeon.effects.Lightning)1 Heap (com.shatteredpixel.shatteredpixeldungeon.items.Heap)1 Crossbow (com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.Crossbow)1 Dart (com.shatteredpixel.shatteredpixeldungeon.items.weapon.missiles.darts.Dart)1 Room (com.shatteredpixel.shatteredpixeldungeon.levels.rooms.Room)1 ConnectionRoom (com.shatteredpixel.shatteredpixeldungeon.levels.rooms.connection.ConnectionRoom)1 CharSprite (com.shatteredpixel.shatteredpixeldungeon.sprites.CharSprite)1 NoosaInputProcessor (com.watabou.input.NoosaInputProcessor)1 ColorBlock (com.watabou.noosa.ColorBlock)1 Image (com.watabou.noosa.Image)1 TextureFilm (com.watabou.noosa.TextureFilm)1 TouchArea (com.watabou.noosa.TouchArea)1