com.watabou.utils.PointF Java Examples

The following examples show how to use com.watabou.utils.PointF. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SpiderWeb.java    From YetAnotherPixelDungeon with GNU General Public License v3.0 6 votes vote down vote up
public void trigger() {

            parent.add(new ScaleTweener( this, new PointF(2, 2), ANIM_TIME ) {
                @Override
                protected void onComplete() {

                    WebbingSprite.this.killAndErase();
                    parent.erase( this );

                }

                @Override
                protected void updateValues(float progress) {
                    super.updateValues(progress);
                    am = 1 - progress;
                }
            });
        }
 
Example #2
Source File: CellSelector.java    From unleashed-pixel-dungeon with GNU General Public License v3.0 6 votes vote down vote up
@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;
	} else if (t != touch) {
		reset();
	}
}
 
Example #3
Source File: TerrainFeaturesTilemap.java    From shattered-pixel-dungeon with GNU General Public License v3.0 6 votes vote down vote up
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);
		}
	} );
}
 
Example #4
Source File: Compass.java    From unleashed-pixel-dungeon with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void update() {
	super.update();
	
	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;
		}
	}
}
 
Example #5
Source File: Bleeding.java    From remixed-dungeon with GNU General Public License v3.0 6 votes vote down vote up
@Override
public boolean act() {
	if (target.isAlive()) {
		
		if ((level = Random.Int( level / 2, level )) > 0) {
			
			target.damage( level, this );
			if (target.getSprite().getVisible()) {
				Splash.at( target.getSprite().center(), -PointF.PI / 2, PointF.PI / 6, 
						target.getSprite().blood(), Math.min( 10 * level / target.ht(), 10 ) );
			}
			
			if (target == Dungeon.hero && !target.isAlive()) {
				Dungeon.fail( Utils.format( ResultDescriptions.getDescription(ResultDescriptions.Reason.BLEEDING), Dungeon.depth ) );
				GLog.n(Game.getVar(R.string.Bleeding_Death));
			}
			
			spend( TICK );
		} else {
			detach();
		}
	} else {
		detach();
	}
	return true;
}
 
Example #6
Source File: IceVein.java    From remixed-dungeon with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void update() {

    if (setVisible(Dungeon.visible[pos])) {

        super.update();

        if ((delay -= Game.elapsed) <= 0) {

            delay = Random.Float();

            PointF p = DungeonTilemap.tileToWorld( pos );
            ((IceSparkle)recycle( IceSparkle.class )).reset(
                p.x + Random.Float( DungeonTilemap.SIZE ),
                p.y + Random.Float( DungeonTilemap.SIZE ) );
        }
    }
}
 
Example #7
Source File: Chains.java    From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void update() {
	if ((spent += Game.elapsed) > duration) {

		killAndErase();
		if (callback != null) {
			callback.call();
		}

	} else {
		float dx = to.x - from.x;
		float dy = to.y - from.y;
		for (int i = 0; i < chains.length; i++) {
			chains[i].center(new PointF(
					from.x + ((dx * (i / (float)chains.length)) * (spent/duration)),
					from.y + ((dy * (i / (float)chains.length)) * (spent/duration))
			));
		}
	}
}
 
Example #8
Source File: LevelObjectSprite.java    From remixed-dungeon with GNU General Public License v3.0 6 votes vote down vote up
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.f, -(ys-DungeonTilemap.SIZE) / 2.f);
	origin.set(xs / 2.f, ys / 2.f);

	reset(object.image());
	alpha(1f);

	setLevelPos(object.getPos());
	setVisible(!object.secret());

	object.resetVisualState();
}
 
