use of com.watabou.utils.PointF in project shattered-pixel-dungeon-gdx by 00-Evan.
the class CellSelector method onClick.
@Override
protected void onClick(NoosaInputProcessor.Touch touch) {
if (dragging) {
dragging = false;
} else {
PointF p = Camera.main.screenToCamera((int) touch.current.x, (int) touch.current.y);
for (Char mob : Dungeon.level.mobs.toArray(new Mob[0])) {
if (mob.sprite != null && mob.sprite.overlapsPoint(p.x, p.y)) {
select(mob.pos);
return;
}
}
for (Heap heap : Dungeon.level.heaps.values()) {
if (heap.sprite != null && heap.sprite.overlapsPoint(p.x, p.y)) {
select(heap.pos);
return;
}
}
select(((DungeonTilemap) target).screenToTile((int) touch.current.x, (int) touch.current.y, true));
}
}
use of com.watabou.utils.PointF in project shattered-pixel-dungeon-gdx by 00-Evan.
the class CharSprite method bloodBurstA.
public void bloodBurstA(PointF from, int damage) {
if (visible) {
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);
}
}
use of com.watabou.utils.PointF in project shattered-pixel-dungeon-gdx by 00-Evan.
the class OptionSlider method createChildren.
@Override
protected void createChildren() {
super.createChildren();
add(BG = Chrome.get(Chrome.Type.BUTTON));
BG.alpha(0.5f);
add(title = PixelScene.renderText(9));
add(this.minTxt = PixelScene.renderText(6));
add(this.maxTxt = PixelScene.renderText(6));
add(sliderBG = new ColorBlock(1, 1, 0xFF222222));
sliderNode = Chrome.get(Chrome.Type.BUTTON);
sliderNode.size(5, 9);
touchArea = new TouchArea(0, 0, 0, 0) {
boolean pressed = false;
@Override
protected void onTouchDown(NoosaInputProcessor.Touch touch) {
pressed = true;
PointF p = camera().screenToCamera((int) touch.current.x, (int) touch.current.y);
sliderNode.x = GameMath.gate(sliderBG.x - 2, p.x, sliderBG.x + sliderBG.width() - 2);
sliderNode.brightness(1.5f);
}
@Override
protected void onDrag(NoosaInputProcessor.Touch touch) {
if (pressed) {
PointF p = camera().screenToCamera((int) touch.current.x, (int) touch.current.y);
sliderNode.x = GameMath.gate(sliderBG.x - 2, p.x, sliderBG.x + sliderBG.width() - 2);
}
}
@Override
protected void onTouchUp(NoosaInputProcessor.Touch touch) {
if (pressed) {
PointF p = camera().screenToCamera((int) touch.current.x, (int) touch.current.y);
sliderNode.x = GameMath.gate(sliderBG.x - 2, p.x, sliderBG.x + sliderBG.width() - 2);
sliderNode.resetColor();
// sets the selected value
selectedVal = minVal + Math.round(sliderNode.x / tickDist);
sliderNode.x = (int) (x + tickDist * (selectedVal - minVal));
onChange();
pressed = false;
}
}
};
add(touchArea);
}
use of com.watabou.utils.PointF in project shattered-pixel-dungeon-gdx by 00-Evan.
the class TerrainFeaturesTilemap method growPlant.
public void growPlant(final int pos) {
final Image plant = tile(pos, map[pos]);
if (plant == null)
return;
plant.origin.set(8, 12);
plant.scale.set(0);
plant.point(DungeonTilemap.tileToWorld(pos));
parent.add(plant);
parent.add(new ScaleTweener(plant, new PointF(1, 1), 0.2f) {
protected void onComplete() {
plant.killAndErase();
killAndErase();
updateMapCell(pos);
}
});
}
use of com.watabou.utils.PointF in project shattered-pixel-dungeon-gdx by 00-Evan.
the class Compass method update.
@Override
public void update() {
super.update();
if (cell < 0 || cell >= Dungeon.level.length()) {
visible = false;
return;
}
if (!visible) {
visible = Dungeon.level.visited[cell] || Dungeon.level.mapped[cell];
}
if (visible) {
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