Converted ShatteredPD to Build from Gradle
Major Changes: - Shattered now builds effortlessly either from gradle CLI or android studio - Much better dependency management through gradle (although it's not really used atm) - Separate PD-classes repo is now SPD-classes module within main repo
This commit is contained in:
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* Pixel Dungeon
|
||||
* Copyright (C) 2012-2015 Oleg Dolya
|
||||
*
|
||||
* Shattered Pixel Dungeon
|
||||
* Copyright (C) 2014-2016 Evan Debenham
|
||||
*
|
||||
* 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.watabou.noosa.particles;
|
||||
|
||||
import android.graphics.RectF;
|
||||
|
||||
import com.watabou.gltextures.SmartTexture;
|
||||
import com.watabou.noosa.Image;
|
||||
import com.watabou.noosa.particles.Emitter;
|
||||
import com.watabou.utils.Random;
|
||||
|
||||
public class BitmaskEmitter extends Emitter {
|
||||
|
||||
// DON'T USE WITH COMPLETELY TRANSPARENT IMAGES!!!
|
||||
|
||||
private SmartTexture map;
|
||||
private int mapW;
|
||||
private int mapH;
|
||||
|
||||
public BitmaskEmitter( Image target ) {
|
||||
super();
|
||||
|
||||
this.target = target;
|
||||
|
||||
map = target.texture;
|
||||
mapW = map.bitmap.getWidth();
|
||||
mapH = map.bitmap.getHeight();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void emit( int index ) {
|
||||
|
||||
RectF frame = ((Image)target).frame();
|
||||
float ofsX = frame.left * mapW;
|
||||
float ofsY = frame.top * mapH;
|
||||
|
||||
float x, y;
|
||||
do {
|
||||
x = Random.Float( frame.width() ) * mapW;
|
||||
y = Random.Float( frame.height() ) * mapH;
|
||||
} while ((map.bitmap.getPixel( (int)(x + ofsX), (int)(y + ofsY) ) & 0x000000FF) == 0);
|
||||
|
||||
factory.emit( this, index,
|
||||
target.x + x * target.scale.x,
|
||||
target.y + y * target.scale.y );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,169 @@
|
||||
/*
|
||||
* Pixel Dungeon
|
||||
* Copyright (C) 2012-2015 Oleg Dolya
|
||||
*
|
||||
* Shattered Pixel Dungeon
|
||||
* Copyright (C) 2014-2016 Evan Debenham
|
||||
*
|
||||
* 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.watabou.noosa.particles;
|
||||
|
||||
import javax.microedition.khronos.opengles.GL10;
|
||||
|
||||
import android.opengl.GLES20;
|
||||
|
||||
import com.watabou.noosa.Game;
|
||||
import com.watabou.noosa.Group;
|
||||
import com.watabou.noosa.Visual;
|
||||
import com.watabou.utils.PointF;
|
||||
import com.watabou.utils.Random;
|
||||
|
||||
public class Emitter extends Group {
|
||||
|
||||
protected boolean lightMode = false;
|
||||
|
||||
public float x;
|
||||
public float y;
|
||||
public float width;
|
||||
public float height;
|
||||
|
||||
protected Visual target;
|
||||
public boolean fillTarget = true;
|
||||
|
||||
protected float interval;
|
||||
protected int quantity;
|
||||
|
||||
public boolean on = false;
|
||||
|
||||
public boolean autoKill = true;
|
||||
|
||||
protected int count;
|
||||
protected float time;
|
||||
|
||||
protected Factory factory;
|
||||
|
||||
public void pos( float x, float y ) {
|
||||
pos( x, y, 0, 0 );
|
||||
}
|
||||
|
||||
public void pos( PointF p ) {
|
||||
pos( p.x, p.y, 0, 0 );
|
||||
}
|
||||
|
||||
public void pos( float x, float y, float width, float height ) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
|
||||
target = null;
|
||||
}
|
||||
|
||||
public void pos( Visual target ) {
|
||||
this.target = target;
|
||||
}
|
||||
|
||||
public void pos( Visual target, float x, float y, float width, float height ) {
|
||||
pos(x, y, width, height);
|
||||
pos(target);
|
||||
}
|
||||
|
||||
public void burst( Factory factory, int quantity ) {
|
||||
start( factory, 0, quantity );
|
||||
}
|
||||
|
||||
public void pour( Factory factory, float interval ) {
|
||||
start( factory, interval, 0 );
|
||||
}
|
||||
|
||||
public void start( Factory factory, float interval, int quantity ) {
|
||||
|
||||
this.factory = factory;
|
||||
this.lightMode = factory.lightMode();
|
||||
|
||||
this.interval = interval;
|
||||
this.quantity = quantity;
|
||||
|
||||
count = 0;
|
||||
time = Random.Float( interval );
|
||||
|
||||
on = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
|
||||
if (on) {
|
||||
time += Game.elapsed;
|
||||
while (time > interval) {
|
||||
time -= interval;
|
||||
emit( count++ );
|
||||
if (quantity > 0 && count >= quantity) {
|
||||
on = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else if (autoKill && countLiving() == 0) {
|
||||
kill();
|
||||
}
|
||||
|
||||
super.update();
|
||||
}
|
||||
|
||||
protected void emit( int index ) {
|
||||
if (target == null) {
|
||||
factory.emit(
|
||||
this,
|
||||
index,
|
||||
x + Random.Float( width ),
|
||||
y + Random.Float( height ) );
|
||||
} else {
|
||||
if (fillTarget) {
|
||||
factory.emit(
|
||||
this,
|
||||
index,
|
||||
target.x + Random.Float( target.width ),
|
||||
target.y + Random.Float( target.height ) );
|
||||
} else {
|
||||
factory.emit(
|
||||
this,
|
||||
index,
|
||||
target.x + x + Random.Float( width ),
|
||||
target.y + y + Random.Float( height ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw() {
|
||||
if (lightMode) {
|
||||
GLES20.glBlendFunc( GL10.GL_SRC_ALPHA, GL10.GL_ONE );
|
||||
super.draw();
|
||||
GLES20.glBlendFunc( GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA );
|
||||
} else {
|
||||
super.draw();
|
||||
}
|
||||
}
|
||||
|
||||
abstract public static class Factory {
|
||||
|
||||
abstract public void emit( Emitter emitter, int index, float x, float y );
|
||||
|
||||
public boolean lightMode() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* Pixel Dungeon
|
||||
* Copyright (C) 2012-2015 Oleg Dolya
|
||||
*
|
||||
* Shattered Pixel Dungeon
|
||||
* Copyright (C) 2014-2016 Evan Debenham
|
||||
*
|
||||
* 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.watabou.noosa.particles;
|
||||
|
||||
import com.watabou.noosa.Game;
|
||||
import com.watabou.noosa.PseudoPixel;
|
||||
|
||||
public class PixelParticle extends PseudoPixel {
|
||||
|
||||
protected float size;
|
||||
|
||||
protected float lifespan;
|
||||
protected float left;
|
||||
|
||||
public PixelParticle() {
|
||||
super();
|
||||
|
||||
origin.set( +0.5f );
|
||||
}
|
||||
|
||||
public void reset( float x, float y, int color, float size, float lifespan ) {
|
||||
revive();
|
||||
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
|
||||
color( color );
|
||||
size( this.size = size );
|
||||
|
||||
this.left = this.lifespan = lifespan;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
super.update();
|
||||
|
||||
if ((left -= Game.elapsed) <= 0) {
|
||||
kill();
|
||||
}
|
||||
}
|
||||
|
||||
public static class Shrinking extends PixelParticle {
|
||||
@Override
|
||||
public void update() {
|
||||
super.update();
|
||||
size( size * left / lifespan );
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user