v0.3.0: refactored beam effects, added Light Ray effect.

This commit is contained in:
Evan Debenham
2015-04-10 12:04:44 -04:00
parent 7cce41e650
commit 6bda20b7b7
5 changed files with 40 additions and 24 deletions
@@ -27,16 +27,16 @@ import com.watabou.noosa.audio.Sample;
import com.shatteredpixel.shatteredpixeldungeon.Assets;
import com.watabou.utils.PointF;
public class DeathRay extends Image {
public class Beam extends Image {
private static final double A = 180 / Math.PI;
private static final float DURATION = 0.5f;
private float duration;
private float timeLeft;
public DeathRay( PointF s, PointF e ) {
super( Effects.get( Effects.Type.RAY ) );
private Beam(PointF s, PointF e, Effects.Type asset, float duration) {
super( Effects.get( asset ) );
origin.set( 0, height / 2 );
@@ -50,14 +50,26 @@ public class DeathRay extends Image {
Sample.INSTANCE.play( Assets.SND_RAY );
timeLeft = DURATION;
timeLeft = this.duration = duration;
}
public static class DeathRay extends Beam{
public DeathRay(PointF s, PointF e){
super(s, e, Effects.Type.DEATH_RAY, 0.5f);
}
}
public static class LightRay extends Beam{
public LightRay(PointF s, PointF e){
super(s, e, Effects.Type.LIGHT_RAY, 1f);
}
}
@Override
public void update() {
super.update();
float p = timeLeft / DURATION;
float p = timeLeft / duration;
alpha( p );
scale.set( scale.x, p );
@@ -26,24 +26,28 @@ public class Effects {
RIPPLE,
LIGHTNING,
WOUND,
RAY
DEATH_RAY,
LIGHT_RAY
};
public static Image get( Type type ) {
Image icon = new Image( Assets.EFFECTS );
switch (type) {
case RIPPLE:
icon.frame( icon.texture.uvRect( 0, 0, 16, 16 ) );
break;
case LIGHTNING:
icon.frame( icon.texture.uvRect( 16, 0, 32, 8 ) );
break;
case WOUND:
icon.frame( icon.texture.uvRect( 16, 8, 32, 16 ) );
break;
case RAY:
icon.frame( icon.texture.uvRect( 16, 16, 32, 24 ) );
break;
case RIPPLE:
icon.frame(icon.texture.uvRect(0, 0, 16, 16));
break;
case LIGHTNING:
icon.frame(icon.texture.uvRect(16, 0, 32, 8));
break;
case WOUND:
icon.frame(icon.texture.uvRect(16, 8, 32, 16));
break;
case DEATH_RAY:
icon.frame(icon.texture.uvRect(16, 16, 32, 24));
break;
case LIGHT_RAY:
icon.frame(icon.texture.uvRect(16, 23, 32, 31));
break;
}
return icon;
}