new to processing, have a few questions....
in
Programming Questions
•
1 year ago
Hello everyone, i'm new to processing and have been learning for about 4 days now. I am trying to make my first game (pretty low quality) , the basic idea is that the cursor moves around a picture while a red dot bounces around the screen. the red dot is meant to be the laser sight of a sniper, and your goal is to try not to get hit. I was wondering how i can make it so whenever the dot goes over the picture, a sound is triggered, the screen flashes red, and a blood splatter appears and fades away where the picture was "shot". it would be very helpful is someone send a couple links explaining, or explain it yourself if you would like. Just having the code i am looking for by itself wouldn't be very helpful. Also here is the code i am working on below.
PImage img,vip;
float y, xvelocity, r, x, yvelocity,restitution;
void setup ()
{
size(567, 381);
img = loadImage("stage.jpg");
vip = loadImage("vip.jpg");
r=10;
y=250;
x=250;
yvelocity=3;
xvelocity=6;
restitution=1;
}
void draw ()
{
y=y+yvelocity;
// if the ball the past the bottom of the screen
if (y+r > height)
{
yvelocity=yvelocity* - restitution;
y= height-r;
}
if (y-r < 0)
{
yvelocity=yvelocity* - restitution;
y = 0 + r;
}
{
x=x+xvelocity;
}
if (x-r < 0 )
{
xvelocity=xvelocity* - restitution;
x= 0 + r;
}
if (x+r > width)
{
xvelocity=xvelocity* - restitution;
x = width - r;
}
background(255);
imageMode(CORNER);
image(img, 0, 0);
imageMode(CENTER);
image(vip,mouseX,mouseY);
stroke(255, 64, 0);
fill(100,30,0);
ellipse(x, y, r*2, r*2);
stroke(0);
fill(30,100,0);
}
1