actually I had it that way, i just typed it wrong but it still dosent work the ball just skids along the top wall I'll post the whole code so you can see.
hide mouse
gosub initail_variabels
gosub player_variabels
gosub create_ball_sprite
gosub create_AI
sync rate 0
game=1
repeat
gosub player_input
gosub AI_input
gosub update_screen
`gosub print_values
gosub collision
if mouseclick()=1 then game=0
until game=0
end
initail_variabels:
radius = 20
ballx = 320
bally = 240
ballxdirection = 5
ballydirection = 5
return
update_screen:
sprite 2,ballx,bally,2
ballx = ballx+ballxdirection
bally = bally+ballydirection
sprite 1,paddelx,paddely,1
sprite 3,AI_x,AI_y,1
cls
return
print_values:
set cursor 0,0
print screen fps()
return
collision:
if ballx <0+radius
ballx = 0+radius
ballxdirection=0-ballxdirection
endif
if bally <0+radius
bally = 0+radius
bounce(ballydirection)
A = ballydirection
endif
if ballx >640-radius
ballx = 640-radius
ballxdirection =0-ballxdirection
endif
if bally >480-radius
bally = 480-radius
ballydirection=0-ballydirection
endif
if sprite hit(1,2)
ballxdirection = 0-ballxdirection
ballydirection = 0-ballydirection
endif
if sprite hit(3,2)
ballxdirection = 0-ballxdirection
ballydirection = 0-ballydirection
endif
return
player_variabels:
paddelx = 600
paddely = 240
box 0,0,10,50
get image 1,0,0,10,50
return
player_input:
if upkey()=1 then inc paddely,10
if downkey()=1 then dec paddely,10
return
AI_input:
if AI_y < bally then inc AI_y,AI_speed
if AI_y > bally then dec AI_y,AI_speed
return
create_ball_sprite:
circle ballx,bally,10
get image 2,309,221,331,251
return
create_AI:
AI_x = 40
AI_y = 240
AI_speed = 4
return
Function bounce(a)
a=0-a
endfunction a