use of com.watabou.utils.PointF in project pixel-dungeon-remix by NYRDS.
the class BitmapText method updateVertices.
protected void updateVertices() {
width = 0;
height = 0;
quads = Quad.createSet(text.length());
realLength = 0;
int length = text.length();
for (int i = 0; i < length; i++) {
RectF rect = font.get(text.charAt(i));
if (rect == null) {
rect = font.get(INVALID_CHAR);
}
float w = font.width(rect);
float h = font.height(rect);
float sx = 0;
float sy = 0;
PointF sp = font.glyphShift.get(text.charAt(i));
if (sp != null) {
sx = sp.x;
sy = sp.y;
}
vertices[0] = width + sx;
vertices[1] = sy;
vertices[2] = rect.left;
vertices[3] = rect.top;
vertices[4] = width + w + sx;
vertices[5] = sy;
vertices[6] = rect.right;
vertices[7] = rect.top;
vertices[8] = width + w + sx;
vertices[9] = h + sy;
vertices[10] = rect.right;
vertices[11] = rect.bottom;
vertices[12] = width + sx;
vertices[13] = h + sy;
vertices[14] = rect.left;
vertices[15] = rect.bottom;
quads.put(vertices);
realLength++;
width += w + font.tracking;
if (h + sy > height) {
height = h + sy;
}
}
if (length > 0) {
width -= font.tracking;
}
dirty = false;
}
use of com.watabou.utils.PointF in project pixel-dungeon-remix by NYRDS.
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));
// Corrigido
if (rect == null) {
rect = font.get(INVALID_CHAR);
}
float sx = 0;
float sy = 0;
PointF sp = font.glyphShift.get(word.charAt(k));
if (sp != null) {
sx = sp.x;
sy = sp.y;
}
float w = font.width(rect);
float h = font.height(rect);
if (mask == null || mask[pos]) {
vertices[0] = writer.x + shift + sx;
vertices[1] = writer.y + sy;
vertices[2] = rect.left;
vertices[3] = rect.top;
vertices[4] = writer.x + shift + w + sx;
vertices[5] = writer.y + sy;
vertices[6] = rect.right;
vertices[7] = rect.top;
vertices[8] = writer.x + shift + w + sx;
vertices[9] = writer.y + h + sy;
vertices[10] = rect.right;
vertices[11] = rect.bottom;
vertices[12] = writer.x + shift + sx;
vertices[13] = writer.y + h + sy;
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);
}
dirty = false;
}
use of com.watabou.utils.PointF in project pixel-dungeon-remix by NYRDS.
the class Camera method updateFullscreenCameraZoom.
public void updateFullscreenCameraZoom(float zoom) {
width = (int) Math.ceil(Game.width() / zoom);
height = (int) Math.ceil(Game.height() / zoom);
x = (int) (Game.width() - width * zoom) / 2;
y = (int) (Game.height() - height * zoom) / 2;
this.zoom = zoom;
screenWidth = (int) (width * zoom);
screenHeight = (int) (height * zoom);
scroll = new PointF();
matrix = new float[16];
Matrix.setIdentity(matrix);
}
use of com.watabou.utils.PointF in project pixel-dungeon-remix by NYRDS.
the class LevelObjectSprite method reset.
public void reset(LevelObject object) {
revive();
texture(object.texture());
int xs = object.getSpriteXS();
int ys = object.getSpriteYS();
frames = new TextureFilm(texture, xs, ys);
centerShift = new PointF(-(xs - DungeonTilemap.SIZE) / 2, -(ys - DungeonTilemap.SIZE) / 2);
origin.set(xs / 2, ys / 2);
reset(object.image());
alpha(1f);
setLevelPos(object.getPos());
setVisible(!object.secret());
}
use of com.watabou.utils.PointF in project pixel-dungeon-remix by NYRDS.
the class Compass method update.
@Override
public void update() {
super.update();
if (level.hasCompassTarget()) {
setCell(level.getCompassTarget());
}
if (!level.cellValid(cell)) {
return;
}
if (!getVisible()) {
setVisible(level.visited[cell] || level.mapped[cell]);
}
if (getVisible()) {
PointF scroll = Camera.main.scroll;
if (!scroll.equals(lastScroll)) {
lastScroll.set(scroll);
PointF center = Camera.main.center().offset(scroll);
angle = (float) Math.atan2(cellCenter.x - center.x, center.y - cellCenter.y) * RAD_2_G;
}
}
}
Aggregations