Time to give this ol' Thread a dust down, yesterday I came across an earlier Bouncing Ball Demo I made in BASIC, which is Text Based in nature (using standard LOCATE, PRINT to display & remove the Ball which is a standard "O"), so it moves around the screen really fast, the general idea being I could setup a Window (which I have) and bounce it around that.
Today I thought that would be a good example to stick a background pattern into the Window and have the Ball Bouncing over the top of that, which I thought this would be a good example to use the Transparency Command Code in something simple, which could help me with more complicated programs which use it.
10 DIM board$(11,25):GOSUB 1000
20 GOSUB 160:WINDOW wx1%,wx2%,wt%,wb%:PAPER 1: PEN 0: CLS
30 FOR y%=1 TO 25:FOR x%=1 TO 11:BORDER 3:INK 0,3:INK 2,9:PEN 2:LOCATE x%,y%:PRINT board$(x%,y%);:NEXT x%:NEXT y%
40 x%=0:y%=0:xd%=1:yd%=1
50 WHILE INKEY(47)=-1
60 x%=x%+xd%:y%=y%+yd%:oldx%=x%:oldy%=y%
70 PRINT CHR$(22);CHR$(1);:LOCATE x%,y%:PEN 0:PRINT "O"
80 PRINT CHR$(22);CHR$(0);
90 CALL &BD19:CALL &BD19
100 LOCATE oldx%,oldy%:PEN 2:PRINT board$(oldx%,oldy%)
110 IF x%=sx2% THEN xd%=-1
120 IF x%=sx1% THEN xd%=1
130 IF y%=wb% THEN yd%=-1
140 IF y%=wt% THEN yd%=1
150 WEND:MODE 2:PAPER 0:PEN 1:CALL &BC02:END
160 MODE 0:wx1%=5:wx2%=15:wt%=1:wb%=25:sx1%=1:sx2%=11:RETURN
1000 FOR y%=1 TO 25
1010 FOR x%=1 TO 11
1020 board$(x%,y%)=CHR$(207)
1030 NEXT x%:NEXT y%:RETURN
So what I did in this case is setup an 2 Dimensional String based Array, used a subroutine (Line 1000-1030) to place the Background pattern into the Array, Line 20 is one of the original lines which leads to another subroutine (Line 160 - which is also original), which changes the screen mode & sets up the Co-ordinates for the Window before returning. Line 30 is an absolute joke, which more or less does what the subroutine at 1000-1030 does minus printing the result, plus it's constantly changing the INKs, BORDERs & PENs in that Nested Loop, lagging the program even more, sadly it's come to this cause the original program is also weird - a "MODE 0" in a subroutine at the end of the program for example. I couldn't stand the original program just having a GOTO 60 where line 150 now resides, so I changed it to a WHILE loop which exits when Space is pressed & plus I'm resetting the screen INKs and PAPER & PEN colours back to the default colours because I seem to get a little irritated these days by ESCaping from the program and changing everything back to the way it was. Line 40 sets up the positions for the "O" and the Direction it's heading. Initially I had X% & Y% set to 1, but because I'm adding 1 (Line 60) before display the ball, I've changed them to 0 so that when it comes to display it, it will show up in 1,1 and not 2,2 which is what the original did. Line 50 is the Loop - Space Bar will exit the program and restore all the screen colours. Line 60 relates to line 40, does all the work of working out where the Ball will be position next, I've also setup oldx% & oldy% which is used for the 2D Array. The opening Command Code in Line 70 activates the Transparency, so by this stage I've got my Window setup, the background pattern is there, so to make it appear as if the Ball is positioned over the Background pattern, I can use this command to activate the Transparency, LOCATE the position for the Ball & then place the Ball there. Line 80 is the reverse, so it switches it off, I'm unsure if this is needed, I've seen other examples have it there, though in my case in Line 90 I'm doing a Frame Flyback the 464 way, and then in line 100 I'm restoring the position from where the Ball was, so it restores the background pattern. Initially I thought I'd need line 80 because I'm moving the ball, in this case it's a simple process of alternating between Ball & Background, so it looks like the Ball is moving across the Background. Lines 110-140 are merely there as part of the original program to check where the ball is and if it's hitting a marker, so then it can bounce back the other way. Line 150 is where the Loop finishes and where the program Exits back to BASIC with all the colours restored.
Updated: Before anyone downloads that old spaghetti version of my program, I've updated it, I'll keep the old one on show here in case anyone wants to see how Bad it is.

Another thing I updated in it too is in the old version, once you exited the program and typed in CAT there would be a long pause before displaying the Directory and then another pause before coming up with Ready. Apparently this is because I'm using a 464, a 6128 doesn't seem to have this problem, so what was happening was my 2D array was doing something which was holding up the Disc Drive, so once the program exits and I have no need for the Array, it gets erased, which resolves the Disk Drive hold up. This new program is a bit more polished, though a bit tricky to sort things out, which is why the original has things scattered around in it.