Renderer/src/main/java/electrosphere/game/server/effects/ParticleEffects.java
austin ebec7a373e
Some checks failed
studiorailgun/Renderer/pipeline/head There was a failure building this commit
Separation of client and server logic
2023-05-20 19:18:09 -04:00

42 lines
1.7 KiB
Java

package electrosphere.game.server.effects;
import electrosphere.entity.Entity;
import electrosphere.entity.EntityUtils;
import electrosphere.entity.types.particle.ParticleUtils;
import java.util.Random;
import org.joml.Vector3f;
/**
*
* @author amaterasu
*/
public class ParticleEffects {
public static void spawnSparks(Vector3f position, int min, int max){
Random rand = new Random();
int num = (int)(rand.nextFloat() * (max - min)) + min;
for(int i = 0; i < num; i++){
Vector3f direction = new Vector3f(rand.nextFloat() - 0.5f,rand.nextFloat() - 0.5f,rand.nextFloat() - 0.5f).normalize();
float velocity = rand.nextFloat() * 0.01f;
float acceleration = 0.005f;
Entity spark = ParticleUtils.clientSpawnBillboardProjectileParticle("Textures/spark1.png", 15, direction, velocity, acceleration);
EntityUtils.getPosition(spark).set(position);
EntityUtils.getScale(spark).mul(0.03f);
}
}
public static void spawnBloodsplats(Vector3f position, int min, int max){
Random rand = new Random();
int num = (int)(rand.nextFloat() * (max - min)) + min;
for(int i = 0; i < num; i++){
Vector3f direction = new Vector3f(rand.nextFloat() - 0.5f,rand.nextFloat() - 0.5f,rand.nextFloat() - 0.5f).normalize();
float velocity = rand.nextFloat() * 0.001f;
float acceleration = 0.000005f;
Entity spark = ParticleUtils.clientSpawnBillboardProjectileParticle("Textures/bloodsplat1.png", 90, direction, velocity, acceleration);
EntityUtils.getPosition(spark).set(position);
EntityUtils.getScale(spark).mul(0.1f);
}
}
}