mirror of
https://github.com/jneug/zeichenmaschine.git
synced 2026-10-12 09:56:33 +02:00
Viele weitere Beispielprojekt für verschiedene Anwendungen
This commit is contained in:
33
examples/zm_cookieclicker/NumberParticle.java
Normal file
33
examples/zm_cookieclicker/NumberParticle.java
Normal file
@@ -0,0 +1,33 @@
|
||||
import schule.ngb.zm.Updatable;
|
||||
import schule.ngb.zm.shapes.Text;
|
||||
|
||||
public class NumberParticle extends Text implements Updatable {
|
||||
|
||||
double sinOffset, life = 0;
|
||||
|
||||
public NumberParticle( double x, double y, int number ) {
|
||||
super(x,y,"+"+number);
|
||||
sinOffset = random(0.0, PI);
|
||||
life = 1.5;
|
||||
setStrokeColor(255);
|
||||
setFontsize(36);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isActive() {
|
||||
return (life > 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update( double delta ) {
|
||||
if( isActive() ) {
|
||||
double deltaX = sin(sinOffset + life);
|
||||
x += deltaX;
|
||||
y -= 100*delta;
|
||||
|
||||
life -= delta;
|
||||
setStrokeColor(strokeColor, (int) interpolate(0, 255, life / 1.5));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user