I would greatly appreciate it if someone has able to help me make sense on what is going on with my code:
if (direction){
while(dbSpriteX(4) < 900){
controlGame.control();
dbSprite(4,xMove + x, yMove + y, 4);
dbPlaySprite(4, 1, 16, 60);
x+= dbCos(angle) * speed;
y+= dbSin(angle) * speed;
if ( dbSpriteY(4) < computerPaddle){
dbSprite(3,560,computerPaddle +4,3);
dbPlaySprite(3,1,16,60);
computerPaddle+=speed;
dbSync();
}
if (dbSpriteCollision (4, 3) ){
direction = false;
angle = dbRND(20);
break;
}
dbSync ( );
}
}
xMove+=x;
x = 0;
yMove+=y;
y =0;
while(computerPaddle < 150){
dbSprite(3, 560, computerPaddle +4, 3);
computerPaddle+=speed;
}
while(computerPaddle > 150){
dbSprite(3, 560, computerPaddle +4, 3);
computerPaddle-=speed;
}
angle = dbRND(20);
if (!direction){
while(dbSpriteX(4) > -200){
controlGame.control();
dbSprite(4, xMove -x, yMove - y, 4);
dbPlaySprite(4, 1, 16, 60);
x+= dbCos(angle) * speed;
y+= dbSin(angle) * speed;
if (dbSpriteY(4) > computerPaddle){
dbSprite(3,560,computerPaddle +4, 3);
dbPlaySprite(3,1,16,60);
computerPaddle+=speed;
dbSync();
}
if (dbSpriteY(4) < computerPaddle){
dbSprite(3,560,computerPaddle +4, 3);
dbPlaySprite(3, 1, 16, 60);
computerPaddle-=speed;
dbSync();
}
if (dbSpriteCollision (4,2)){
direction = true;
angle = dbRND(20);
break;
}
dbSync();
}
dbSync();
}
xMove-=x;
x=0;
yMove-=y;
y=0;
angle = dbRND(20);
speed++;
while(computerPaddle < 150){
dbSprite(3, 560, computerPaddle +4, 3);
computerPaddle+=speed;
}
while(computerPaddle > 150){
dbSprite(3, 560, computerPaddle +4, 3);
computerPaddle-=speed;
}
I really appreciate anyone's help on this.
My two biggest problems are computer a.i and when the ball bouncing from the wall.
thanks.