V0.1.0 Partial Commit

changed package and application names to differentiate from main PD
release
This commit is contained in:
Evan Debenham
2014-08-03 14:46:22 -04:00
parent 65dd9c2dc0
commit aed303672a
474 changed files with 3468 additions and 3458 deletions
@@ -0,0 +1,284 @@
/*
* Pixel Dungeon
* Copyright (C) 2012-2014 Oleg Dolya
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.effects;
import com.watabou.noosa.Game;
import com.watabou.noosa.Image;
import com.watabou.noosa.TextureFilm;
import com.watabou.noosa.audio.Sample;
import com.shatteredpixel.shatteredpixeldungeon.Assets;
import com.watabou.utils.PointF;
public class BadgeBanner extends Image {
private enum State {
FADE_IN, STATIC, FADE_OUT
};
private State state;
private static final float DEFAULT_SCALE = 3;
private static final float FADE_IN_TIME = 0.2f;
private static final float STATIC_TIME = 1f;
private static final float FADE_OUT_TIME = 1.0f;
private int index;
private float time;
private static TextureFilm atlas;
private static BadgeBanner current;
private BadgeBanner( int index ) {
super( Assets.BADGES );
if (atlas == null) {
atlas = new TextureFilm( texture, 16, 16 );
}
this.index = index;
frame( atlas.get( index ) );
origin.set( width / 2, height / 2 );
alpha( 0 );
scale.set( 2 * DEFAULT_SCALE );
state = State.FADE_IN;
time = FADE_IN_TIME;
Sample.INSTANCE.play( Assets.SND_BADGE );
}
@Override
public void update() {
super.update();
time -= Game.elapsed;
if (time >= 0) {
switch (state) {
case FADE_IN:
float p = time / FADE_IN_TIME;
scale.set( (1 + p) * DEFAULT_SCALE );
alpha( 1 - p );
break;
case STATIC:
break;
case FADE_OUT:
alpha( time / FADE_OUT_TIME );
break;
}
} else {
switch (state) {
case FADE_IN:
time = STATIC_TIME;
state = State.STATIC;
scale.set( DEFAULT_SCALE );
alpha( 1 );
highlight( this, index );
break;
case STATIC:
time = FADE_OUT_TIME;
state = State.FADE_OUT;
break;
case FADE_OUT:
killAndErase();
break;
}
}
}
@Override
public void kill() {
if (current == this) {
current = null;
}
super.kill();
}
public static void highlight( Image image, int index ) {
PointF p = new PointF();
switch (index) {
case 0:
case 1:
case 2:
case 3:
p.offset( 7, 3 );
break;
case 4:
case 5:
case 6:
case 7:
p.offset( 6, 5 );
break;
case 8:
case 9:
case 10:
case 11:
p.offset( 6, 3 );
break;
case 12:
case 13:
case 14:
case 15:
p.offset( 7, 4 );
break;
case 16:
p.offset( 6, 3 );
break;
case 17:
p.offset( 5, 4 );
break;
case 18:
p.offset( 7, 3 );
break;
case 20:
p.offset( 7, 3 );
break;
case 21:
p.offset( 7, 3 );
break;
case 22:
p.offset( 6, 4 );
break;
case 23:
p.offset( 4, 5 );
break;
case 24:
p.offset( 6, 4 );
break;
case 25:
p.offset( 6, 5 );
break;
case 26:
p.offset( 5, 5 );
break;
case 27:
p.offset( 6, 4 );
break;
case 28:
p.offset( 3, 5 );
break;
case 29:
p.offset( 5, 4 );
break;
case 30:
p.offset( 5, 4 );
break;
case 31:
p.offset( 5, 5 );
break;
case 32:
case 33:
p.offset( 7, 4 );
break;
case 34:
p.offset( 6, 4 );
break;
case 35:
p.offset( 6, 4 );
break;
case 36:
p.offset( 6, 5 );
break;
case 37:
p.offset( 4, 4 );
break;
case 38:
p.offset( 5, 5 );
break;
case 40:
case 41:
case 42:
case 43:
p.offset( 5, 4 );
break;
case 44:
case 45:
case 46:
case 47:
p.offset( 5, 5 );
break;
case 48:
case 49:
case 50:
case 51:
p.offset( 7, 4 );
break;
case 52:
case 53:
case 54:
case 55:
p.offset( 4, 4 );
break;
case 56:
p.offset( 3, 7 );
break;
case 57:
p.offset( 4, 5 );
break;
case 58:
p.offset( 6, 4 );
break;
case 59:
p.offset( 7, 4 );
break;
case 60:
case 61:
case 62:
case 63:
p.offset( 4, 4 );
break;
}
p.x *= image.scale.x;
p.y *= image.scale.y;
p.offset(
-image.origin.x * (image.scale.x - 1),
-image.origin.y * (image.scale.y - 1) );
p.offset( image.point() );
Speck star = new Speck();
star.reset( 0, p.x, p.y, Speck.DISCOVER );
star.camera = image.camera();
image.parent.add( star );
}
public static BadgeBanner show( int image ) {
if (current != null) {
current.killAndErase();
}
return (current = new BadgeBanner( image ));
}
public static Image image( int index ) {
Image image = new Image( Assets.BADGES );
if (atlas == null) {
atlas = new TextureFilm( image.texture, 16, 16 );
}
image.frame( atlas.get( index ) );
return image;
}
}
@@ -0,0 +1,46 @@
/*
* Pixel Dungeon
* Copyright (C) 2012-2014 Oleg Dolya
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.effects;
import com.watabou.noosa.Image;
import com.shatteredpixel.shatteredpixeldungeon.Assets;
public class BannerSprites {
public enum Type {
PIXEL_DUNGEON,
BOSS_SLAIN,
GAME_OVER
};
public static Image get( Type type ) {
Image icon = new Image( Assets.BANNERS );
switch (type) {
case PIXEL_DUNGEON:
icon.frame( icon.texture.uvRect( 0, 0, 128, 70 ) );
break;
case BOSS_SLAIN:
icon.frame( icon.texture.uvRect( 0, 70, 128, 105 ) );
break;
case GAME_OVER:
icon.frame( icon.texture.uvRect( 0, 105, 128, 140 ) );
break;
}
return icon;
}
}
@@ -0,0 +1,59 @@
/*
* Pixel Dungeon
* Copyright (C) 2012-2014 Oleg Dolya
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.effects;
import com.watabou.noosa.particles.Emitter;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.DungeonTilemap;
import com.shatteredpixel.shatteredpixeldungeon.actors.blobs.Blob;
import com.watabou.utils.Random;
public class BlobEmitter extends Emitter {
private static final int WIDTH = Blob.WIDTH;
private static final int LENGTH = Blob.LENGTH;
private Blob blob;
public BlobEmitter( Blob blob ) {
super();
this.blob = blob;
blob.use( this );
}
@Override
protected void emit( int index ) {
if (blob.volume <= 0) {
return;
}
int[] map = blob.cur;
float size = DungeonTilemap.SIZE;
for (int i=0; i < LENGTH; i++) {
if (map[i] > 0 && Dungeon.visible[i]) {
float x = ((i % WIDTH) + Random.Float()) * size;
float y = ((i / WIDTH) + Random.Float()) * size;
factory.emit( this, index, x, y );
}
}
}
}
@@ -0,0 +1,56 @@
/*
* Pixel Dungeon
* Copyright (C) 2012-2014 Oleg Dolya
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.effects;
import com.watabou.noosa.particles.Emitter;
import com.shatteredpixel.shatteredpixeldungeon.DungeonTilemap;
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
import com.watabou.utils.PointF;
public class CellEmitter {
public static Emitter get( int cell ) {
PointF p = DungeonTilemap.tileToWorld( cell );
Emitter emitter = GameScene.emitter();
emitter.pos( p.x, p.y, DungeonTilemap.SIZE, DungeonTilemap.SIZE );
return emitter;
}
public static Emitter center( int cell ) {
PointF p = DungeonTilemap.tileToWorld( cell );
Emitter emitter = GameScene.emitter();
emitter.pos( p.x + DungeonTilemap.SIZE / 2, p.y + DungeonTilemap.SIZE / 2 );
return emitter;
}
public static Emitter bottom( int cell ) {
PointF p = DungeonTilemap.tileToWorld( cell );
Emitter emitter = GameScene.emitter();
emitter.pos( p.x, p.y + DungeonTilemap.SIZE, DungeonTilemap.SIZE, 0 );
return emitter;
}
}
@@ -0,0 +1,50 @@
/*
* Pixel Dungeon
* Copyright (C) 2012-2014 Oleg Dolya
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.effects;
import com.watabou.gltextures.TextureCache;
import com.watabou.noosa.Game;
import com.watabou.noosa.Image;
import com.shatteredpixel.shatteredpixeldungeon.DungeonTilemap;
public class CheckedCell extends Image {
private float alpha;
public CheckedCell( int pos ) {
super( TextureCache.createSolid( 0xFF55AAFF ) );
origin.set( 0.5f );
point( DungeonTilemap.tileToWorld( pos ).offset(
DungeonTilemap.SIZE / 2,
DungeonTilemap.SIZE / 2 ) );
alpha = 0.8f;
}
@Override
public void update() {
if ((alpha -= Game.elapsed) > 0) {
alpha( alpha );
scale.set( DungeonTilemap.SIZE * alpha );
} else {
killAndErase();
}
}
}
@@ -0,0 +1,75 @@
/*
* Pixel Dungeon
* Copyright (C) 2012-2014 Oleg Dolya
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.effects;
import javax.microedition.khronos.opengles.GL10;
import android.opengl.GLES20;
import com.watabou.noosa.Game;
import com.watabou.noosa.Image;
import com.watabou.noosa.audio.Sample;
import com.shatteredpixel.shatteredpixeldungeon.Assets;
import com.watabou.utils.PointF;
public class DeathRay extends Image {
private static final double A = 180 / Math.PI;
private static final float DURATION = 0.5f;
private float timeLeft;
public DeathRay( PointF s, PointF e ) {
super( Effects.get( Effects.Type.RAY ) );
origin.set( 0, height / 2 );
x = s.x - origin.x;
y = s.y - origin.y;
float dx = e.x - s.x;
float dy = e.y - s.y;
angle = (float)(Math.atan2( dy, dx ) * A);
scale.x = (float)Math.sqrt( dx * dx + dy * dy ) / width;
Sample.INSTANCE.play( Assets.SND_RAY );
timeLeft = DURATION;
}
@Override
public void update() {
super.update();
float p = timeLeft / DURATION;
alpha( p );
scale.set( scale.x, p );
if ((timeLeft -= Game.elapsed) <= 0) {
killAndErase();
}
}
@Override
public void draw() {
GLES20.glBlendFunc( GL10.GL_SRC_ALPHA, GL10.GL_ONE );
super.draw();
GLES20.glBlendFunc( GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA );
}
}
@@ -0,0 +1,50 @@
/*
* Pixel Dungeon
* Copyright (C) 2012-2014 Oleg Dolya
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.effects;
import com.watabou.noosa.Image;
import com.shatteredpixel.shatteredpixeldungeon.Assets;
public class Effects {
public enum Type {
RIPPLE,
LIGHTNING,
WOUND,
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;
}
return icon;
}
}
@@ -0,0 +1,97 @@
/*
* Pixel Dungeon
* Copyright (C) 2012-2014 Oleg Dolya
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.effects;
import com.watabou.noosa.Game;
import com.watabou.noosa.Image;
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
import com.shatteredpixel.shatteredpixeldungeon.sprites.CharSprite;
import com.shatteredpixel.shatteredpixeldungeon.ui.Icons;
import com.watabou.utils.Random;
public class EmoIcon extends Image {
protected float maxSize = 2;
protected float timeScale = 1;
protected boolean growing = true;
protected CharSprite owner;
public EmoIcon( CharSprite owner ) {
super();
this.owner = owner;
GameScene.add( this );
}
@Override
public void update() {
super.update();
if (visible) {
if (growing) {
scale.set( scale.x + Game.elapsed * timeScale );
if (scale.x > maxSize) {
growing = false;
}
} else {
scale.set( scale.x - Game.elapsed * timeScale );
if (scale.x < 1) {
growing = true;
}
}
x = owner.x + owner.width - width / 2;
y = owner.y - height;
}
}
public static class Sleep extends EmoIcon {
public Sleep( CharSprite owner ) {
super( owner );
copy( Icons.get( Icons.SLEEP ) );
maxSize = 1.2f;
timeScale = 0.5f;
origin.set( width / 2, height / 2 );
scale.set( Random.Float( 1, maxSize ) );
}
}
public static class Alert extends EmoIcon {
public Alert( CharSprite owner ) {
super( owner );
copy( Icons.get( Icons.ALERT ) );
maxSize = 1.3f;
timeScale = 2;
origin.set( 2.5f, height - 2.5f );
scale.set( Random.Float( 1, maxSize ) );
}
}
}
@@ -0,0 +1,164 @@
/*
* Pixel Dungeon
* Copyright (C) 2012-2014 Oleg Dolya
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.effects;
import javax.microedition.khronos.opengles.GL10;
import android.graphics.RectF;
import android.opengl.GLES20;
import com.watabou.glwrap.Texture;
import com.watabou.noosa.Game;
import com.watabou.noosa.Group;
import com.watabou.noosa.Image;
import com.watabou.noosa.particles.Emitter;
import com.watabou.noosa.particles.PixelParticle;
import com.watabou.noosa.ui.Component;
import com.shatteredpixel.shatteredpixeldungeon.Assets;
import com.watabou.utils.ColorMath;
import com.watabou.utils.Random;
public class Fireball extends Component {
private static final RectF BLIGHT = new RectF( 0, 0, 0.25f, 1 );
private static final RectF FLIGHT = new RectF( 0.25f, 0, 0.5f, 1 );
private static final RectF FLAME1 = new RectF( 0.50f, 0, 0.75f, 1 );
private static final RectF FLAME2 = new RectF( 0.75f, 0, 1.00f, 1 );
private static final int COLOR = 0xFF66FF;
private Image bLight;
private Image fLight;
private Emitter emitter;
private Group sparks;
@Override
protected void createChildren() {
sparks = new Group();
add( sparks );
bLight = new Image( Assets.FIREBALL );
bLight.frame( BLIGHT );
bLight.origin.set( bLight.width / 2 );
bLight.angularSpeed = -90;
add( bLight );
emitter = new Emitter();
emitter.pour( new Emitter.Factory() {
@Override
public void emit(Emitter emitter, int index, float x, float y) {
Flame p = (Flame)emitter.recycle( Flame.class );
p.reset();
p.x = x - p.width / 2;
p.y = y - p.height / 2;
}
}, 0.1f );
add( emitter );
fLight = new Image( Assets.FIREBALL );
fLight.frame( FLIGHT );
fLight.origin.set( fLight.width / 2 );
fLight.angularSpeed = 360;
add( fLight );
bLight.texture.filter( Texture.LINEAR, Texture.LINEAR );
}
@Override
protected void layout() {
bLight.x = x - bLight.width / 2;
bLight.y = y - bLight.height / 2;
emitter.pos(
x - bLight.width / 4,
y - bLight.height / 4,
bLight.width / 2,
bLight.height / 2 );
fLight.x = x - fLight.width / 2;
fLight.y = y - fLight.height / 2;
}
@Override
public void update() {
super.update();
if (Random.Float() < Game.elapsed) {
PixelParticle spark = (PixelParticle)sparks.recycle( PixelParticle.Shrinking.class );
spark.reset( x, y, ColorMath.random( COLOR, 0x66FF66 ), 2, Random.Float( 0.5f, 1.0f ) );
spark.speed.set(
Random.Float( -40, +40 ),
Random.Float( -60, +20 ) );
spark.acc.set( 0, +80 );
sparks.add( spark );
}
}
@Override
public void draw() {
GLES20.glBlendFunc( GL10.GL_SRC_ALPHA, GL10.GL_ONE );
super.draw();
GLES20.glBlendFunc( GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA );
}
public static class Flame extends Image {
private static float LIFESPAN = 1f;
private static float SPEED = -40f;
private static float ACC = -20f;
private float timeLeft;
public Flame() {
super( Assets.FIREBALL );
frame( Random.Int( 2 ) == 0 ? FLAME1 : FLAME2 );
origin.set( width / 2, height / 2 );
acc.set( 0, ACC );
}
public void reset() {
revive();
timeLeft = LIFESPAN;
speed.set( 0, SPEED );
}
@Override
public void update() {
super.update();
if ((timeLeft -= Game.elapsed) <= 0) {
kill();
} else {
float p = timeLeft / LIFESPAN;
scale.set( p );
alpha( p > 0.8f ? (1 - p) * 5f : p * 1.25f );
}
}
}
}
@@ -0,0 +1,170 @@
/*
* Pixel Dungeon
* Copyright (C) 2012-2014 Oleg Dolya
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.effects;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.FloatBuffer;
import java.nio.ShortBuffer;
import javax.microedition.khronos.opengles.GL10;
import android.annotation.SuppressLint;
import android.opengl.GLES20;
import android.util.FloatMath;
import com.watabou.gltextures.Gradient;
import com.watabou.gltextures.SmartTexture;
import com.watabou.noosa.Game;
import com.watabou.noosa.NoosaScript;
import com.watabou.noosa.Visual;
public class Flare extends Visual {
private float duration = 0;
private float lifespan;
private boolean lightMode = true;
private SmartTexture texture;
private FloatBuffer vertices;
private ShortBuffer indices;
private int nRays;
@SuppressLint("FloatMath")
public Flare( int nRays, float radius ) {
super( 0, 0, 0, 0 );
// Texture is incorrectly created every time we need
// to show the effect, it must be refactored
int gradient[] = {0xFFFFFFFF, 0x00FFFFFF};
texture = new Gradient( gradient );
this.nRays = nRays;
angle = 45;
angularSpeed = 180;
vertices = ByteBuffer.
allocateDirect( (nRays * 2 + 1) * 4 * (Float.SIZE / 8) ).
order( ByteOrder.nativeOrder() ).
asFloatBuffer();
indices = ByteBuffer.
allocateDirect( nRays * 3 * Short.SIZE / 8 ).
order( ByteOrder.nativeOrder() ).
asShortBuffer();
float v[] = new float[4];
v[0] = 0;
v[1] = 0;
v[2] = 0.25f;
v[3] = 0;
vertices.put( v );
v[2] = 0.75f;
v[3] = 0;
for (int i=0; i < nRays; i++) {
float a = i * 3.1415926f * 2 / nRays;
v[0] = FloatMath.cos( a ) * radius;
v[1] = FloatMath.sin( a ) * radius;
vertices.put( v );
a += 3.1415926f * 2 / nRays / 2;
v[0] = FloatMath.cos( a ) * radius;
v[1] = FloatMath.sin( a ) * radius;
vertices.put( v );
indices.put( (short)0 );
indices.put( (short)(1 + i * 2) );
indices.put( (short)(2 + i * 2) );
}
indices.position( 0 );
}
public Flare color( int color, boolean lightMode ) {
this.lightMode = lightMode;
hardlight( color );
return this;
}
public Flare show( Visual visual, float duration ) {
point( visual.center() );
visual.parent.addToBack( this );
lifespan = this.duration = duration;
return this;
}
@Override
public void update() {
super.update();
if (duration > 0) {
if ((lifespan -= Game.elapsed) > 0) {
float p = 1 - lifespan / duration; // 0 -> 1
p = p < 0.25f ? p * 4 : (1 - p) * 1.333f;
scale.set( p );
alpha( p );
} else {
killAndErase();
}
}
}
@Override
public void draw() {
super.draw();
if (lightMode) {
GLES20.glBlendFunc( GL10.GL_SRC_ALPHA, GL10.GL_ONE );
drawRays();
GLES20.glBlendFunc( GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA );
} else {
drawRays();
}
}
private void drawRays() {
NoosaScript script = NoosaScript.get();
texture.bind();
script.uModel.valueM4( matrix );
script.lighting(
rm, gm, bm, am,
ra, ga, ba, aa );
script.camera( camera );
script.drawElements( vertices, indices, nRays * 3 );
}
}
@@ -0,0 +1,134 @@
/*
* Pixel Dungeon
* Copyright (C) 2012-2014 Oleg Dolya
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.effects;
import java.util.ArrayList;
import com.watabou.noosa.BitmapText;
import com.watabou.noosa.Game;
import com.shatteredpixel.shatteredpixeldungeon.DungeonTilemap;
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene;
import com.watabou.utils.SparseArray;
public class FloatingText extends BitmapText {
private static final float LIFESPAN = 1f;
private static final float DISTANCE = DungeonTilemap.SIZE;
private float timeLeft;
private int key = -1;
private static SparseArray<ArrayList<FloatingText>> stacks = new SparseArray<ArrayList<FloatingText>>();
public FloatingText() {
super();
PixelScene.chooseFont( 9 );
font = PixelScene.font;
scale.set( PixelScene.scale );
speed.y = - DISTANCE / LIFESPAN;
}
@Override
public void update() {
super.update();
if (timeLeft > 0) {
if ((timeLeft -= Game.elapsed) <= 0) {
kill();
} else {
float p = timeLeft / LIFESPAN;
alpha( p > 0.5f ? 1 : p * 2 );
}
}
}
@Override
public void kill() {
if (key != -1) {
stacks.get( key ).remove( this );
key = -1;
}
super.kill();
}
@Override
public void destroy() {
kill();
super.destroy();
}
public void reset( float x, float y, String text, int color ) {
revive();
text( text );
hardlight( color );
measure();
this.x = PixelScene.align( x - width() / 2 );
this.y = y - height();
timeLeft = LIFESPAN;
}
/* STATIC METHODS */
public static void show( float x, float y, String text, int color ) {
GameScene.status().reset( x, y, text, color );
}
public static void show( float x, float y, int key, String text, int color ) {
FloatingText txt = GameScene.status();
txt.reset( x, y, text, color );
push( txt, key );
}
private static void push( FloatingText txt, int key ) {
txt.key = key;
ArrayList<FloatingText> stack = stacks.get( key );
if (stack == null) {
stack = new ArrayList<FloatingText>();
stacks.put( key, stack );
}
if (stack.size() > 0) {
FloatingText below = txt;
int aboveIndex = stack.size() - 1;
while (aboveIndex >= 0) {
FloatingText above = stack.get( aboveIndex );
if (above.y + above.height() > below.y) {
above.y = below.y - above.height();
below = above;
aboveIndex--;
} else {
break;
}
}
}
stack.add( txt );
}
}
@@ -0,0 +1,74 @@
/*
* Pixel Dungeon
* Copyright (C) 2012-2014 Oleg Dolya
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.effects;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Paint;
import com.watabou.gltextures.SmartTexture;
import com.watabou.gltextures.TextureCache;
import com.watabou.noosa.Image;
public class Halo extends Image {
private static final Object CACHE_KEY = Halo.class;
protected static final int RADIUS = 64;
protected float radius = RADIUS;
protected float brightness = 1;
public Halo() {
super();
if (!TextureCache.contains( CACHE_KEY )) {
Bitmap bmp = Bitmap.createBitmap( RADIUS * 2, RADIUS * 2, Bitmap.Config.ARGB_8888 );
Canvas canvas = new Canvas( bmp );
Paint paint = new Paint();
paint.setColor( 0xFFFFFFFF );
canvas.drawCircle( RADIUS, RADIUS, RADIUS * 0.75f, paint );
paint.setColor( 0x88FFFFFF );
canvas.drawCircle( RADIUS, RADIUS, RADIUS, paint );
TextureCache.add( CACHE_KEY, new SmartTexture( bmp ) );
}
texture( CACHE_KEY );
origin.set( RADIUS );
}
public Halo( float radius, int color, float brightness ) {
this();
hardlight( color );
alpha( this.brightness = brightness );
radius( radius );
}
public Halo point( float x, float y ) {
this.x = x - RADIUS;
this.y = y - RADIUS;
return this;
}
public void radius( float value ) {
scale.set( (this.radius = value) / RADIUS );
}
}
@@ -0,0 +1,68 @@
/*
* Pixel Dungeon
* Copyright (C) 2012-2014 Oleg Dolya
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.effects;
import com.watabou.noosa.Game;
import com.watabou.noosa.Gizmo;
import com.watabou.noosa.audio.Sample;
import com.shatteredpixel.shatteredpixeldungeon.Assets;
import com.shatteredpixel.shatteredpixeldungeon.sprites.CharSprite;
public class IceBlock extends Gizmo {
private float phase;
private CharSprite target;
public IceBlock( CharSprite target ) {
super();
this.target = target;
phase = 0;
}
@Override
public void update() {
super.update();
if ((phase += Game.elapsed * 2) < 1) {
target.tint( 0.83f, 1.17f, 1.33f, phase * 0.6f );
} else {
target.tint( 0.83f, 1.17f, 1.33f, 0.6f );
}
}
public void melt() {
target.resetColor();
killAndErase();
if (visible) {
Splash.at( target.center(), 0xFFB2D6FF, 5 );
Sample.INSTANCE.play( Assets.SND_SHATTER );
}
}
public static IceBlock freeze( CharSprite sprite ) {
IceBlock iceBlock = new IceBlock( sprite );
sprite.parent.add( iceBlock );
return iceBlock;
}
}
@@ -0,0 +1,101 @@
/*
* Pixel Dungeon
* Copyright (C) 2012-2014 Oleg Dolya
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.effects;
import javax.microedition.khronos.opengles.GL10;
import android.opengl.GLES20;
import com.watabou.noosa.Group;
import com.watabou.noosa.particles.PixelParticle;
import com.watabou.utils.PointF;
import com.watabou.utils.Random;
public class Identification extends Group {
private static int[] DOTS = {
-1, -3,
0, -3,
+1, -3,
-1, -2,
+1, -2,
+1, -1,
0, 0,
+1, 0,
0, +1,
0, +3
};
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] ) );
}
}
@Override
public void update() {
super.update();
if (countLiving() == 0) {
killAndErase();
}
}
@Override
public void draw() {
GLES20.glBlendFunc( GL10.GL_SRC_ALPHA, GL10.GL_ONE );
super.draw();
GLES20.glBlendFunc( GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA );
}
public static class Speck extends PixelParticle {
public Speck( float x0, float y0, int mx, int my ) {
super();
color( 0x4488CC );
float x1 = x0 + mx * 3;
float y1 = y0 + my * 3;
PointF p = new PointF().polar( Random.Float( 2 * PointF.PI ), 8 );
x0 += p.x;
y0 += p.y;
float dx = x1 - x0;
float dy = y1 - y0;
x = x0;
y = y0;
speed.set( dx, dy );
acc.set( -dx / 4, -dy / 4 );
left = lifespan = 2f;
}
@Override
public void update() {
super.update();
am = 1 - Math.abs( left / lifespan - 0.5f ) * 2;
am *= am;
size( am * 2 );
}
}
}
@@ -0,0 +1,142 @@
/*
* Pixel Dungeon
* Copyright (C) 2012-2014 Oleg Dolya
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.effects;
import javax.microedition.khronos.opengles.GL10;
import android.opengl.GLES20;
import com.watabou.noosa.Game;
import com.watabou.noosa.Group;
import com.watabou.noosa.Image;
import com.watabou.noosa.audio.Sample;
import com.shatteredpixel.shatteredpixeldungeon.Assets;
import com.shatteredpixel.shatteredpixeldungeon.DungeonTilemap;
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
import com.watabou.utils.Callback;
import com.watabou.utils.Random;
public class Lightning extends Group {
private static final float DURATION = 0.3f;
private float life;
private int length;
private float[] cx;
private float[] cy;
private Image[] arcsS;
private Image[] arcsE;
private Callback callback;
public Lightning( int[] cells, int length, Callback callback ) {
super();
this.callback = callback;
Image proto = Effects.get( Effects.Type.LIGHTNING );
float ox = 0;
float oy = proto.height / 2;
this.length = length;
cx = new float[length];
cy = new float[length];
for (int i=0; i < length; i++) {
int c = cells[i];
cx[i] = (c % Level.WIDTH + 0.5f) * DungeonTilemap.SIZE;
cy[i] = (c / Level.WIDTH + 0.5f) * DungeonTilemap.SIZE;
}
arcsS = new Image[length - 1];
arcsE = new Image[length - 1];
for (int i=0; i < length - 1; i++) {
Image arc = arcsS[i] = new Image( proto );
arc.x = cx[i] - arc.origin.x;
arc.y = cy[i] - arc.origin.y;
arc.origin.set( ox, oy );
add( arc );
arc = arcsE[i] = new Image( proto );
arc.origin.set( ox, oy );
add( arc );
}
life = DURATION;
Sample.INSTANCE.play( Assets.SND_LIGHTNING );
}
private static final double A = 180 / Math.PI;
@Override
public void update() {
super.update();
if ((life -= Game.elapsed) < 0) {
killAndErase();
if (callback != null) {
callback.call();
}
} else {
float alpha = life / DURATION;
for (int i=0; i < length - 1; i++) {
float sx = cx[i];
float sy = cy[i];
float ex = cx[i+1];
float ey = cy[i+1];
float x2 = (sx + ex) / 2 + Random.Float( -4, +4 );
float y2 = (sy + ey) / 2 + Random.Float( -4, +4 );
float dx = x2 - sx;
float dy = y2 - sy;
Image arc = arcsS[i];
arc.am = alpha;
arc.angle = (float)(Math.atan2( dy, dx ) * A);
arc.scale.x = (float)Math.sqrt( dx * dx + dy * dy ) / arc.width;
dx = ex - x2;
dy = ey - y2;
arc = arcsE[i];
arc.am = alpha;
arc.angle = (float)(Math.atan2( dy, dx ) * A);
arc.scale.x = (float)Math.sqrt( dx * dx + dy * dy ) / arc.width;
arc.x = x2 - arc.origin.x;
arc.y = y2 - arc.origin.x;
}
}
}
@Override
public void draw() {
GLES20.glBlendFunc( GL10.GL_SRC_ALPHA, GL10.GL_ONE );
super.draw();
GLES20.glBlendFunc( GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA );
}
}
@@ -0,0 +1,399 @@
/*
* Pixel Dungeon
* Copyright (C) 2012-2014 Oleg Dolya
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.effects;
import com.watabou.noosa.Game;
import com.watabou.noosa.Group;
import com.watabou.noosa.particles.Emitter;
import com.watabou.noosa.particles.PixelParticle;
import com.shatteredpixel.shatteredpixeldungeon.DungeonTilemap;
import com.shatteredpixel.shatteredpixeldungeon.effects.particles.FlameParticle;
import com.shatteredpixel.shatteredpixeldungeon.effects.particles.LeafParticle;
import com.shatteredpixel.shatteredpixeldungeon.effects.particles.PoisonParticle;
import com.shatteredpixel.shatteredpixeldungeon.effects.particles.PurpleParticle;
import com.shatteredpixel.shatteredpixeldungeon.effects.particles.ShadowParticle;
import com.shatteredpixel.shatteredpixeldungeon.effects.particles.WoolParticle;
import com.watabou.utils.Callback;
import com.watabou.utils.ColorMath;
import com.watabou.utils.PointF;
import com.watabou.utils.Random;
public class MagicMissile extends Emitter {
private static final float SPEED = 200f;
private Callback callback;
private float sx;
private float sy;
private float time;
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;
}
public void size( float size ) {
x -= size / 2;
y -= size / 2;
width = height = size;
}
public static void blueLight( Group group, int from, int to, Callback callback ) {
MagicMissile missile = ((MagicMissile)group.recycle( MagicMissile.class ));
missile.reset( from, to, callback );
missile.pour( MagicParticle.FACTORY, 0.01f );
}
public static void fire( Group group, int from, int to, Callback callback ) {
MagicMissile missile = ((MagicMissile)group.recycle( MagicMissile.class ));
missile.reset( from, to, callback );
missile.size( 4 );
missile.pour( FlameParticle.FACTORY, 0.01f );
}
public static void earth( Group group, int from, int to, Callback callback ) {
MagicMissile missile = ((MagicMissile)group.recycle( MagicMissile.class ));
missile.reset( from, to, callback );
missile.size( 2 );
missile.pour( EarthParticle.FACTORY, 0.01f );
}
public static void purpleLight( Group group, int from, int to, Callback callback ) {
MagicMissile missile = ((MagicMissile)group.recycle( MagicMissile.class ));
missile.reset( from, to, callback );
missile.size( 2 );
missile.pour( PurpleParticle.MISSILE, 0.01f );
}
public static void whiteLight( Group group, int from, int to, Callback callback ) {
MagicMissile missile = ((MagicMissile)group.recycle( MagicMissile.class ));
missile.reset( from, to, callback );
missile.size( 4 );
missile.pour( WhiteParticle.FACTORY, 0.01f );
}
public static void wool( Group group, int from, int to, Callback callback ) {
MagicMissile missile = ((MagicMissile)group.recycle( MagicMissile.class ));
missile.reset( from, to, callback );
missile.size( 3 );
missile.pour( WoolParticle.FACTORY, 0.01f );
}
public static void poison( Group group, int from, int to, Callback callback ) {
MagicMissile missile = ((MagicMissile)group.recycle( MagicMissile.class ));
missile.reset( from, to, callback );
missile.size( 3 );
missile.pour( PoisonParticle.MISSILE, 0.01f );
}
public static void foliage( Group group, int from, int to, Callback callback ) {
MagicMissile missile = ((MagicMissile)group.recycle( MagicMissile.class ));
missile.reset( from, to, callback );
missile.size( 4 );
missile.pour( LeafParticle.GENERAL, 0.01f );
}
public static void slowness( Group group, int from, int to, Callback callback ) {
MagicMissile missile = ((MagicMissile)group.recycle( MagicMissile.class ));
missile.reset( from, to, callback );
missile.pour( SlowParticle.FACTORY, 0.01f );
}
public static void force( Group group, int from, int to, Callback callback ) {
MagicMissile missile = ((MagicMissile)group.recycle( MagicMissile.class ));
missile.reset( from, to, callback );
missile.size( 4 );
missile.pour( ForceParticle.FACTORY, 0.01f );
}
public static void coldLight( Group group, int from, int to, Callback callback ) {
MagicMissile missile = ((MagicMissile)group.recycle( MagicMissile.class ));
missile.reset( from, to, callback );
missile.size( 4 );
missile.pour( ColdParticle.FACTORY, 0.01f );
}
public static void shadow( Group group, int from, int to, Callback callback ) {
MagicMissile missile = ((MagicMissile)group.recycle( MagicMissile.class ));
missile.reset( from, to, callback );
missile.size( 4 );
missile.pour( ShadowParticle.MISSILE, 0.01f );
}
@Override
public void update() {
super.update();
if (on) {
float d = Game.elapsed;
x += sx * d;
y += sy * d;
if ((time -= d) <= 0) {
on = false;
callback.call();
}
}
}
public static class MagicParticle extends PixelParticle {
public static final Emitter.Factory FACTORY = new Factory() {
@Override
public void emit( Emitter emitter, int index, float x, float y ) {
((MagicParticle)emitter.recycle( MagicParticle.class )).reset( x, y );
}
@Override
public boolean lightMode() {
return true;
};
};
public MagicParticle() {
super();
color( 0x88CCFF );
lifespan = 0.5f;
speed.set( Random.Float( -10, +10 ), Random.Float( -10, +10 ) );
}
public void reset( float x, float y ) {
revive();
this.x = x;
this.y = y;
left = lifespan;
}
@Override
public void update() {
super.update();
// alpha: 1 -> 0; size: 1 -> 4
size( 4 - (am = left / lifespan) * 3 );
}
}
public static class EarthParticle extends PixelParticle.Shrinking {
public static final Emitter.Factory FACTORY = new Factory() {
@Override
public void emit( Emitter emitter, int index, float x, float y ) {
((EarthParticle)emitter.recycle( EarthParticle.class )).reset( x, y );
}
};
public EarthParticle() {
super();
lifespan = 0.5f;
color( ColorMath.random( 0x555555, 0x777766 ) );
acc.set( 0, +40 );
}
public void reset( float x, float y ) {
revive();
this.x = x;
this.y = y;
left = lifespan;
size = 4;
speed.set( Random.Float( -10, +10 ), Random.Float( -10, +10 ) );
}
}
public static class WhiteParticle extends PixelParticle {
public static final Emitter.Factory FACTORY = new Factory() {
@Override
public void emit( Emitter emitter, int index, float x, float y ) {
((WhiteParticle)emitter.recycle( WhiteParticle.class )).reset( x, y );
}
@Override
public boolean lightMode() {
return true;
};
};
public WhiteParticle() {
super();
lifespan = 0.4f;
am = 0.5f;
}
public void reset( float x, float y ) {
revive();
this.x = x;
this.y = y;
left = lifespan;
}
@Override
public void update() {
super.update();
// size: 3 -> 0
size( (left / lifespan) * 3 );
}
}
public static class SlowParticle extends PixelParticle {
private Emitter emitter;
public static final Emitter.Factory FACTORY = new Factory() {
@Override
public void emit( Emitter emitter, int index, float x, float y ) {
((SlowParticle)emitter.recycle( SlowParticle.class )).reset( x, y, emitter );
}
@Override
public boolean lightMode() {
return true;
};
};
public SlowParticle() {
super();
lifespan = 0.6f;
color( 0x664422 );
size( 2 );
}
public void reset( float x, float y, Emitter emitter ) {
revive();
this.x = x;
this.y = y;
this.emitter = emitter;
left = lifespan;
acc.set( 0 );
speed.set( Random.Float( -20, +20 ), Random.Float( -20, +20 ) );
}
@Override
public void update() {
super.update();
am = left / lifespan;
acc.set( (emitter.x - x) * 10, (emitter.y - y) * 10 );
}
}
public static class ForceParticle extends PixelParticle {
public static final Emitter.Factory FACTORY = new Factory() {
@Override
public void emit( Emitter emitter, int index, float x, float y ) {
((ForceParticle)emitter.recycle( ForceParticle.class )).reset( x, y );
}
};
public ForceParticle() {
super();
lifespan = 0.6f;
size( 4 );
}
public void reset( float x, float y ) {
revive();
this.x = x;
this.y = y;
left = lifespan;
acc.set( 0 );
speed.set( Random.Float( -40, +40 ), Random.Float( -40, +40 ) );
}
@Override
public void update() {
super.update();
am = (left / lifespan) / 2;
acc.set( -speed.x * 10, -speed.y * 10 );
}
}
public static class ColdParticle extends PixelParticle.Shrinking {
public static final Emitter.Factory FACTORY = new Factory() {
@Override
public void emit( Emitter emitter, int index, float x, float y ) {
((ColdParticle)emitter.recycle( ColdParticle.class )).reset( x, y );
}
@Override
public boolean lightMode() {
return true;
};
};
public ColdParticle() {
super();
lifespan = 0.6f;
color( 0x2244FF );
}
public void reset( float x, float y ) {
revive();
this.x = x;
this.y = y;
left = lifespan;
size = 8;
}
@Override
public void update() {
super.update();
am = 1 - left / lifespan;
}
}
}
@@ -0,0 +1,100 @@
/*
* Pixel Dungeon
* Copyright (C) 2012-2014 Oleg Dolya
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.effects;
import com.watabou.noosa.Game;
import com.watabou.noosa.Visual;
import com.shatteredpixel.shatteredpixeldungeon.actors.Actor;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.sprites.CharSprite;
import com.watabou.utils.PointF;
public class Pushing extends Actor {
private CharSprite sprite;
private int from;
private int to;
private Effect effect;
public Pushing( Char ch, int from, int to ) {
sprite = ch.sprite;
this.from = from;
this.to = to;
}
@Override
protected boolean act() {
if (sprite != null) {
if (effect == null) {
new Effect();
}
return false;
} else {
Actor.remove( Pushing.this );
return true;
}
}
public class Effect extends Visual {
private static final float DELAY = 0.15f;
private PointF end;
private float delay;
public Effect() {
super( 0, 0, 0, 0 );
point( sprite.worldToCamera( from ) );
end = sprite.worldToCamera( to );
speed.set( 2 * (end.x - x) / DELAY, 2 * (end.y - y) / DELAY );
acc.set( -speed.x / DELAY, -speed.y / DELAY );
delay = 0;
sprite.parent.add( this );
}
@Override
public void update() {
super.update();
if ((delay += Game.elapsed) < DELAY) {
sprite.x = x;
sprite.y = y;
} else {
sprite.point( end );
killAndErase();
Actor.remove( Pushing.this );
next();
}
}
}
}
@@ -0,0 +1,59 @@
/*
* Pixel Dungeon
* Copyright (C) 2012-2014 Oleg Dolya
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.effects;
import com.watabou.noosa.Game;
import com.watabou.noosa.Image;
import com.shatteredpixel.shatteredpixeldungeon.DungeonTilemap;
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
public class Ripple extends Image {
private static final float TIME_TO_FADE = 0.5f;
private float time;
public Ripple() {
super( Effects.get( Effects.Type.RIPPLE ) );
}
public void reset( int p ) {
revive();
x = (p % Level.WIDTH) * DungeonTilemap.SIZE;
y = (p / Level.WIDTH) * DungeonTilemap.SIZE;
origin.set( width / 2, height / 2 );
scale.set( 0 );
time = TIME_TO_FADE;
}
@Override
public void update() {
super.update();
if ((time -= Game.elapsed) <= 0) {
kill();
} else {
float p = time / TIME_TO_FADE;
scale.set( 1 - p );
alpha( p );
}
}
}
@@ -0,0 +1,419 @@
/*
* Pixel Dungeon
* Copyright (C) 2012-2014 Oleg Dolya
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.effects;
import android.annotation.SuppressLint;
import android.util.FloatMath;
import android.util.SparseArray;
import com.watabou.noosa.Game;
import com.watabou.noosa.Image;
import com.watabou.noosa.TextureFilm;
import com.watabou.noosa.particles.Emitter;
import com.shatteredpixel.shatteredpixeldungeon.Assets;
import com.watabou.utils.PointF;
import com.watabou.utils.Random;
public class Speck extends Image {
public static final int HEALING = 0;
public static final int STAR = 1;
public static final int LIGHT = 2;
public static final int QUESTION = 3;
public static final int UP = 4;
public static final int SCREAM = 5;
public static final int BONE = 6;
public static final int WOOL = 7;
public static final int ROCK = 8;
public static final int NOTE = 9;
public static final int CHANGE = 10;
public static final int HEART = 11;
public static final int BUBBLE = 12;
public static final int STEAM = 13;
public static final int COIN = 14;
public static final int DISCOVER = 101;
public static final int EVOKE = 102;
public static final int MASTERY = 103;
public static final int KIT = 104;
public static final int RATTLE = 105;
public static final int JET = 106;
public static final int TOXIC = 107;
public static final int PARALYSIS = 108;
public static final int DUST = 109;
public static final int FORGE = 110;
private static final int SIZE = 7;
private int type;
private float lifespan;
private float left;
private static TextureFilm film;
private static SparseArray<Emitter.Factory> factories = new SparseArray<Emitter.Factory>();
public Speck() {
super();
texture( Assets.SPECKS );
if (film == null) {
film = new TextureFilm( texture, SIZE, SIZE );
}
origin.set( SIZE / 2f );
}
public void reset( int index, float x, float y, int type ) {
revive();
this.type = type;
switch (type) {
case DISCOVER:
frame( film.get( LIGHT ) );
break;
case EVOKE:
case MASTERY:
case KIT:
case FORGE:
frame( film.get( STAR ) );
break;
case RATTLE:
frame( film.get( BONE ) );
break;
case JET:
case TOXIC:
case PARALYSIS:
case DUST:
frame( film.get( STEAM ) );
break;
default:
frame( film.get( type ) );
}
this.x = x - origin.x;
this.y = y - origin.y;
resetColor();
scale.set( 1 );
speed.set( 0 );
acc.set( 0 );
angle = 0;
angularSpeed = 0;
switch (type) {
case HEALING:
speed.set( 0, -20 );
lifespan = 1f;
break;
case STAR:
speed.polar( Random.Float( 2 * 3.1415926f ), Random.Float( 128 ) );
acc.set( 0, 128 );
angle = Random.Float( 360 );
angularSpeed = Random.Float( -360, +360 );
lifespan = 1f;
break;
case FORGE:
speed.polar( Random.Float( -3.1415926f, 0 ), Random.Float( 64 ) );
acc.set( 0, 128 );
angle = Random.Float( 360 );
angularSpeed = Random.Float( -360, +360 );
lifespan = 0.51f;
break;
case EVOKE:
speed.polar( Random.Float( -3.1415926f, 0 ), 50 );
acc.set( 0, 50 );
angle = Random.Float( 360 );
angularSpeed = Random.Float( -180, +180 );
lifespan = 1f;
break;
case KIT:
speed.polar( index * 3.1415926f / 5, 50 );
acc.set( -speed.x, -speed.y );
angle = index * 36;
angularSpeed = 360;
lifespan = 1f;
break;
case MASTERY:
speed.set( Random.Int( 2 ) == 0 ? Random.Float( -128, -64 ) : Random.Float( +64, +128 ), 0 );
angularSpeed = speed.x < 0 ? -180 : +180;
acc.set( -speed.x, 0 );
lifespan = 0.5f;
break;
case LIGHT:
angle = Random.Float( 360 );
angularSpeed = 90;
lifespan = 1f;
break;
case DISCOVER:
angle = Random.Float( 360 );
angularSpeed = 90;
lifespan = 0.5f;
am = 0;
break;
case QUESTION:
lifespan = 0.8f;
break;
case UP:
speed.set( 0, -20 );
lifespan = 1f;
break;
case SCREAM:
lifespan = 0.9f;
break;
case BONE:
lifespan = 0.2f;
speed.polar( Random.Float( 2 * 3.1415926f ), 24 / lifespan );
acc.set( 0, 128 );
angle = Random.Float( 360 );
angularSpeed = 360;
break;
case RATTLE:
lifespan = 0.5f;
speed.set( 0, -200 );
acc.set( 0, -2 * speed.y / lifespan );
angle = Random.Float( 360 );
angularSpeed = 360;
break;
case WOOL:
lifespan = 0.5f;
speed.set( 0, -50 );
angle = Random.Float( 360 );
angularSpeed = Random.Float( -360, +360 );
break;
case ROCK:
angle = Random.Float( 360 );
angularSpeed = Random.Float( -360, +360 );
scale.set( Random.Float( 1, 2 ) );
speed.set( 0, 64 );
lifespan = 0.2f;
y -= speed.y * lifespan;
break;
case NOTE:
angularSpeed = Random.Float( -30, +30 );
speed.polar( (angularSpeed - 90) * PointF.G2R, 30 );
lifespan = 1f;
break;
case CHANGE:
angle = Random.Float( 360 );
speed.polar( (angle - 90) * PointF.G2R, Random.Float( 4, 12 ) );
lifespan = 1.5f;
break;
case HEART:
speed.set( Random.Int( -10, +10 ), -40 );
angularSpeed = Random.Float( -45, +45 );
lifespan = 1f;
break;
case BUBBLE:
speed.set( 0, -15 );
scale.set( Random.Float( 0.8f, 1 ) );
lifespan = Random.Float( 0.8f, 1.5f );
break;
case STEAM:
speed.y = -Random.Float( 20, 30 );
angularSpeed = Random.Float( +180 );
angle = Random.Float( 360 );
lifespan = 1f;
break;
case JET:
speed.y = +32;
acc.y = -64;
angularSpeed = Random.Float( 180, 360 );
angle = Random.Float( 360 );
lifespan = 0.5f;
break;
case TOXIC:
hardlight( 0x50FF60 );
angularSpeed = 30;
angle = Random.Float( 360 );
lifespan = Random.Float( 1f, 3f );
break;
case PARALYSIS:
hardlight( 0xFFFF66 );
angularSpeed = -30;
angle = Random.Float( 360 );
lifespan = Random.Float( 1f, 3f );
break;
case DUST:
hardlight( 0xFFFF66 );
angle = Random.Float( 360 );
speed.polar( Random.Float( 2 * 3.1415926f ), Random.Float( 16, 48 ) );
lifespan = 0.5f;
break;
case COIN:
speed.polar( -PointF.PI * Random.Float( 0.3f, 0.7f ), Random.Float( 48, 96 ) );
acc.y = 256;
lifespan = -speed.y / acc.y * 2;
break;
}
left = lifespan;
}
@SuppressLint("FloatMath")
@Override
public void update() {
super.update();
left -= Game.elapsed;
if (left <= 0) {
kill();
} else {
float p = 1 - left / lifespan; // 0 -> 1
switch (type) {
case STAR:
case FORGE:
scale.set( 1 - p );
am = p < 0.2f ? p * 5f : (1 - p) * 1.25f;
break;
case KIT:
case MASTERY:
am = 1 - p * p;
break;
case EVOKE:
case HEALING:
am = p < 0.5f ? 1 : 2 - p * 2;
break;
case LIGHT:
am = scale.set( p < 0.2f ? p * 5f : (1 - p) * 1.25f ).x;
break;
case DISCOVER:
am = 1 - p;
scale.set( (p < 0.5f ? p : 1 - p) * 2 );
break;
case QUESTION:
scale.set( (float)(Math.sqrt( p < 0.5f ? p : 1 - p ) * 3) );
break;
case UP:
scale.set( (float)(Math.sqrt( p < 0.5f ? p : 1 - p ) * 2) );
break;
case SCREAM:
am = (float)Math.sqrt( (p < 0.5f ? p : 1 - p) * 2f );
scale.set( p * 7 );
break;
case BONE:
case RATTLE:
am = p < 0.9f ? 1 : (1 - p) * 10;
break;
case ROCK:
am = p < 0.2f ? p * 5 : 1 ;
break;
case NOTE:
am = 1 - p * p;
break;
case WOOL:
scale.set( 1 - p );
break;
case CHANGE:
am = (float)FloatMath.sqrt( (p < 0.5f ? p : 1 - p) * 2);
scale.y = (1 + p) * 0.5f;
scale.x = scale.y * FloatMath.cos( left * 15 );
break;
case HEART:
scale.set( 1 - p );
am = 1 - p * p;
break;
case BUBBLE:
am = p < 0.2f ? p * 5 : 1;
break;
case STEAM:
case TOXIC:
case PARALYSIS:
case DUST:
am = p < 0.5f ? p : 1 - p;
scale.set( 1 + p * 2 );
break;
case JET:
am = (p < 0.5f ? p : 1 - p) * 2;
scale.set( p * 1.5f );
break;
case COIN:
scale.x = FloatMath.cos( left * 5 );
rm = gm = bm = (Math.abs( scale.x ) + 1) * 0.5f;
am = p < 0.9f ? 1 : (1 - p) * 10;
break;
}
}
}
public static Emitter.Factory factory( final int type ) {
Emitter.Factory factory = factories.get( type );
if (factory == null) {
factory = new Emitter.Factory() {
@Override
public void emit ( Emitter emitter, int index, float x, float y ) {
Speck p = (Speck)emitter.recycle( Speck.class );
p.reset( index, x, y, type );
}
};
factories.put( type, factory );
}
return factory;
}
}
@@ -0,0 +1,135 @@
/*
* Pixel Dungeon
* Copyright (C) 2012-2014 Oleg Dolya
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.effects;
import java.util.HashMap;
import com.watabou.noosa.Game;
import com.watabou.noosa.Image;
import com.watabou.noosa.TextureFilm;
import com.shatteredpixel.shatteredpixeldungeon.Assets;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
public class SpellSprite extends Image {
public static final int FOOD = 0;
public static final int MAP = 1;
public static final int CHARGE = 2;
public static final int MASTERY = 3;
private static final int SIZE = 16;
private enum Phase {
FADE_IN, STATIC, FADE_OUT
};
private static final float FADE_IN_TIME = 0.2f;
private static final float STATIC_TIME = 0.8f;
private static final float FADE_OUT_TIME = 0.4f;
private static TextureFilm film;
private Char target;
private Phase phase;
private float duration;
private float passed;
private static HashMap<Char,SpellSprite> all = new HashMap<Char, SpellSprite>();
public SpellSprite() {
super( Assets.SPELL_ICONS );
if (film == null) {
film = new TextureFilm( texture, SIZE );
}
}
public void reset( int index ) {
frame( film.get( index ) );
origin.set( width / 2, height / 2 );
phase = Phase.FADE_IN;
duration = FADE_IN_TIME;
passed = 0;
}
@Override
public void update() {
super.update();
x = target.sprite.center().x - SIZE / 2;
y = target.sprite.y - SIZE;
switch (phase) {
case FADE_IN:
alpha( passed / duration );
scale.set( passed / duration );
break;
case STATIC:
break;
case FADE_OUT:
alpha( 1 - passed / duration );
break;
}
if ((passed += Game.elapsed) > duration) {
switch (phase) {
case FADE_IN:
phase = Phase.STATIC;
duration = STATIC_TIME;
break;
case STATIC:
phase = Phase.FADE_OUT;
duration = FADE_OUT_TIME;
break;
case FADE_OUT:
kill();
break;
}
passed = 0;
}
}
@Override
public void kill() {
super.kill();
all.remove( target );
}
public static void show( Char ch, int index ) {
if (!ch.sprite.visible) {
return;
}
SpellSprite old = all.get( ch );
if (old != null) {
old.kill();
}
SpellSprite sprite = GameScene.spellSprite();
sprite.revive();
sprite.reset( index );
sprite.target = ch;
all.put( ch, sprite );
}
}
@@ -0,0 +1,80 @@
/*
* Pixel Dungeon
* Copyright (C) 2012-2014 Oleg Dolya
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.effects;
import com.watabou.noosa.particles.Emitter;
import com.watabou.noosa.particles.PixelParticle;
import com.shatteredpixel.shatteredpixeldungeon.DungeonTilemap;
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
import com.watabou.utils.PointF;
import com.watabou.utils.Random;
public class Splash {
public static void at( int cell, final int color, int n ) {
at( DungeonTilemap.tileCenterToWorld( cell ), color, n );
}
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 );
}
public static void at( PointF p, final float dir, final float cone, final int color, int n ) {
if (n <= 0) {
return;
}
Emitter emitter = GameScene.emitter();
emitter.pos( p );
FACTORY.color = color;
FACTORY.dir = dir;
FACTORY.cone = cone;
emitter.burst( FACTORY, n );
}
private static final SplashFactory FACTORY = new SplashFactory();
private static class SplashFactory extends Emitter.Factory {
public int color;
public float dir;
public float cone;
@Override
public void emit( Emitter emitter, int index, float x, float y ) {
PixelParticle p = (PixelParticle)emitter.recycle( PixelParticle.Shrinking.class );
p.reset( x, y, color, 4, Random.Float( 0.5f, 1.0f ) );
p.speed.polar( Random.Float( dir - cone / 2, dir + cone / 2 ), Random.Float( 40, 80 ) );
p.acc.set( 0, +100 );
}
}
}
@@ -0,0 +1,71 @@
/*
* Pixel Dungeon
* Copyright (C) 2012-2014 Oleg Dolya
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.effects;
import javax.microedition.khronos.opengles.GL10;
import android.opengl.GLES20;
import com.watabou.noosa.Game;
import com.shatteredpixel.shatteredpixeldungeon.sprites.CharSprite;
public class TorchHalo extends Halo {
private CharSprite target;
private float phase = 0;
public TorchHalo( CharSprite sprite ) {
super( 24, 0xFFDDCC, 0.15f );
target = sprite;
am = 0;
}
@Override
public void update() {
super.update();
if (phase < 0) {
if ((phase += Game.elapsed) >= 0) {
killAndErase();
} else {
scale.set( (2 + phase) * radius / RADIUS );
am = -phase * brightness;
}
} else if (phase < 1) {
if ((phase += Game.elapsed) >= 1) {
phase = 1;
}
scale.set( phase * radius / RADIUS );
am = phase * brightness;
}
point( target.x + target.width / 2, target.y + target.height / 2 );
}
@Override
public void draw() {
GLES20.glBlendFunc( GL10.GL_SRC_ALPHA, GL10.GL_ONE );
super.draw();
GLES20.glBlendFunc( GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA );
}
public void putOut() {
phase = -1;
}
}
@@ -0,0 +1,83 @@
/*
* Pixel Dungeon
* Copyright (C) 2012-2014 Oleg Dolya
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.effects;
import com.watabou.noosa.Game;
import com.watabou.noosa.Group;
import com.watabou.noosa.Image;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.DungeonTilemap;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
public class Wound extends Image {
private static final float TIME_TO_FADE = 0.8f;
private float time;
public Wound() {
super( Effects.get( Effects.Type.WOUND ) );
origin.set( width / 2, height / 2 );
}
public void reset( int p ) {
revive();
x = (p % Level.WIDTH) * DungeonTilemap.SIZE + (DungeonTilemap.SIZE - width) / 2;
y = (p / Level.WIDTH) * DungeonTilemap.SIZE + (DungeonTilemap.SIZE - height) / 2;
time = TIME_TO_FADE;
}
@Override
public void update() {
super.update();
if ((time -= Game.elapsed) <= 0) {
kill();
} else {
float p = time / TIME_TO_FADE;
alpha( p );
scale.x = 1 + p;
}
}
public static void hit( Char ch ) {
hit( ch, 0 );
}
public static void hit( Char ch, float angle ) {
Wound w = (Wound)ch.sprite.parent.recycle( Wound.class );
ch.sprite.parent.bringToFront( w );
w.reset( ch.pos );
w.angle = angle;
}
public static void hit( int pos ) {
hit( pos, 0 );
}
public static void hit( int pos, float angle ) {
Group parent = Dungeon.hero.sprite.parent;
Wound w = (Wound)parent.recycle( Wound.class );
parent.bringToFront( w );
w.reset( pos );
w.angle = angle;
}
}
@@ -0,0 +1,60 @@
/*
* Pixel Dungeon
* Copyright (C) 2012-2014 Oleg Dolya
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.effects.particles;
import com.watabou.noosa.particles.Emitter;
import com.watabou.noosa.particles.PixelParticle;
import com.watabou.noosa.particles.Emitter.Factory;
public class BloodParticle extends PixelParticle.Shrinking {
public static final Emitter.Factory FACTORY = new Factory() {
@Override
public void emit( Emitter emitter, int index, float x, float y ) {
((BloodParticle)emitter.recycle( BloodParticle.class )).reset( x, y );
}
};
public BloodParticle() {
super();
color( 0xCC0000 );
lifespan = 0.8f;
acc.set( 0, +40 );
}
public void reset( float x, float y ) {
revive();
this.x = x;
this.y = y;
left = lifespan;
size = 4;
speed.set( 0 );
}
@Override
public void update() {
super.update();
float p = left / lifespan;
am = p > 0.6f ? (1 - p) * 2.5f : 1;
}
}
@@ -0,0 +1,60 @@
/*
* Pixel Dungeon
* Copyright (C) 2012-2014 Oleg Dolya
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.effects.particles;
import com.watabou.noosa.particles.Emitter;
import com.watabou.noosa.particles.PixelParticle;
import com.watabou.noosa.particles.Emitter.Factory;
import com.watabou.utils.ColorMath;
import com.watabou.utils.Random;
public class EarthParticle extends PixelParticle {
public static final Emitter.Factory FACTORY = new Factory() {
@Override
public void emit( Emitter emitter, int index, float x, float y ) {
((EarthParticle)emitter.recycle( EarthParticle.class )).reset( x, y );
}
};
public EarthParticle() {
super();
color( ColorMath.random( 0x444444, 0x777766 ) );
angle = Random.Float( -30, 30 );
lifespan = 0.5f;
}
public void reset( float x, float y ) {
revive();
this.x = x;
this.y = y;
left = lifespan;
}
@Override
public void update() {
super.update();
float p = left / lifespan;
size( (p < 0.5f ? p : 1 - p) * 16 );
}
}
@@ -0,0 +1,64 @@
/*
* Pixel Dungeon
* Copyright (C) 2012-2014 Oleg Dolya
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.effects.particles;
import com.watabou.noosa.particles.Emitter;
import com.watabou.noosa.particles.PixelParticle;
import com.watabou.noosa.particles.Emitter.Factory;
public class ElmoParticle extends PixelParticle.Shrinking {
public static final Emitter.Factory FACTORY = new Factory() {
@Override
public void emit( Emitter emitter, int index, float x, float y ) {
((ElmoParticle)emitter.recycle( ElmoParticle.class )).reset( x, y );
}
@Override
public boolean lightMode() {
return true;
};
};
public ElmoParticle() {
super();
color( 0x22EE66 );
lifespan = 0.6f;
acc.set( 0, -80 );
}
public void reset( float x, float y ) {
revive();
this.x = x;
this.y = y;
left = lifespan;
size = 4;
speed.set( 0 );
}
@Override
public void update() {
super.update();
float p = left / lifespan;
am = p > 0.8f ? (1 - p) * 5 : 1;
}
}
@@ -0,0 +1,65 @@
/*
* Pixel Dungeon
* Copyright (C) 2012-2014 Oleg Dolya
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.effects.particles;
import com.watabou.noosa.particles.Emitter;
import com.watabou.noosa.particles.PixelParticle;
import com.watabou.noosa.particles.Emitter.Factory;
import com.watabou.utils.PointF;
import com.watabou.utils.Random;
public class EnergyParticle extends PixelParticle {
public static final Emitter.Factory FACTORY = new Factory() {
@Override
public void emit( Emitter emitter, int index, float x, float y ) {
((EnergyParticle)emitter.recycle( EnergyParticle.class )).reset( x, y );
}
@Override
public boolean lightMode() {
return true;
};
};
public EnergyParticle() {
super();
lifespan = 1f;
color( 0xFFFFAA );
speed.polar( Random.Float( 2 * PointF.PI ), Random.Float( 24, 32 ) );
}
public void reset( float x, float y ) {
revive();
left = lifespan;
this.x = x - speed.x * lifespan;
this.y = y - speed.y * lifespan;
}
@Override
public void update() {
super.update();
float p = left / lifespan;
am = p < 0.5f ? p * p * 4 : (1 - p) * 2;
size( Random.Float( 5 * left / lifespan ) );
}
}
@@ -0,0 +1,64 @@
/*
* Pixel Dungeon
* Copyright (C) 2012-2014 Oleg Dolya
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.effects.particles;
import com.watabou.noosa.particles.Emitter;
import com.watabou.noosa.particles.PixelParticle;
import com.watabou.noosa.particles.Emitter.Factory;
public class FlameParticle extends PixelParticle.Shrinking {
public static final Emitter.Factory FACTORY = new Factory() {
@Override
public void emit( Emitter emitter, int index, float x, float y ) {
((FlameParticle)emitter.recycle( FlameParticle.class )).reset( x, y );
}
@Override
public boolean lightMode() {
return true;
};
};
public FlameParticle() {
super();
color( 0xEE7722 );
lifespan = 0.6f;
acc.set( 0, -80 );
}
public void reset( float x, float y ) {
revive();
this.x = x;
this.y = y;
left = lifespan;
size = 4;
speed.set( 0 );
}
@Override
public void update() {
super.update();
float p = left / lifespan;
am = p > 0.8f ? (1 - p) * 5 : 1;
}
}
@@ -0,0 +1,109 @@
/*
* Pixel Dungeon
* Copyright (C) 2012-2014 Oleg Dolya
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.effects.particles;
import com.watabou.noosa.Game;
import com.watabou.noosa.Group;
import com.watabou.noosa.particles.Emitter;
import com.watabou.noosa.particles.PixelParticle;
import com.watabou.noosa.particles.Emitter.Factory;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.DungeonTilemap;
import com.watabou.utils.PointF;
import com.watabou.utils.Random;
public class FlowParticle extends PixelParticle {
public static final Emitter.Factory FACTORY = new Factory() {
@Override
public void emit( Emitter emitter, int index, float x, float y ) {
((FlowParticle)emitter.recycle( FlowParticle.class )).reset( x, y );
}
};
public FlowParticle() {
super();
lifespan = 0.6f;
acc.set( 0, 32 );
angularSpeed = Random.Float( -360, +360 );
}
public void reset( float x, float y ) {
revive();
left = lifespan;
this.x = x;
this.y = y;
am = 0;
size( 0 );
speed.set( 0 );
}
@Override
public void update() {
super.update();
float p = left / lifespan;
am = (p < 0.5f ? p : 1 - p) * 0.6f;
size( (1 - p) * 4 );
}
public static class Flow extends Group {
private static final float DELAY = 0.1f;
private int pos;
private float x;
private float y;
private float delay;
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 );
}
@Override
public void update() {
if (visible = Dungeon.visible[pos]) {
super.update();
if ((delay -= Game.elapsed) <= 0) {
delay = Random.Float( DELAY );
((FlowParticle)recycle( FlowParticle.class )).reset(
x + Random.Float( DungeonTilemap.SIZE ), y );
}
}
}
}
}
@@ -0,0 +1,69 @@
/*
* Pixel Dungeon
* Copyright (C) 2012-2014 Oleg Dolya
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.effects.particles;
import com.watabou.noosa.particles.Emitter;
import com.watabou.noosa.particles.PixelParticle;
import com.watabou.noosa.particles.Emitter.Factory;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.watabou.utils.ColorMath;
import com.watabou.utils.Random;
public class LeafParticle extends PixelParticle.Shrinking {
public static int color1;
public static int color2;
public static final Emitter.Factory GENERAL = new Factory() {
@Override
public void emit( Emitter emitter, int index, float x, float y ) {
LeafParticle p = ((LeafParticle)emitter.recycle( LeafParticle.class ));
p.color( ColorMath.random( 0x004400, 0x88CC44 ) );
p.reset( x, y );
}
};
public static final Emitter.Factory LEVEL_SPECIFIC = new Factory() {
@Override
public void emit( Emitter emitter, int index, float x, float y ) {
LeafParticle p = ((LeafParticle)emitter.recycle( LeafParticle.class ));
p.color( ColorMath.random( Dungeon.level.color1, Dungeon.level.color2 ) );
p.reset( x, y );
}
};
public LeafParticle() {
super();
lifespan = 1.2f;
acc.set( 0, 25 );
}
public void reset( float x, float y ) {
revive();
this.x = x;
this.y = y;
speed.set( Random.Float( -8, +8 ), -20 );
left = lifespan;
size = Random.Float( 2, 3 );
}
}
@@ -0,0 +1,88 @@
/*
* Pixel Dungeon
* Copyright (C) 2012-2014 Oleg Dolya
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.effects.particles;
import com.watabou.noosa.particles.Emitter;
import com.watabou.noosa.particles.PixelParticle;
import com.watabou.noosa.particles.Emitter.Factory;
import com.watabou.utils.ColorMath;
import com.watabou.utils.Random;
public class PoisonParticle extends PixelParticle {
public static final Emitter.Factory MISSILE = new Factory() {
@Override
public void emit( Emitter emitter, int index, float x, float y ) {
((PoisonParticle)emitter.recycle( PoisonParticle.class )).resetMissile( x, y );
}
@Override
public boolean lightMode() {
return true;
};
};
public static final Emitter.Factory SPLASH = new Factory() {
@Override
public void emit( Emitter emitter, int index, float x, float y ) {
((PoisonParticle)emitter.recycle( PoisonParticle.class )).resetSplash( x, y );
}
@Override
public boolean lightMode() {
return true;
};
};
public PoisonParticle() {
super();
lifespan = 0.6f;
acc.set( 0, +30 );
}
public void resetMissile( float x, float y ) {
revive();
this.x = x;
this.y = y;
left = lifespan;
speed.polar( Random.Float( 3.1415926f ), Random.Float( 6 ) );
}
public void resetSplash( float x, float y ) {
revive();
this.x = x;
this.y = y;
left = lifespan;
speed.polar( Random.Float( 3.1415926f ), Random.Float( 10, 20 ) );
}
@Override
public void update() {
super.update();
// alpha: 1 -> 0; size: 1 -> 4
size( 4 - (am = left / lifespan) * 3 );
// color: 0x8844FF -> 0x00FF00
color( ColorMath.interpolate( 0x00FF00, 0x8844FF, am ) );
}
}
@@ -0,0 +1,82 @@
/*
* Pixel Dungeon
* Copyright (C) 2012-2014 Oleg Dolya
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.effects.particles;
import com.watabou.noosa.particles.Emitter;
import com.watabou.noosa.particles.PixelParticle;
import com.watabou.noosa.particles.Emitter.Factory;
import com.watabou.utils.ColorMath;
import com.watabou.utils.Random;
public class PurpleParticle extends PixelParticle {
public static final Emitter.Factory MISSILE = new Factory() {
@Override
public void emit( Emitter emitter, int index, float x, float y ) {
((PurpleParticle)emitter.recycle( PurpleParticle.class )).reset( x, y );
}
};
public static final Emitter.Factory BURST = new Factory() {
@Override
public void emit( Emitter emitter, int index, float x, float y ) {
((PurpleParticle)emitter.recycle( PurpleParticle.class )).resetBurst( x, y );
}
@Override
public boolean lightMode() {
return true;
}
};
public PurpleParticle() {
super();
lifespan = 0.5f;
}
public void reset( float x, float y ) {
revive();
this.x = x;
this.y = y;
speed.set( Random.Float( -5, +5 ), Random.Float( -5, +5 ) );
left = lifespan;
}
public void resetBurst( float x, float y ) {
revive();
this.x = x;
this.y = y;
speed.polar( Random.Float( 360 ), Random.Float( 16, 32 ) );
left = lifespan;
}
@Override
public void update() {
super.update();
// alpha: 1 -> 0; size: 1 -> 5
size( 5 - (am = left / lifespan) * 4 );
// color: 0xFF0044 -> 0x220066
color( ColorMath.interpolate( 0x220066, 0xFF0044, am ) );
}
}
@@ -0,0 +1,93 @@
/*
* Pixel Dungeon
* Copyright (C) 2012-2014 Oleg Dolya
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.effects.particles;
import com.watabou.noosa.particles.Emitter;
import com.watabou.noosa.particles.PixelParticle;
import com.watabou.noosa.particles.Emitter.Factory;
import com.watabou.utils.ColorMath;
import com.watabou.utils.PointF;
import com.watabou.utils.Random;
public class ShadowParticle extends PixelParticle.Shrinking {
public static final Emitter.Factory MISSILE = new Factory() {
@Override
public void emit( Emitter emitter, int index, float x, float y ) {
((ShadowParticle)emitter.recycle( ShadowParticle.class )).reset( x, y );
}
};
public static final Emitter.Factory CURSE = new Factory() {
@Override
public void emit( Emitter emitter, int index, float x, float y ) {
((ShadowParticle)emitter.recycle( ShadowParticle.class )).resetCurse( x, y );
}
};
public static final Emitter.Factory UP = new Factory() {
@Override
public void emit( Emitter emitter, int index, float x, float y ) {
((ShadowParticle)emitter.recycle( ShadowParticle.class )).resetUp( x, y );
}
};
public void reset( float x, float y ) {
revive();
this.x = x;
this.y = y;
speed.set( Random.Float( -5, +5 ), Random.Float( -5, +5 ) );
size = 6;
left = lifespan = 0.5f;
}
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;
}
public void resetUp( float x, float y ) {
revive();
speed.set( Random.Float( -8, +8 ), Random.Float( -32, -48 ) );
this.x = x;
this.y = y;
size = 6;
left = lifespan = 1f;
}
@Override
public void update() {
super.update();
float p = left / lifespan;
// alpha: 0 -> 1 -> 0; size: 6 -> 0; color: 0x660044 -> 0x000000
color( ColorMath.interpolate( 0x000000, 0x440044, p ) );
am = p < 0.5f ? p * p * 4 : (1 - p) * 2;
}
}
@@ -0,0 +1,66 @@
/*
* Pixel Dungeon
* Copyright (C) 2012-2014 Oleg Dolya
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.effects.particles;
import com.watabou.noosa.particles.Emitter;
import com.watabou.noosa.particles.PixelParticle;
import com.watabou.noosa.particles.Emitter.Factory;
import com.watabou.utils.Random;
public class ShaftParticle extends PixelParticle {
public static final Emitter.Factory FACTORY = new Factory() {
@Override
public void emit( Emitter emitter, int index, float x, float y ) {
((ShaftParticle)emitter.recycle( ShaftParticle.class )).reset( x, y );
}
@Override
public boolean lightMode() {
return true;
}
};
public ShaftParticle() {
super();
lifespan = 1.2f;
speed.set( 0, -6 );
}
private float offs;
public void reset( float x, float y ) {
revive();
this.x = x;
this.y = y;
offs = -Random.Float( lifespan );
left = lifespan - offs;
}
@Override
public void update() {
super.update();
float p = left / lifespan;
am = p < 0.5f ? p : 1 - p;
scale.x = (1 - p) * 4;
scale.y = 16 + (1 - p) * 16;
}
}
@@ -0,0 +1,55 @@
/*
* Pixel Dungeon
* Copyright (C) 2012-2014 Oleg Dolya
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.effects.particles;
import com.watabou.noosa.particles.Emitter;
import com.watabou.noosa.particles.PixelParticle;
import com.watabou.noosa.particles.Emitter.Factory;
import com.watabou.utils.Random;
public class SnowParticle extends PixelParticle {
public static final Emitter.Factory FACTORY = new Factory() {
@Override
public void emit( Emitter emitter, int index, float x, float y ) {
((SnowParticle)emitter.recycle( SnowParticle.class )).reset( x, y );
}
};
public SnowParticle() {
super();
speed.set( 0, Random.Float( 5, 8 ) );
lifespan = 1.2f;
}
public void reset( float x, float y ) {
revive();
this.x = x;
this.y = y - speed.y * lifespan;
left = lifespan;
}
@Override
public void update() {
super.update();
float p = left / lifespan;
am = (p < 0.5f ? p : 1 - p) * 1.5f;
}
}
@@ -0,0 +1,62 @@
/*
* Pixel Dungeon
* Copyright (C) 2012-2014 Oleg Dolya
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.effects.particles;
import com.watabou.noosa.particles.Emitter;
import com.watabou.noosa.particles.PixelParticle;
import com.watabou.noosa.particles.Emitter.Factory;
import com.watabou.utils.Random;
public class SparkParticle extends PixelParticle {
public static final Emitter.Factory FACTORY = new Factory() {
@Override
public void emit( Emitter emitter, int index, float x, float y ) {
((SparkParticle)emitter.recycle( SparkParticle.class )).reset( x, y );
}
@Override
public boolean lightMode() {
return true;
};
};
public SparkParticle() {
super();
size( 2 );
acc.set( 0, +50 );
}
public void reset( float x, float y ) {
revive();
this.x = x;
this.y = y;
left = lifespan = Random.Float( 0.5f, 1.0f );
speed.polar( Random.Float( 3.1415926f ), Random.Float( 20, 40 ) );
}
@Override
public void update() {
super.update();
size( Random.Float( 5 * left / lifespan ) );
}
}
@@ -0,0 +1,61 @@
/*
* Pixel Dungeon
* Copyright (C) 2012-2014 Oleg Dolya
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.effects.particles;
import com.watabou.noosa.particles.Emitter;
import com.watabou.noosa.particles.PixelParticle;
import com.watabou.noosa.particles.Emitter.Factory;
import com.watabou.utils.Random;
public class WebParticle extends PixelParticle {
public static final Emitter.Factory FACTORY = new Factory() {
@Override
public void emit( Emitter emitter, int index, float x, float y ) {
for (int i=0; i < 3; i++) {
((WebParticle)emitter.recycle( WebParticle.class )).reset( x, y );
}
}
};
public WebParticle() {
super();
color( 0xCCCCCC );
lifespan = 2f;
}
public void reset( float x, float y ) {
revive();
this.x = x;
this.y = y;
left = lifespan;
angle = Random.Float( 360 );
}
@Override
public void update() {
super.update();
float p = left / lifespan;
am = p < 0.5f ? p : 1 - p;
scale.y = 16 + p * 8;
}
}
@@ -0,0 +1,114 @@
/*
* Pixel Dungeon
* Copyright (C) 2012-2014 Oleg Dolya
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.effects.particles;
import com.watabou.noosa.Game;
import com.watabou.noosa.Group;
import com.watabou.noosa.particles.Emitter;
import com.watabou.noosa.particles.PixelParticle;
import com.watabou.noosa.particles.Emitter.Factory;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.DungeonTilemap;
import com.watabou.utils.PointF;
import com.watabou.utils.Random;
public class WindParticle extends PixelParticle {
public static final Emitter.Factory FACTORY = new Factory() {
@Override
public void emit( Emitter emitter, int index, float x, float y ) {
((WindParticle)emitter.recycle( WindParticle.class )).reset( x, y );
}
};
private static float angle = Random.Float( PointF.PI * 2 );
private static PointF speed = new PointF().polar( angle, 5 );
private float size;
public WindParticle() {
super();
lifespan = Random.Float( 1, 2 );
scale.set( size = Random.Float( 3 ) );
}
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;
}
@Override
public void update() {
super.update();
float p = left / lifespan;
am = (p < 0.5f ? p : 1 - p) * size * 0.2f;
}
public static class Wind extends Group {
private int pos;
private float x;
private float y;
private float delay;
public Wind( int pos ) {
super();
this.pos = pos;
PointF p = DungeonTilemap.tileToWorld( pos );
x = p.x;
y = p.y;
delay = Random.Float( 5 );
}
@Override
public void update() {
if (visible = Dungeon.visible[pos]) {
super.update();
if ((delay -= Game.elapsed) <= 0) {
delay = Random.Float( 5 );
((WindParticle)recycle( WindParticle.class )).reset(
x + Random.Float( DungeonTilemap.SIZE ),
y + Random.Float( DungeonTilemap.SIZE ) );
}
}
}
}
}
@@ -0,0 +1,54 @@
/*
* Pixel Dungeon
* Copyright (C) 2012-2014 Oleg Dolya
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.effects.particles;
import com.watabou.noosa.particles.Emitter;
import com.watabou.noosa.particles.PixelParticle;
import com.watabou.noosa.particles.Emitter.Factory;
import com.watabou.utils.ColorMath;
import com.watabou.utils.Random;
public class WoolParticle extends PixelParticle.Shrinking {
public static final Emitter.Factory FACTORY = new Factory() {
@Override
public void emit( Emitter emitter, int index, float x, float y ) {
((WoolParticle)emitter.recycle( WoolParticle.class )).reset( x, y );
}
};
public WoolParticle() {
super();
color( ColorMath.random( 0x999999, 0xEEEEE0 ) );
acc.set( 0, -40 );
}
public void reset( float x, float y ) {
revive();
this.x = x;
this.y = y;
left = lifespan = Random.Float( 0.6f, 1f );
size = 5;
speed.set( Random.Float( -10, +10 ), Random.Float( -10, +10 ) );
}
}