I am attempting to convert my AS2 brick breaker game to DBP and have had much success up until the point where the ball hits the paddle. I have now switched the game over to 2d which I have found to be what I wanted in the first place. Well when the ball hits the paddle the ball simply starts bouncing straight up and down instead of bouncing at an angle when it hits the left or right of the paddle. The function that calculates the angle is called CalcBallAngle() in the code. Did I do something wrong there? Please correct me where I am wrong because the AS2 code worked perfectly. I posted my entire code below and the single function by itself underneath the source code. I commented the code and indented to make it easier to read.
Source code:
Rem Project: Brick Break Clone
Rem Created: Thursday, April 07, 2011
Rem ***** Main Source File *****
set display mode 800,600,32
`Lets define some variables.
`Settings for the paddle.
global P = 1
global PX
PX = screen width()/2
global PY = 550
`Settings for the ball.
global B = 2
global BX
BX = screen width()/2
global BY = 450
global BXS
BXS = 10
global BYS
BYS = 10
`Player settings.
global Score = 0
global Lives = 3
`Lets slow the game down.
sync on : sync rate 24
`Load images.
load image "images\paddle.png",1 `Load the paddle.
load image "images\ball.png",2 `Load the ball.
do
set cursor 0,0
cls
`Lets move the ball.
BX = BX + BXS
BY = BY + BYS
`Lets set the ball's boundaries and make it bounce off of the edges.
if BX >= screen width()-image width(2)
BXS = BXS * -1
endif
if BX <= 0
BXS = BXS * -1
endif
if BY >= screen height()-image height(2)
BYS = BYS * -1
endif
if BY <= 0
BYS = BYS * -1
endif
`Center the paddle with the mouse.
PX = mousex() - image width(1) * 0.5
`Set the boundaries for the paddle.
if PX > 744 then PX = 744
if PX < 0 then PX = 0
`Paste the paddle on the screen.
sprite 1,PX,PY,1
sprite 2,BX,BY,2
`Test to see if the ball is hitting the paddle.
if sprite hit(2,1) = 1
CalcBallAngle()
endif
`Draw the screen.
sync
loop
function CalcBallAngle()
`ballPosition is the position the ball is on the paddle.
ballPosition = BX - PX
`hitPercent will convert ballPosition into a percentage.
`All the way to the left is -0.5
`All the way to the right is 0.5
`The center is 0
hitPercent = (ballPosition / (image width(1)-image width(2))) - .5
`Get the hitPercent number and make it a larger number so the ball actually bounces.
BXS = hitPercent * 10
`Make the ball bounce back up.
BYS = BYS * -1
endfunction
CalcBallAngle() Function (by itself):
function CalcBallAngle()
`ballPosition is the position the ball is on the paddle.
ballPosition = BX - PX
`hitPercent will convert ballPosition into a percentage.
`All the way to the left is -0.5
`All the way to the right is 0.5
`The center is 0
hitPercent = (ballPosition / (image width(1)-image width(2))) - .5
`Get the hitPercent number and make it a larger number so the ball actually bounces.
BXS = hitPercent * 10
`Make the ball bounce back up.
BYS = BYS * -1
endfunction
Thanks!

Zeus