Load this little demo. Hopefully, it will explain everything you need to know. Essentially, a yellow pixel will travel through a red outlined box until it sees a red pixel; and then the yellow pixel will reverse direction. And so on.
Normally, all you have to do is interrogate the point position with IF POINT(X, Y) = such and such color THEN branch to a different routine.
I have included two lines that show what the colors are on two spots on the screen, so you'll know this can be done, also.
Hope this helps.
Dr. Jon
SCREEN 12
CLS
LINE (0, 45)-(100, 55), 4, B
COLOR 7
LOCATE 1, 1: PRINT "The color at POINT(50,50) ="; POINT(50, 50)
LOCATE 2, 1: PRINT "The color at POINT(100,50) ="; POINT(100, 50)
LOCATE 6, 1: PRINT "Hit Esc"
x = 1 ' 1 makes the not so bouncing ball go forward. -1 makes it go back.
y = 2 ' starting position on the left side
a:
a$ = INKEY$: IF a$ <> "" THEN END
y = y + x
PSET (y - x, 50), 0 ' trailing black pixel
PSET (y, 50), 14 ' the not so bouncing ball
IF POINT(y + 1, 50) = 4 THEN x = -1 ' if point is color 4 (right side), go back
IF POINT(y - 1, 50) = 4 THEN x = 1 ' if point is color 4 (left side), go forward
FOR t = 1 TO 15000: NEXT ' delay loop
GOTO a