Example #9
Source File: BitmapTextMultiline.java    From remixed-dungeon with GNU General Public License v3.0 6 votes vote down vote up
private void getWordMetrics( String word, PointF metrics ) {
	
	float w = 0;
	float h = 0;
	
	int length = word.length();
	for (int i=0; i < length; i++) {
		
		RectF rect = font.get( word.charAt( i ) );
		//Corrigido
		if (rect == null) {
			rect = font.get(INVALID_CHAR);
		}
		w += font.width( rect ) + (w > 0 ? font.tracking : 0);
		
		h = Math.max( h, font.height( rect ) + glyphShiftY(word.charAt( i )));
	}
	
	metrics.set( w, h );
}
 
Example #10
Source File: MobSprite.java    From YetAnotherPixelDungeon with GNU General Public License v3.0 6 votes vote down vote up
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;
           }
       });
}
 
Example #11
Source File: MobSprite.java    From pixel-dungeon with GNU General Public License v3.0 6 votes vote down vote up
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;
		}
	} );
}
 
Example #12
Source File: CharSprite.java    From shattered-pixel-dungeon with GNU General Public License v3.0 5 votes vote down vote up
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 );
	}
}
 
Example #13
Source File: Visual.java    From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 5 votes vote down vote up
public boolean overlapsScreenPoint( int x, int y ) {
	Camera c = camera();

	if (c == null) return false;

	PointF p = c.screenToCamera( x, y );
	return overlapsPoint( p.x, p.y );
}
 
Example #14
Source File: Identification.java    From pixel-dungeon with GNU General Public License v3.0 5 votes vote down vote up
public Identification( PointF p ) {
	
	for (int i=0; i < DOTS.length; i += 2) {
		add( new Speck( p.x, p.y, DOTS[i], DOTS[i+1] ) );
		add( new Speck( p.x, p.y, DOTS[i], DOTS[i+1] ) );
	}
}
 
Example #15
Source File: Splash.java    From remixed-dungeon with GNU General Public License v3.0 5 votes vote down vote up
public static void at( PointF p, final int color, int n ) {
	
	if (n <= 0) {
		return;
	}
	
	Emitter emitter = GameScene.emitter();
	emitter.pos( p );
	
	FACTORY.color = color;
	FACTORY.dir = -3.1415926f / 2;
	FACTORY.cone = 3.1415926f;
	emitter.burst( FACTORY, n );
}
 
Example #16
Source File: Degradation.java    From shattered-pixel-dungeon with GNU General Public License v3.0 5 votes vote down vote up
private Degradation( PointF p, int[] matrix ) {
	
	for (int i=0; i < matrix.length; i += 2) {
		add( new Speck( p.x, p.y, matrix[i], matrix[i+1] ) );
		add( new Speck( p.x, p.y, matrix[i], matrix[i+1] ) );
	}
}
 
Example #17
Source File: Splash.java    From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 5 votes vote down vote up
public static void at( PointF p, final int color, int n ) {
	
	if (n <= 0) {
		return;
	}
	
	Emitter emitter = GameScene.emitter();
	emitter.pos( p );
	
	FACTORY.color = color;
	FACTORY.dir = -3.1415926f / 2;
	FACTORY.cone = 3.1415926f;
	emitter.burst( FACTORY, n );
}
 
Example #18
Source File: Degradation.java    From unleashed-pixel-dungeon with GNU General Public License v3.0 5 votes vote down vote up
private Degradation( PointF p, int[] matrix ) {
	
	for (int i=0; i < matrix.length; i += 2) {
		add( new Speck( p.x, p.y, matrix[i], matrix[i+1] ) );
		add( new Speck( p.x, p.y, matrix[i], matrix[i+1] ) );
	}
}
 
Example #19
Source File: CharSprite.java    From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 5 votes vote down vote up
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 );
	}
}
 
Example #20
Source File: FlowParticle.java    From shattered-pixel-dungeon with GNU General Public License v3.0 5 votes vote down vote up
public Flow( int pos ) {
	super();
	
	this.pos = pos;
	
	PointF p = DungeonTilemap.tileToWorld( pos );
	x = p.x;
	y = p.y + DungeonTilemap.SIZE - 1;
	
	delay = Random.Float( DELAY );
}
 
