Hi,
I can get the bat to move towards the Bat and the ball to stop at the bat but it doesn't move in the opposite direction.
Would be very greatful if anyone could help.
REM /// set display mode and sync rate
set display mode 800,600,32
hide mouse
REM /// Draw box then snach to create image.
box 200,200,240,300
get image 1,200,200,240,300
box 10,10,520,20
get image 2,10,10,520,20
filledcircle(50,50,10)
get image 3,40,40,60,60
sync on
`This will turn on the background
backdrop on
`This will give you black bacground
color backdrop rgb(0,0,0)
REM /// ball speed and initial position
ball_x=400
ball_y=300
speed_x=0
speed_y=0
random_direction_x=0
do
REM /// pad
sprite 1, 150,250 + pad_x,1
sprite 2, 650,250 + pad_y,1
REM /// Walls
sprite 3, 160,140,2
sprite 4, 160,450,2
REM /// Ball
Sprite 5, ball_x,ball_y,3
REM /// ball movement
if keystate(57)=1 then speed_x=1
ball_x = ball_x + speed_x
ball_y = ball_y + speed_y
If sprite hit(5, 2)
speed_x = speed_x * -1
ball_x = ball_x + speed_x
EndIf
REM /// Input for pads
if upkey()=1 and pad_x>-100 then pad_x = pad_x - 1
if downkey()=1 and pad_x<100 then pad_x = pad_x + 1
sync
loop
function filledcircle(x,y,r)
for count=1 to r
box x-count,y-sqrt((r^2)-(count^2)),x+count,y+sqrt((r^2)-(count^2))
next count
endfunction
Thanks,
HeadlessJC