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;
}
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;
}
});
}
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);
}
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);
}
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);
}
}
Aggregations