i am trying to create a simple paddle game and this is the code i have on the ball but when the ball hits the paddle it is only 50% chance that it works.
Could anyone take a look at this and see what i am doing wrong. Alternitavly if there is a better way of dooing this i would be intrested to hear about it.
Cheers
D
--code for the ball
property pX, pY, pAngle, pVel, xvel, yvel
on beginsprite me
set pX = 320
set pY = 240
set pAngle = 30
set pVel = 10
set xvel = pVel*Cos(pAngle * PI/180)
set yvel = pVel*Sin(pAngle * PI/180)
end beginsprite
on exitframe me
set pX = pX + xvel
set pY = pY + yvel
If pX > 625 then set xvel = -xvel
If pY > 465 then set yvel = -yvel
If pX < 15 then set xvel = -xvel
--if hits paddel
--sprite 3 is the movable paddle and it 70 pixels long
if ( (pY < 50) and ( pY > 15 ) and (pX > (the loch of sprite 3 - 35)) and (pX < (the loch of sprite 3 + 35 )) ) then
set yvel = -yvel
end if
set the loc of sprite ( the spritenum of me ) = point( pX,480 - pY)
end exitframe