codigo raqueta
int bolaX=400,bolaY=300,velX=5,velY=5,raquetaX,points=0;
int level=1;
void setup(){
size(800,600);
fill(0);
rectMode(CENTER);
}
void draw(){
background(255);
bola();
raqueta();
textSize(20);
text("POINTS: " + points,50,50);
text("LEVEL: " + level,50,70);
if(bolaY>600){
background(0);
textSize(50);
fill(255);
text("GAME OVER",250,200);
stop();
text("FINAL POINTS: " + points,250,300);
text("FINAL LEVEL: " + level,250,400);
}
}
void raqueta(){
raquetaX=mouseX;
if (raquetaX>750){
raquetaX=750;
}
if (raquetaX<50){
raquetaX=50;
}
rect(raquetaX,550,100,10);
}
void bola(){
bolaX=bolaX+velX;
bolaY=bolaY+velY;
if (bolaY>520 && raquetaX-50775){
velX=-velX;
}
if (bolaY<25){
velY=-velY;
}
ellipse (bolaX,bolaY,50,50);
}
Comentarios
Publicar un comentario