This content is archived and may be deprecated or obsolete and is presented in the hope that it may still be useful.
REM Bounce.bbc 0.02 28-May-2005 REM Bounce a card around the screen REM Press SPACE to end program : INSTALL "CardLib.bbc" : REM Setup PROCcdtInit : REM Disable cursor OFF : REM Turn off screen update PROCcdtRedraw(FALSE) : REM Read current client area DIM rect% 16 SYS "GetClientRect", @hwnd%, rect% xmax%=rect%!8-cdtWidth%:ymax%=rect%!12-cdtHeight% : REM Initialise variables x%=RND(xmax%):y%=RND(ymax%):xs%=1:ys%=1:oldtime=TIME-100:moved%=FALSE : REM Set flag if the window has been moved ON MOVE moved%=@msg%:RETURN : REM Main loop REPEAT : REM Change card every 50cs IF TIME-oldtime>=50 card%=RND(52)-1:oldtime=TIME : REM Remove the last card PROCcdtDraw(@memhdc%,x%,y%,1,mdRemove,&FFFFFF) : REM Move cardx x%+=xs%:y%+=ys% : REM Draw card PROCcdtDraw(@memhdc%,x%,y%,card%,mdFaceUp,0) : REM Redraw screen PROCcdtRedrawArea(x%-ABS(xs%),y%-ABS(ys%),cdtWidth%+ABS(xs%*2),cdtHeight%+ABS(ys%*2)) : REM Read new client area IF moved%=5 THEN SYS "GetClientRect", @hwnd%, rect% xmax%=rect%!8-cdtWidth%:ymax%=rect%!12-cdtHeight%:moved%=0 ENDIF : REM Check for card bounce and update directions IF y%>=ymax% OR y%<0 ys%=-ys% IF x%>=xmax% OR x%<0 xs%=-xs% : UNTIL INKEY(0)=32 : REM Finish using the DLL PROCcdtTerm : REM Enable cursor ON : REM Done END