Hi again guys, I'm still trying to do my pong and I'm stuck in the collision detection.
Could someone please tellme why the ball doesn't detect the collision with the player 2 pad?
Thanks in advance.
P.S: The images used are white so if you load the page and don'g see anything it's ok, they are in the upper left corner.
http://img252.imageshack.us/img252/5945/p00qm3.png
http://img252.imageshack.us/img252/7951/b00hq3.png
http://img209.imageshack.us/img209/2294/n00he7.png
hide mouse
set display mode 800,600,32
sync rate 60
cls
vel_bola_x=2
vel_bola_y=2
m2=5
p1_izq=017
p1_der=031
p1_bot=057
p2_izq=200
p2_der=208
p2_bot=082
color backdrop 0
load image "P00.png",1
sprite 1,(screen width()/2-screen width()/2)+25,screen height()/2-20,1
sprite 2,screen width()-30,screen height()/2-20,1
load image "N00.png",2
for m=4 to screen height()/10
sprite m,(screen width()/2)-5,m2,2
inc m2,20
next m
load image "B00.png",3
sprite 3,31,(screen height()/2)-5,3
pad_p1_y=sprite y(1)
pad_p1_x=sprite x(1)
pad_p2_y=sprite y(2)
pad_p2_x=sprite x(2)
bola_x=sprite x(3)
bola_y=sprite y(3)
repeat
if keystate(p1_izq)=1 and keystate(p1_bot)=1
repeat
if sprite hit(3,2)>1
vel_bola_y=vel_bola_y*-1
endif
if bola_y<5 or bola_y>screen height()-15
vel_bola_y=vel_bola_y*-1
`vel_bola_x=vel_bola_x*-1
endif
` if bola_y<5 or bola_y>screen height()-5
` vel_bola_y=vel_bola_y*-1
` endif
bola_x=bola_x+vel_bola_x
bola_y=bola_y-vel_bola_y
sprite 3,bola_x,bola_y,3
if keystate(p1_izq)=1 and pad_p1_y>5 then pad_p1_y=pad_p1_y-5
sprite 1,pad_p1_x,pad_p1_y,1
if keystate(p1_der)=1 and pad_p1_y<screen height()-45 then pad_p1_y=pad_p1_y+5
sprite 1,pad_p1_x,pad_p1_y,1
if keystate(p2_izq)=1 and pad_p2_y>5 then pad_p2_y=pad_p2_y-5
sprite 2,pad_p2_x,pad_p2_y,1
if keystate(p2_der)=1 and pad_p2_y<screen height()-45 then pad_p2_y=pad_p2_y+5
sprite 2,pad_p2_x,pad_p2_y,1
until keystate(082)=1
endif
if keystate(p1_der)=1 and keystate(p1_bot)=1
repeat
if sprite hit(3,2)>1
vel_bola_y=vel_bola_y*-1
endif
if bola_y<5 or bola_y>screen height()-15
vel_bola_y=vel_bola_y*-1
`vel_bola_x=vel_bola_x*-1
endif
` if bola_y<5 or bola_y>screen height()-5
` vel_bola_y=vel_bola_y*-1
` endif
bola_x=bola_x+vel_bola_x
bola_y=bola_y+vel_bola_y
sprite 3,bola_x,bola_y,3
if keystate(p1_izq)=1 and pad_p1_y>5 then pad_p1_y=pad_p1_y-5
sprite 1,pad_p1_x,pad_p1_y,1
if keystate(p1_der)=1 and pad_p1_y<screen height()-45 then pad_p1_y=pad_p1_y+5
sprite 1,pad_p1_x,pad_p1_y,1
if keystate(p2_izq)=1 and pad_p2_y>5 then pad_p2_y=pad_p2_y-5
sprite 2,pad_p2_x,pad_p2_y,1
if keystate(p2_der)=1 and pad_p2_y<screen height()-45 then pad_p2_y=pad_p2_y+5
sprite 2,pad_p2_x,pad_p2_y,1
until keystate(082)=1
endif
until mouseclick()=2
end