Arkanoid z odbijającą paletką xD

PVector location, velocity, paddle;

void setup(){
size(600, 400);
location = new PVector(0.5*width, 0.5*height);
velocity = new PVector(2, 5);
paddle = new PVector(100, 20);
}

void draw(){
background(0, 0, 0);
noStroke();
fill(0, 180, 0);
ellipse(location.x, location.y, 40, 40);
rect(mouseX, height - paddle.y, paddle.x, paddle.y);
location.add(velocity);

if(location.y < 0){
velocity.y = - 1 * velocity.y;
}

if(location.x > width || location.x < 0){
velocity.x = - 1 * velocity.x;
}

if(location.x > mouseX && location.x < (mouseX + paddle.x) && location.y > (height - paddle.y))
{
velocity.y = - 1 * velocity.y;
}

}
Udostępnij znajomym

Zostaw komentarz