Search in sources :

Example 6 with PointF

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

the class BitmapTextMultiline method updateVertices.

@Override
protected void updateVertices() {
    if (text == null) {
        text = "";
    }
    quads = Quad.createSet(text.length());
    realLength = 0;
    // This object controls lines breaking
    SymbolWriter writer = new SymbolWriter();
    // Word size
    PointF metrics = new PointF();
    String[] paragraphs = PARAGRAPH.split(text);
    // Current character (used in masking)
    int pos = 0;
    for (int i = 0; i < paragraphs.length; i++) {
        String[] words = WORD.split(paragraphs[i]);
        for (int j = 0; j < words.length; j++) {
            String word = words[j];
            if (word.length() == 0) {
                // several spaces coming along
                continue;
            }
            getWordMetrics(word, metrics);
            writer.addSymbol(metrics.x, metrics.y);
            int length = word.length();
            // Position in pixels relative to the beginning of the word
            float shift = 0;
            for (int k = 0; k < length; k++) {
                RectF rect = font.get(word.charAt(k));
                float w = font.width(rect);
                float h = font.height(rect);
                if (mask == null || mask[pos]) {
                    vertices[0] = writer.x + shift;
                    vertices[1] = writer.y;
                    vertices[2] = rect.left;
                    vertices[3] = rect.top;
                    vertices[4] = writer.x + shift + w;
                    vertices[5] = writer.y;
                    vertices[6] = rect.right;
                    vertices[7] = rect.top;
                    vertices[8] = writer.x + shift + w;
                    vertices[9] = writer.y + h;
                    vertices[10] = rect.right;
                    vertices[11] = rect.bottom;
                    vertices[12] = writer.x + shift;
                    vertices[13] = writer.y + h;
                    vertices[14] = rect.left;
                    vertices[15] = rect.bottom;
                    quads.put(vertices);
                    realLength++;
                }
                shift += w + font.tracking;
                pos++;
            }
            writer.addSpace(spaceSize);
        }
        writer.newLine(0, font.lineHeight);
    }
    nLines = writer.nLines();
    dirty = false;
}
Also used : RectF(com.watabou.utils.RectF) PointF(com.watabou.utils.PointF)

Example 7 with PointF

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

the class ShockingDart method proc.

@Override
public int proc(Char attacker, Char defender, int damage) {
    defender.damage(Random.NormalIntRange(8, 12), this);
    CharSprite s = defender.sprite;
    ArrayList<Lightning.Arc> arcs = new ArrayList<>();
    arcs.add(new Lightning.Arc(new PointF(s.x, s.y + s.height / 2), new PointF(s.x + s.width, s.y + s.height / 2)));
    arcs.add(new Lightning.Arc(new PointF(s.x + s.width / 2, s.y), new PointF(s.x + s.width / 2, s.y + s.height)));
    defender.sprite.parent.add(new Lightning(arcs, null));
    return super.proc(attacker, defender, damage);
}
Also used : Lightning(com.shatteredpixel.shatteredpixeldungeon.effects.Lightning) PointF(com.watabou.utils.PointF) ArrayList(java.util.ArrayList) CharSprite(com.shatteredpixel.shatteredpixeldungeon.sprites.CharSprite)

Example 8 with PointF

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

the class BadgeBanner method highlight.

public static void highlight(Image image, int index) {
    PointF p = new PointF();
    switch(index) {
        case 0:
        case 1:
        case 2:
        case 3:
            p.offset(7, 3);
            break;
        case 4:
        case 5:
        case 6:
        case 7:
            p.offset(6, 5);
            break;
        case 8:
        case 9:
        case 10:
        case 11:
            p.offset(6, 3);
            break;
        case 12:
        case 13:
        case 14:
        case 15:
            p.offset(7, 4);
            break;
        case 16:
            p.offset(6, 3);
            break;
        case 17:
            p.offset(5, 4);
            break;
        case 18:
            p.offset(7, 3);
            break;
        case 20:
            p.offset(7, 3);
            break;
        case 21:
            p.offset(7, 3);
            break;
        case 22:
            p.offset(6, 4);
            break;
        case 23:
            p.offset(4, 5);
            break;
        case 24:
            p.offset(6, 4);
            break;
        case 25:
            p.offset(6, 5);
            break;
        case 26:
            p.offset(5, 5);
            break;
        case 27:
            p.offset(6, 4);
            break;
        case 28:
            p.offset(3, 5);
            break;
        case 29:
            p.offset(5, 4);
            break;
        case 30:
            p.offset(5, 4);
            break;
        case 31:
            p.offset(5, 5);
            break;
        case 32:
        case 33:
            p.offset(7, 4);
            break;
        case 34:
            p.offset(6, 4);
            break;
        case 35:
            p.offset(6, 4);
            break;
        case 36:
            p.offset(6, 5);
            break;
        case 37:
            p.offset(4, 4);
            break;
        case 38:
            p.offset(5, 5);
            break;
        case 39:
            p.offset(5, 4);
            break;
        case 40:
        case 41:
        case 42:
        case 43:
            p.offset(5, 4);
            break;
        case 44:
        case 45:
        case 46:
        case 47:
            p.offset(5, 5);
            break;
        case 48:
        case 49:
        case 50:
        case 51:
            p.offset(7, 4);
            break;
        case 52:
        case 53:
        case 54:
        case 55:
            p.offset(4, 4);
            break;
        case 56:
            p.offset(3, 7);
            break;
        case 57:
            p.offset(4, 5);
            break;
        case 58:
            p.offset(6, 4);
            break;
        case 59:
            p.offset(7, 4);
            break;
        case 60:
        case 61:
        case 62:
        case 63:
            p.offset(4, 4);
            break;
    }
    p.x *= image.scale.x;
    p.y *= image.scale.y;
    p.offset(-image.origin.x * (image.scale.x - 1), -image.origin.y * (image.scale.y - 1));
    p.offset(image.point());
    Speck star = new Speck();
    star.reset(0, p.x, p.y, Speck.DISCOVER);
    star.camera = image.camera();
    image.parent.add(star);
}
Also used : PointF(com.watabou.utils.PointF)

Example 9 with PointF

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

the class CellEmitter method get.

public static Emitter get(int cell) {
    PointF p = DungeonTilemap.tileToWorld(cell);
    Emitter emitter = GameScene.emitter();
    emitter.pos(p.x, p.y, DungeonTilemap.SIZE, DungeonTilemap.SIZE);
    return emitter;
}
Also used : Emitter(com.watabou.noosa.particles.Emitter) PointF(com.watabou.utils.PointF)

Example 10 with PointF

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

the class CellEmitter method bottom.

public static Emitter bottom(int cell) {
    PointF p = DungeonTilemap.tileToWorld(cell);
    Emitter emitter = GameScene.emitter();
    emitter.pos(p.x, p.y + DungeonTilemap.SIZE, DungeonTilemap.SIZE, 0);
    return emitter;
}
Also used : Emitter(com.watabou.noosa.particles.Emitter) 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