Java Code Examples for com.watabou.utils.PointF#inter()

The following examples show how to use com.watabou.utils.PointF#inter() . 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: ScaleTweener.java    From YetAnotherPixelDungeon with GNU General Public License v3.0 4 votes vote down vote up
@Override
protected void updateValues( float progress ) {
	visual.scale = PointF.inter( start, end, progress );
}
 
Example 2
Source File: CameraScrollTweener.java    From YetAnotherPixelDungeon with GNU General Public License v3.0 4 votes vote down vote up
@Override
protected void updateValues( float progress ) {
	camera.scroll = PointF.inter( start, end, progress );
}
 
Example 3
Source File: ScaleTweener.java    From shattered-pixel-dungeon with GNU General Public License v3.0 4 votes vote down vote up
@Override
protected void updateValues( float progress ) {
	visual.scale = PointF.inter( start, end, progress );
}
 
Example 4
Source File: CameraScrollTweener.java    From shattered-pixel-dungeon with GNU General Public License v3.0 4 votes vote down vote up
@Override
protected void updateValues( float progress ) {
	camera.scroll = PointF.inter( start, end, progress );
}
 
Example 5
Source File: ConeAOE.java    From shattered-pixel-dungeon with GNU General Public License v3.0 4 votes vote down vote up
public ConeAOE( int from, int to, float maxDist, float degrees, int ballisticaParams ){

		//we want to use true coordinates for our trig functions, not game cells
		// so get the center of from and to as points
		PointF fromP = new PointF(Dungeon.level.cellToPoint(from));
		fromP.x += 0.5f;
		fromP.y += 0.5f;
		PointF toP = new PointF(Dungeon.level.cellToPoint(to));
		toP.x += 0.5f;
		toP.y += 0.5f;

		//clamp distance of cone to maxDist (in true distance, not game distance)
		if (PointF.distance(fromP, toP) > maxDist){
			toP = PointF.inter(fromP, toP, maxDist/PointF.distance(fromP, toP) );
		}

		//now we can get the circle's radius. We bump it by 0.5 as we want the cone to reach
		// The edge of the target cell, not the center.
		float circleRadius = PointF.distance(fromP, toP);
		circleRadius += 0.5f;

		//Now we find every unique cell along the outer arc of our cone.
		PointF scan = new PointF();
		Point scanInt = new Point();
		float initalAngle = PointF.angle(fromP, toP)/PointF.G2R;
		//want to preserve order so that our collection of rays is going clockwise
		LinkedHashSet<Integer> targetCells = new LinkedHashSet<>();

		//cast a ray every 0.5 degrees in a clockwise arc, to find cells along the cone's outer arc
		for (float a = initalAngle+degrees/2f; a >= initalAngle-degrees/2f; a-=0.5f){
			scan.polar(a * PointF.G2R, circleRadius);
			scan.offset(fromP);
			scan.x += (fromP.x > scan.x ? +0.5f : -0.5f);
			scan.y += (fromP.y > scan.y ? +0.5f : -0.5f);
			scanInt.set(
					(int)GameMath.gate(0, (int)Math.floor(scan.x), Dungeon.level.width()-1),
					(int)GameMath.gate(0, (int)Math.floor(scan.y), Dungeon.level.height()-1));
			targetCells.add(Dungeon.level.pointToCell(scanInt));
			//if the cone is large enough, also cast rays to cells just inside of the outer arc
			// this helps fill in any holes when casting rays
			if (circleRadius >= 7) {
				scan.polar(a * PointF.G2R, circleRadius - 1);
				scan.offset(fromP);
				scan.x += (fromP.x > scan.x ? +0.5f : -0.5f);
				scan.y += (fromP.y > scan.y ? +0.5f : -0.5f);
				scanInt.set(
						(int)GameMath.gate(0, (int)Math.floor(scan.x), Dungeon.level.width()-1),
						(int)GameMath.gate(0, (int)Math.floor(scan.y), Dungeon.level.height()-1));
				targetCells.add(Dungeon.level.pointToCell(scanInt));
			}
		}

		//cast a ray to each found cell, these make up the cone
		for( int c : targetCells ){
			Ballistica ray = new Ballistica(from, c, ballisticaParams);
			cells.addAll(ray.subPath(1, ray.dist));
			rays.add(ray);
		}

	}
 
Example 6
Source File: ScaleTweener.java    From PD-classes with GNU General Public License v3.0 4 votes vote down vote up
@Override
protected void updateValues( float progress ) {
	visual.scale = PointF.inter( start, end, progress );
}
 
Example 7
Source File: CameraScrollTweener.java    From PD-classes with GNU General Public License v3.0 4 votes vote down vote up
@Override
protected void updateValues( float progress ) {
	camera.scroll = PointF.inter( start, end, progress );
}
 
Example 8
Source File: ScaleTweener.java    From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 4 votes vote down vote up
@Override
protected void updateValues( float progress ) {
	visual.scale = PointF.inter( start, end, progress );
}
 
Example 9
Source File: CameraScrollTweener.java    From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 4 votes vote down vote up
@Override
protected void updateValues( float progress ) {
	camera.scroll = PointF.inter( start, end, progress );
}