you got the key 5 where say hold2 = true for the right paddle
then here the attachment happens: attachedToPaddle2=true; here:
if ( xpos >= 30+size/2) {
if (ypos > playerpos2-50 && ypos < playerpos2+50) {
if ( ! (hold2 && attachedToPaddle2)) {
xspeed *= -1;
yspeed += (ypos-playerpos2)/5;
}
attachedToPaddle2=true;
}
} else {
attachedToPaddle2=false;
}
wrong:
if ( xpos >= 30+size/2) {
you must check it against the right paddle :
if ( xpos >= width-30-size/2) {
1 Like
ok so now to turn it on i need to type when the 5 key is pressed the hold becomes true?
you have this already!!!
else if (key == '5'){
hold2 = !hold2;
}
but when i press 5 it still doesnt hold, maybe i misplaced the code
did you correct this
if ( xpos >= 30+size/2) {
if (ypos > playerpos2-50 && ypos < playerpos2+50) {
if ( ! (hold2 && attachedToPaddle2)) {
xspeed *= -1;
yspeed += (ypos-playerpos2)/5;
}
attachedToPaddle2=true;
}
} else {
attachedToPaddle2=false;
}
please find the error yourself, understand your programā¦
i changed as you said the if ( xpos >= 30+size/2) to if ( xpos >= width-30-size/2), and added a if (hold2 == true)
does it work?
please find the error yourself, understand your programā¦
how do i play sounds in processing
Look at library sound on the website
I posted the link yesterday