Created
February 3, 2024 22:34
-
-
Save avorobey/86570cdb3d5770f5dbd2e8900e1d7175 to your computer and use it in GitHub Desktop.
GW-BASIC program that displays two balls bouncing around on a tiled field "eating into" each other's spaces.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 SCREEN 9:VIEW | |
90 DEFINT A-Z | |
95 X0=200:Y0=30 | |
100 LINE (X0,Y0)-(X0+299,Y0+299),3,BF | |
120 LINE (X0+150,Y0)-(X0+299,Y0+299),1,BF | |
150 DIM A%(200):DIM B%(200) | |
155 LINE (543,23)-(557,37),3,BF:LINE(563,23)-(577,37),1,BF | |
160 CIRCLE (550,30),7,1,0,2*3.14,1:CIRCLE (570,30),7,3,0,2*3.14,1 | |
170 PAINT (550,30),1:PAINT(570,30),3 | |
180 GET (543,23)-(557,37),A%:GET (563,23)-(577,37),B% | |
194 VIEW SCREEN (X0,Y0)-(X0+299,Y0+299) | |
195 X1=X0:Y1=Y0+30:DX1=1:DY1=1 | |
196 X2=X0+180:Y2=Y0+60:DX2=-1:DY2=1 | |
198 DEF FNA(X)=X*(SGN(X+1)*14+1):DEF FNB(X)=X*15 | |
200 IF POINT(X1+FNA(DX1),Y1) <> 3 THEN LINE (X1+FNB(DX1),Y1)-(X1+FNB(DX1)+14,Y1+14),3,BF:DX1=-DX1 | |
205 IF POINT(X1,Y1+FNA(DY1)) <> 3 THEN LINE (X1,Y1+FNB(DY1))-(X1+14,Y1+FNB(DY1)+14),3,BF:DY1=-DY1 | |
210 IF POINT(X1+FNA(DX1),Y1+FNA(DY1)) <> 3 THEN LINE(X1+FNB(DX1),Y1+FNB(DY1))-(X1+FNB(DX1)+14,Y1+FNB(DY1)+14),3,BF:DX1=-DX1:DY1=-DY1 | |
215 IF POINT(X2+FNA(DX2),Y2) <> 1 THEN LINE (X2+FNB(DX2),Y2)-(X2+FNB(DX2)+14,Y2+14),1,BF:DX2=-DX2:GOTO 215 | |
220 IF POINT(X2,Y2+FNA(DY2)) <> 1 THEN LINE (X2,Y2+FNB(DY2))-(X2+14,Y2+FNB(DY2)+14),1,BF:DY2=-DY2:GOTO 215 | |
225 IF POINT(X2+FNA(DX2),Y2+FNA(DY2)) <> 1 THEN LINE(X2+FNB(DX2),Y2+FNB(DY2))-(X2+FNB(DX2)+14,Y2+FNB(DY2)+14),1,BF:DX2=-DX2:DY2=-DY2:GOTO 215 | |
250 LINE (X1,Y1)-(X1+14,Y1+14),3,B | |
255 LINE (X2,Y2)-(X2+14,Y2+14),1,B | |
260 PUT (X1+DX1,Y1+DY1),A%,PSET | |
265 PUT (X2+DX2,Y2+DY2),B%,PSET | |
270 X1=X1+DX1:Y1=Y1+DY1 | |
275 X2=X2+DX2:Y2=Y2+DY2 | |
300 GOTO 200 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment