xxxxxxxxxx
int x=100, y=100, vx=4, vy=4;
int by;
int ty;
PFont sos;
int escore =0;
PImage grassblock;
PImage bola;
void setup(){
size (606,400);
grassblock = loadImage ("Grass Block.png");
bola = loadImage ("bolavolei.png");
sos = createFont("sos.vlw",24);
textFont(sos);
}
void draw(){
///restrição para que o rebatedor não saia da tela
by=constrain(mouseY,0,height -100);
ty=constrain(mouseY,0,height -100);
x=x+vx;
y=y+vy;
///rebatedor função
if(x<20 && y>by && y<by+100){
vx = -vx;
}
if(x>590 && y>by && y<by+100){
vx = -vx;
}
////caso o pong bate em algum canto da tela ,se tem a velocidede invertida
if(x>width) noLoop();//aumentar a velocidade (-2)
if(y<0 || y>height) vy=-vy-1;///aumentar a velocidade(-1)
///caso ele passe da tela o jogo para!
if(x<0) noLoop();
//não ocorrer bullet miss
if(vx>30 || vx<-30 ) vx=4;
if(vy>30 || vy<-30 ) vy=4;
///if(vx<vx) vx=vx+X;
escore ++;
//texto fonte e cor
background(0);
// sprites //
for (int i=0; i<6; i++) {
for (int j=0; j<4; j++) {
image (grassblock, 101*i, 85*j);
}}
for(int i=0;i<6;i++){
image( grassblock,101*i,-120);}
// rede //
fill(#F0E8E8);
rect(303,0,10,400);
fill(255);
text("pontuação",440,20);
text(escore,450,40);
fill(0);
if(x<0) text( "game over",260,200);///(caso vc perca,,,)
if(x>600) text( "game over",260,200);
fill(255,0,0);
//bolinha que faz ping
image(bola,x-10,y-10);
//raquete de pong
noStroke();
rect(10,by,10,100);
rect(590,by,10,100);
}