Skip to content

Commit

Permalink
Particles
Browse files Browse the repository at this point in the history
  • Loading branch information
Arinerron committed Apr 1, 2017
1 parent 0f0ba0d commit f031dae
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
19 changes: 16 additions & 3 deletions res/tileset.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
# - ondeath:<command> - Executes when the player dies on the tile
# - onentry:<command> - Executes when the player touches the tile
# - onexit:<command> - Executes when the player leaves
# - ontouch:<command> - Executes while the player is in the tile
#
# [commands] config:
#
Expand Down Expand Up @@ -89,7 +90,7 @@
S null spawn replace=tiles/dirt
D tiles/dirt event={onmove:a}
. tiles/water speed=0.2 nojump
L tiles/lava fluid nojump dangerous default animation={500,tiles/lava,tiles/lava2,tiles/lava3,tiles/lava4}
L tiles/lava fluid nojump default event={ontouch:lava,ondeath:lavadie} animation={500,tiles/lava,tiles/lava2,tiles/lava3,tiles/lava4} dangerous
C tiles/dirt checkpoint
_ tiles/ice speed=0.4 acceleration=0.0008 nojump slippery particle={color:#A1CAFF,count:1,iteration:35,lifetime:400,front:true,xacceleration:[-0.02|0.02],yacceleration:[-0.02|0.02]}
G tiles/gravel acceleration=0.1 speed=0.5 event={onmove:c}
Expand All @@ -115,16 +116,28 @@ R tiles/dirt speed=0.5 filter=0

a (
particle={color:#D2691E,count:1,iteration:25,lifetime:500,front:false};
particle={color:#5B2D00,count:1,iteration:25,lifetime:500,xacceleration:[-0.001|0.001],yacceleration:[-0.001|0.001],front:false}
particle={color:#5B2D00,count:1,iteration:25,lifetime:500,front:false}
)

b (
a;a;a;a;a;a;a;a;a;a;a;
sound=derp;
)

lava (
particle={color:#FFFF00,lifetime:200,count:5,iteration:25,xacceleration:[-0.075|0.075],yacceleration:-0.05};
particle={color:#FFA500,lifetime:200,count:5,iteration:25,xacceleration:[-0.075|0.075],yacceleration:-0.05};
particle={color:#F3F315,lifetime:100,count:5,iteration:25,xacceleration:[-0.01|0.01],yacceleration:-0.01,front:true};
)

lavadie (
particle={color:#FFFF00,lifetime:200,count:25,iteration:1,xacceleration:[-0.075|0.075],yacceleration:-0.05};
particle={color:#FFA500,lifetime:200,count:25,iteration:1,xacceleration:[-0.075|0.075],yacceleration:-0.05};
particle={color:#F3F315,lifetime:100,count:20,iteration:1,xacceleration:[-0.01|0.01],yacceleration:-0.01,front:true};
)

c (
particle={color:#A9A9A9,count:5,front:false,iteration:35,lifetime:800,xacceleration:[-0.001|0.001],yacceleration:[-0.001|0.001]};
particle={color:#A9A9A9,count:5,front:false,iteration:35,lifetime:800};
)

[entities]
Expand Down
8 changes: 6 additions & 2 deletions src/game/Game.java
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,8 @@ public void run() {
// tick the game dev off ;)
tick();

dispatchEvent("ontouch");

// do particle stuff, and calculate speed
new Thread(new Runnable() {@Override public void run() {
BufferedImage particles_front = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
Expand Down Expand Up @@ -547,6 +549,7 @@ else if(yacceleration < -speed)
System.out.println("null!\nnull!\nnull!\nnull!\nnull!\nnull!\nnull!\nA severe error occured.");
System.exit(1);
}

updateImage();
threadlocked = false;
} else
Expand Down Expand Up @@ -617,10 +620,11 @@ public void kill() {

// reset and particles around player
public void respawn() {
reset(); // Game game, double x, double y, Color color, int lifetime, int number
reset();

dispatchEvent("ondeath");


java.util.List<Particle> particles = Particle.randomlySpread(this, x + half, y + half, Color.GREEN, 600, 100);

for(Particle particle : particles) {
Expand All @@ -630,7 +634,7 @@ public void respawn() {
particle.color = new Color(r, g, b);
particle.xacceleration = (Math.random() - 0.5) / 3;
particle.yacceleration = (Math.random() - 0.5) / 3;
particle.lifetime = (int)(Math.random() * 150);
particle.lifetime = (int)(Math.random() * (Math.random() * (Math.random() * 600)));
particle.front = random.nextBoolean();

this.particles.add(particle);
Expand Down

0 comments on commit f031dae

Please sign in to comment.