Here's the code from my breakout game. "_bounce_it" is the routine that determines which side was hit.
REM ___________________________________________________ COLLISION (BALL N' BRICK)
_collision:
for i=1 to block_total
if map(i).color<>0
object_num = map(i).object
bposx#=map(i).x
bposy#=map(i).y
if abs(bx#-bposx#)<20+radius and abs(by#-bposy#)<7.5+radius
gosub _bounce_it
if map(i).color > 10
play sound sound_brick_break
inc score,10
array delete element map(0), i
dec block_total, 1
dec i, 1
array insert at top fadeObjectOut(0)
fadeObjectOut(0).object = object_num
fadeObjectOut(0).fade = 100
inc fadingObjects, 1
else
`play sound 9
endif
return
endif
endif
next i
RETURN
REM ________________________________________________________________ BOUNCE IT
_bounce_it:
if abs(oldbx#-bposx#)<20.5
if ang#<=180 then ang#=180-ang#
if ang#>180 then ang#=180+(360-ang#)
return
endif
if abs(oldby#-bposy#)<13
if oldbx#<bposx#
if ang#<90
ang#=360-ang#
else
ang#=180+(180-ang#)
endif
endif
if oldbx#>bposx#
if ang#<270
ang#=360-ang#
else
ang#=180+(180-ang#)
endif
endif
else
ang#=wrapvalue(ang#+180)
endif
return
"eureka" - Archimedes