Example #21
Source File: Splash.java    From pixel-dungeon with GNU General Public License v3.0 5 votes vote down vote up
public static void at( PointF p, final int color, int n ) {
	
	if (n <= 0) {
		return;
	}
	
	Emitter emitter = GameScene.emitter();
	emitter.pos( p );
	
	FACTORY.color = color;
	FACTORY.dir = -3.1415926f / 2;
	FACTORY.cone = 3.1415926f;
	emitter.burst( FACTORY, n );
}
 
Example #22
Source File: ScrollPane.java    From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void onDrag( NoosaInputProcessor.Touch t ) {
	if (dragging) {

		doScroll(t.current);

	} else if (PointF.distance( t.current, t.start ) > dragThreshold) {

		dragging = true;
		lastPos.set( t.current );
		thumb.am = 1;

	}
}
 
Example #23
Source File: MagicMissile.java    From shattered-pixel-dungeon with GNU General Public License v3.0 5 votes vote down vote up
public void reset( int index, float x, float y ) {
	super.reset( x, y, 0xFFFFFF, 8, 0.5f );

	speed.polar( PointF.PI2 / 8 * index, 12 );
	this.x -= speed.x * lifespan;
	this.y -= speed.y * lifespan;
}
 
Example #24
Source File: CharSprite.java    From pixel-dungeon with GNU General Public License v3.0 5 votes vote down vote up
public JumpTweener( Visual visual, PointF pos, float height, float time ) {
	super( visual, time );
	
	this.visual = visual;
	start = visual.point();
	end = pos;

	this.height = height;
}
 
Example #25
Source File: ShadowParticle.java    From remixed-dungeon with GNU General Public License v3.0 5 votes vote down vote up
public void resetCurse( float x, float y ) {
	revive();
	
	size = 8;
	left = lifespan = 0.5f;
	
	speed.polar( Random.Float( 2 * PointF.PI ), Random.Float( 16, 32 ) );
	this.x = x - speed.x * lifespan;
	this.y = y - speed.y * lifespan;
}
 
Example #26
Source File: CameraScrollTweener.java    From shattered-pixel-dungeon with GNU General Public License v3.0 5 votes vote down vote up
public CameraScrollTweener( Camera camera, PointF pos, float time ) {
	super( camera, time );
	
	this.camera = camera;
	start = camera.scroll;
	end = pos;
}
 
Example #27
Source File: GooSprite.java    From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 5 votes vote down vote up
public void reset( float x, float y ) {
	revive();

	this.x = x;
	this.y = y;

	left = lifespan;

	size = 4;
	speed.polar( -Random.Float( PointF.PI ), Random.Float( 32, 48 ) );
}
 
Example #28
Source File: AcidParticle.java    From YetAnotherPixelDungeon with GNU General Public License v3.0 5 votes vote down vote up
public void resetBurst( float x, float y ) {
    revive();

    this.x = x;
    this.y = y;

    size = 3;
    speed.polar( Random.Float( PointF.PI2 ), Random.Float( 16, 32 ) );

    left = lifespan;
}
 
Example #29
Source File: CircleArc.java    From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 5 votes vote down vote up
public CircleArc show(Group parent, PointF pos, float duration ) {
	point( pos );
	parent.add( this );
	
	lifespan = this.duration = duration;
	
	return this;
}
 
Example #30
Source File: ShadowParticle.java    From YetAnotherPixelDungeon with GNU General Public License v3.0 5 votes vote down vote up
public void resetCurse( float x, float y ) {
	revive();
	
	size = 8;
	left = lifespan = 0.5f;
	
	speed.polar( Random.Float( PointF.PI2 ), Random.Float( 16, 32 ) );
	this.x = x - speed.x * lifespan;
	this.y = y - speed.y * lifespan;
}