' based on code from https://www.youtube.com/watch?v=ybLZyY655iY

CLEAR ALL
BACKGROUND RGB(64,64,64)
PRINT "Use arrow keys to rotate and scale the car, press Esc to quit."
BITMAP 1 LOAD "Car.png" RESCALE 200,100
BITMAP 2 NEW 320,200
TARGET BITMAP 2
INK RGB(255,0,0)
HLINE 0,BITMAP.WIDTH(2)-1,BITMAP.HEIGHT(2)/2
VLINE BITMAP.WIDTH(2)/2,0,BITMAP.HEIGHT(2)-1
SPRITE 1 BIND BITMAP 2 PRIORITY -1 FIT SHOW
SCREEN 5
INK RGB(255,255,255)
s=1
r=0
d=1
DO
    IF d THEN
        ' reset -> origin -> rotate -> scale -> (shear) -> translate -> blit
        CEL RESET
        CEL TRANSLATE -100,-50
        CEL ROTATE r
        CEL SCALE s,s
        'cel shear 0.2,0.2
        CEL TRANSLATE 320,200

        CLEAR BITMAP
        CEL BLIT BITMAP 1
        d=0
    END IF

    fElapsedTime=ELAPSED.TIME

    IF KEY.DOWN(VK_ESC) THEN EXIT DO
    IF KEY.DOWN(VK_LEFT) THEN d=1:r=r+0.2*fElapsedTime:IF r>=360 THEN r=r-360
    IF KEY.DOWN(VK_RIGHT) THEN d=1:r=r-0.2*fElapsedTime:IF r<=0 THEN r=r+360
    IF KEY.DOWN(VK_UP) THEN d=1:s=s+0.005*fElapsedTime:IF s>=5 THEN s=5
    IF KEY.DOWN(VK_DOWN) THEN d=1:s=s-0.005*fElapsedTime:IF s<=0.25 THEN s=0.25
    PAUSE
LOOP
