This will move your ball if no collision is detected.
REM Detect Paddle hitting the ball
IF SPRITE HIT(2,1) = 0
REM Should be something like.
S=SPRITE HIT(2,0)
If S=1 Then Whatever
If S=11 Then Whatever
If S=>0 and s<10 Then Whatever
Here is a simple pong game using sprites.
Hope this helps.
ToXic.
randomize timer()
hide mouse
sync on
sync rate 80
gosub gamesetup
gosub newgame
do
if p1score=10 or p2score=10 then gosub newgame
gosub updatescore
if upkey()=1 then dec bat1y,bat1spd
if downkey()=1 then inc bat1y,bat1spd
bat2y=bally
`bat1y=bally
if bat1y<6 then bat1y=6
if bat1y>416 then bat1y=416
if bat2y<6 then bat2y=6
if bat2y>416 then bat2y=416
s=sprite hit(3,0)
if s=1
repeat
ballangle=rnd(130)
if ballangle > 70 and ballangle <110 then ballangle=1
until ballangle>50
ballx=bat1x+ballspd+9
EndIf
if s=2
repeat
ballangle=rnd(310)
if ballangle > 250 and ballangle <290 then ballangle=1
until ballangle>230
ballx=bat2x-ballspd-9
EndIf
If ballx>639
Inc p1score
ballangle=wrapvalue(0-ballangle)
ballx=ballstartx
bally=ballstarty
endif
If ballx<0
inc p2score
ballangle=wrapvalue(0-ballangle)
ballx=ballstartx
bally=ballstarty
endif
If bally>466 then ballangle=wrapvalue(180-llangle):bally=466
If bally<3 then ballangle=wrapvalue(180-ballangle):bally=3
ballx=newxvalue(ballx,ballangle,ballspd)
bally=newzvalue(bally,ballangle,ballspd)
sprite 1,bat1x,bat1y,1
sprite 2,bat2x,bat2y,2
Sprite 3,ballx,bally,3
sync
loop
updatescore:
ink 0,0
box 235,15,310,60:box 332,15,409,60
ink rgb(225,225,225),0
center text 320,10,str$(p1score) + " " + str$(p2score)
return
newgame:
p1score=0:p2score=0
bat1x=10:bat1y=205
bat2x=620:bat2y=205
ballstartx=315:ballstarty=230
ballx=315:bally=230
bat1spd=4:bat2spd=4
ballspd=4:ballangle=38
sprite 1,bat1x,bat1y,1
sprite 2,bat2x,bat2y,2
Sprite 3,ballx,bally,3
return
gamesetup:
create bitmap 1,20,70
ink rgb(225,225,225),0
Box 1,1,11,61
Get Image 1,1,1,11,61
Get Image 2,1,1,11,61
Get Image 3,1,1,11,11
delete bitmap 1
ink rgb(225,225,225),0
box 1,2,639,3
box 1,477,639,478
box 320,2,321,478
set text font "verdana"
set text size 52
return