public void reset( int from, int to, Callback callback ) { this.callback = callback; revive(); PointF pf = DungeonTilemap.tileCenterToWorld( from ); PointF pt = DungeonTilemap.tileCenterToWorld( to ); x = pf.x; y = pf.y; width = 0; height = 0; PointF d = PointF.diff( pt, pf ); PointF speed = new PointF( d ).normalize().scale( SPEED ); sx = speed.x; sy = speed.y; time = d.length() / SPEED; }
@Override protected void updateValues( float progress ) { visual.scale = PointF.inter( start, end, progress ); } }
@Override protected void onDrag( Touch t ) { camera.target = null; if (pinching) { float curSpan = PointF.distance( touch.current, another.current ); float zoom = (startZoom * curSpan / startSpan); camera.zoom( GameMath.gate( PixelScene.minZoom, zoom - (zoom % 0.1f), PixelScene.maxZoom ) ); } else { if (!dragging && PointF.distance( t.current, t.start ) > dragThreshold) { dragging = true; lastPos.set( t.current ); } else if (dragging) { camera.scroll.offset( PointF.diff( lastPos, t.current ).invScale( camera.zoom ) ); lastPos.set( t.current ); } } }
public void reset( float x, float y ) { revive(); left = lifespan; super.speed.set( WindParticle.speed ); super.speed.scale( size ); this.x = x - super.speed.x * lifespan / 2; this.y = y - super.speed.y * lifespan / 2; angle += Random.Float( -0.1f, +0.1f ); speed = new PointF().polar( angle, 5 ); am = 0; }
public ShaftParticle() { super(); lifespan = 1.2f; speed.set( 0, -6 ); }
public PointF screenToCamera( int x, int y ) { return new PointF( (x - this.x) / zoom + scroll.x, (y - this.y) / zoom + scroll.y ); }
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; }
@Override public void staffFx(MagesStaff.StaffParticle particle) { particle.color(0x88CCFF); particle.am = 0.6f; particle.setLifespan(2f); float angle = Random.Float(PointF.PI2); particle.speed.polar( angle, 2f); particle.acc.set( 0f, 1f); particle.setSize( 0f, 1.5f); particle.radiateXY(Random.Float(1f)); }
public PointF normalize() { float l = length(); x /= l; y /= l; return this; }
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 ); } }
@Override protected void onTouchDown( Touch t ) { if (t != touch && another == null) { if (!touch.down) { touch = t; onTouchDown( t ); return; } pinching = true; another = t; startSpan = PointF.distance( touch.current, another.current ); startZoom = camera.zoom; dragging = false; } }
public void update( MotionEvent e, int index ) { float x = e.getX( index ); float y = e.getY( index ); x /= (Game.dispWidth / (float)Game.width); y /= (Game.dispHeight / (float)Game.height); current.set( x, y ); }
public static PointF tileCenterToWorld( int pos ) { return new PointF( (pos % Level.WIDTH + 0.5f) * SIZE, (pos / Level.WIDTH + 0.5f) * SIZE ); }
public void reset( float x, float y ) { revive(); left = lifespan; super.speed.set( WindParticle.speed ); super.speed.scale( size ); this.x = x - super.speed.x * lifespan / 2; this.y = y - super.speed.y * lifespan / 2; angle += Random.Float( -0.1f, +0.1f ); speed = new PointF().polar( angle, 5 ); am = 0; }