how to create a paint splatter effect
in
Programming Questions
•
2 years ago
hello everyone,
I am trying to create a splatter effect to implement in a game- if I use the noLoop function in the Splat class, it stops the movement, but it also stops the movement for my other objects. I thought about using an array and calling random numbers, but I am a little new to Processing, and I can't quite figure out if I should use an array for the angle variable or for another variable- below is my code- any help or hints would be greatly appreciated-
Splat splatter;
void setup(){
size(400,400);
smooth();
splatter = new Splat();
}
void draw(){
background(255);
splatter.display();
splatter.splats();
}
class Splat{
float x;
float y;
float rad;
Splat(){
x = 200;
y = 200;
rad = 17;
}
void display(){
fill(255,243,0);
noStroke();
ellipse(x,y,rad,rad);
}
void splats(){
for ( float i =3; i < 29; i +=.35){
float angle = random(0,TWO_PI);
float splatX = x + cos(angle)*2*i;
float splatY = y + sin(angle)*3*i;
ellipse(splatX,splatY,rad-i,rad-i+1.8);
noLoop();
}
}
}
I am trying to create a splatter effect to implement in a game- if I use the noLoop function in the Splat class, it stops the movement, but it also stops the movement for my other objects. I thought about using an array and calling random numbers, but I am a little new to Processing, and I can't quite figure out if I should use an array for the angle variable or for another variable- below is my code- any help or hints would be greatly appreciated-
Splat splatter;
void setup(){
size(400,400);
smooth();
splatter = new Splat();
}
void draw(){
background(255);
splatter.display();
splatter.splats();
}
class Splat{
float x;
float y;
float rad;
Splat(){
x = 200;
y = 200;
rad = 17;
}
void display(){
fill(255,243,0);
noStroke();
ellipse(x,y,rad,rad);
}
void splats(){
for ( float i =3; i < 29; i +=.35){
float angle = random(0,TWO_PI);
float splatX = x + cos(angle)*2*i;
float splatY = y + sin(angle)*3*i;
ellipse(splatX,splatY,rad-i,rad-i+1.8);
noLoop();
}
}
}
1