I am pretty bad at math but I wish to learn soon enough. My question is right now how I would get a random direction for my blood particles to travel. Here is my Blood class :
public class Blood {
private int x, y, direction, speed = 3, delta = 0;
private boolean isCompleted = false;
public Blood(int x, int y){
this.x = x;
this.y = y;
direction = (int) ((Math.random() * 360) % 360);
}
public void render(Graphics g){
g.pushTransform();
g.setColor(new Color(255, 0, 0, 255));
g.fillRect(x, y, 2, 2);
g.popTransform();
}
public void update(){
delta += 1;
if(delta >= 10){
destroy();
}
x += direction+speed;
y += direction+speed;
}
public void destroy() {
isCompleted = true;
}
public boolean getCompleted(){
return isCompleted;
}
}
This is handled by a Blood Emitter class that has an array of blood and what not, but that is not what I am asking anyways. How would you get the random direction for the blood to go?