Ashir
First of all, why not use sprites to move the ball and paddles instead of clearing and re-drawing the screen every time? This is a lot of unnecessary work that you are coding.
From what I can tell, you need to press 'W' and hold down the space bar in order for the ball to even move. When it does get to the top, it bounces along the top without coming back down as you have said.
The code that you had needed some work. Rather than try to tell you what I would recommend, it was easier to re-write some of it. Here it is:
hide mouse
randomize timer()
set display mode 800,600,32
sync on : sync rate 60
backdrop off
color backdrop 0
cls
pad_p1_izq=25
pad_p1_sup=280
pad_p1_der=30
pad_p1_inf=320
pad_p2_izq=775
pad_p2_sup=280
pad_p2_der=780
pad_p2_inf=320
bola_r=5
bola_x1=35
bola_y1=296
bola_x2=770
bola_y2=296
vel_bola_x1=2
vel_bola_y1=2
vel_bola_x2=2
vel_bola_y2=2
borde=5
cls
ink rgb(255,0,0),0
circle bola_r,bola_r,bola_r
get image 1,0,0,(bola_r*2)+1,(bola_r*2)+1
cls
ink rgb(0,0,255),0
circle bola_r,bola_r,bola_r
get image 2,0,0,(bola_r*2)+1,(bola_r*2)+1
sprite 1,bola_x1,bola_y1,1
`sprite 2,bola_x2,bola_y2,2
cls
ink rgb(255,0,0),0
box 25,280,30,320
get image 3,25,280,31,321
ink rgb(0,0,255),0
box 775,280,780,320
get image 4,775,280,781,321
sprite 3,pad_p1_izq,pad_p1_sup,3
sprite 4,pad_p2_izq,pad_p2_sup,4
cls
ink rgb(255,255,255),0
red_izquierdo=395
red_superior=5
red_inferior=405
red_derecho=15
for i=1 to 30
box red_izquierdo,red_superior,red_inferior,red_derecho
inc red_superior,20
inc red_derecho,20
next i
get image 5,395,5,406,599
cls
sprite 5,395,5,5
p1_izq=017
p1_der=031
p1_bot=057
p2_izq=200
p2_der=208
p2_bot=082
bola_x=35
bola_y=296
do
if bola_y1<=5 or bola_y1>=595
vel_bola_y1=vel_bola_y1*-1
endif
bola_x1=bola_x1+vel_bola_x1
bola_y1=bola_y1+vel_bola_y1
sprite 1,bola_x1,bola_y1,1
if keystate(p1_izq)=1 and pad_p1_sup>5 then pad_p1_sup=pad_p1_sup-5 : sprite 3,pad_p1_izq,pad_p1_sup,3
if keystate(p1_der)=1 and pad_p1_sup<595 then pad_p1_sup=pad_p1_sup+5 : sprite 3,pad_p1_izq,pad_p1_sup,3
if keystate(p1_der)=1 and keystate(p1_bot)=1
cls
mesa()
bola_x2=bola_x2+vel_bola_x2
bola_y2=bola_y2+vel_bola_y2
` sprite 2,bola_x2,bola_y2,2
endif
sync
loop
end
function mesa()
`De la linea xx a la linea xx dibujo en pantalla la red mediante un ciclo for...next para ahorrar lineas de codigo.
`Las 4 variables indican los limites izquierdo, superior, inferior y derecho de los cuadros que componen la red.
`De la linea xx a la linea xx dibujo en pantalla los bordes de la mesa
` box 0,0,800,5
` box 0,595,800,600
`De la linea xx a la linea xx dibujo las raquetas en pantalla
endfunction
I have replaced the constant screen redraws with sprites. I have shortened your do-loop considerably. I have made it so that you can used the 'W' key to move the left paddle up and the 'S' key to move it down. I left the coding of the right paddle to you. The ball bounces and moves correctly now, but it basically will move off the right side of the screen. You need to put in the code to check whether or not the players missed the ball. I left the mesa() function there, but it was not necessary to call it in the new code, so you could just delete it if you want.
Hope this helps.
LB