CLEAR ALL
BACKGROUND RGB(50,50,50)
PRINT "Use the arrow keys to move, space to toggle bit mask, ESC to quit."
BITMAP 1 LOAD "run_000.png"
SPRITE 1 BIND BITMAP 1 SHOW XYSIZE 2,2 XYSTEP 2,2
SPRITE 2 BIND BITMAP 1 SHOW XYSIZE 2,2 XYSTEP 2,2
BITMAP 2 NEW 640,400
SPRITE 3 BIND BITMAP 2 XYSIZE 2,2
TARGET BITMAP 2
c1=RGB(255,0,0):x1=320:y1=200
c2=RGB(0,0,255):x2=320:y2=200
t=0
DO
    IF KEY.PRESSED(27) THEN EXIT DO
    IF KEY.DOWN(VK_LEFT) THEN x2=x2-1:IF x2<0 THEN x2=0
    IF KEY.DOWN(VK_RIGHT) THEN x2=x2+1:IF x2>640 THEN x2=640
    IF KEY.DOWN(VK_UP) THEN y2=y2-1:IF y2<0 THEN y2=0
    IF KEY.DOWN(VK_DOWN) THEN y2=y2+1:IF y2>400 THEN y2=400
    IF KEY.PRESSED(VK_SPACE) THEN
        IF t=0 THEN
            SPRITE 1 HIDE
            SPRITE 2 HIDE
            SPRITE 3 SHOW
        ELSE
            SPRITE 1 SHOW
            SPRITE 2 SHOW
            SPRITE 3 HIDE
        END IF
        t=1-t
    END IF
    SPRITE 1 MOVE x1,y1
    SPRITE 2 MOVE x2,y2
    CLEAR BITMAP
    PIXEL OPERATOR PXO_COLLISION
    INK c1
    BLIT BITMAP 1 TO x1,y1 ALIGN 0,0
    INK c2
    BLIT BITMAP 1 TO x2,y2 ALIGN 0,0
    IF PIXEL.COLLISION(c1,c2) THEN
        BACKGROUND RGB(100,100,100)
    ELSE
        BACKGROUND RGB(50,50,50)
    END IF
    PAUSE
LOOP
