Ik ben de hele nacht bezig met dit stomme Pong Flash Spelletje, maar er zit een fout in de code en ik kom er niet achter. Het is het aloude ping-pong spel, de bal en de tweede bat reageren niet op de bounderies en schieten daar gelijk doorheen...
stop();
_root.createEmptyMovieClip("controller",1);
_global.enemy_speed = 7.5;
_global.ballYspeed = 5;
_global.ballXspeed = 10;
bat2.ty = 150;
controller.onEnterFrame = function(){
lowerlimit = area._height - (bat2._height + bottom._height);
upperlimit = top._height;
bat2.ty = (ball._y-(ball._height/2));
bat2._y += (bat2.ty-bat2._y)/enemy_speed;
startDrag("bat1",true,bat1._x,upperlimit,bat1._x,lowerlimit);
ball._y += ballYspeed;
ball._x += ballXspeed;
if(ball.hittest(right)){
p1score++;
ball._y = 11;
ball._x = 300;
ballYspeed += 0.5 ;
ballXspeed = ballYspeed*2;
ballYspeed *= 1;
ballXspeed *= -1;
}
if(ball.hittest(left)){
p2score++;
ball._y = 11;
ball._x = 300;
ballYspeed *= -1;
ballXspeed *= 1;
}
if(ball.hittest(bottom) || ball.hittest(top)){
ballYspeed *= -1;
ballXspeed *= 1;
}
if(ball.hittest(bat1)){
ball._x += 5;
ballYspeed *= 1;
ballXspeed *= -1;
}
if(ball.hittest(bat2)){
ball._x -= 5;
ballYspeed *= 1;
ballXspeed *= -1;
}
};
stop();
_root.createEmptyMovieClip("controller",1);
_global.enemy_speed = 7.5;
_global.ballYspeed = 5;
_global.ballXspeed = 10;
bat2.ty = 150;
controller.onEnterFrame = function(){
lowerlimit = area._height - (bat2._height + bottom._height);
upperlimit = top._height;
bat2.ty = (ball._y-(ball._height/2));
bat2._y += (bat2.ty-bat2._y)/enemy_speed;
startDrag("bat1",true,bat1._x,upperlimit,bat1._x,lowerlimit);
ball._y += ballYspeed;
ball._x += ballXspeed;
if(ball.hittest(right)){
p1score++;
ball._y = 11;
ball._x = 300;
ballYspeed += 0.5 ;
ballXspeed = ballYspeed*2;
ballYspeed *= 1;
ballXspeed *= -1;
}
if(ball.hittest(left)){
p2score++;
ball._y = 11;
ball._x = 300;
ballYspeed *= -1;
ballXspeed *= 1;
}
if(ball.hittest(bottom) || ball.hittest(top)){
ballYspeed *= -1;
ballXspeed *= 1;
}
if(ball.hittest(bat1)){
ball._x += 5;
ballYspeed *= 1;
ballXspeed *= -1;
}
if(ball.hittest(bat2)){
ball._x -= 5;
ballYspeed *= 1;
ballXspeed *= -1;
}
};