From fa8439f2ec19c64565979a97c10b33dc7cc0fe01 Mon Sep 17 00:00:00 2001 From: Lawrence Kesteloot Date: Mon, 6 Aug 2018 00:38:42 -0700 Subject: [PATCH] Speed up stars example. --- examples/stars.bas | 66 +++++++++++++++++++++++----------------------- examples/stars.py | 12 ++++----- 2 files changed, 38 insertions(+), 40 deletions(-) diff --git a/examples/stars.bas b/examples/stars.bas index d2f3899..cff3e27 100644 --- a/examples/stars.bas +++ b/examples/stars.bas @@ -1,43 +1,43 @@ 10 GR 20 TS = 40 30 DIM DX(9),DY(9),C(9),X(9),Y(9) -1000 DX(0) = 14 -1005 DY(0) = 13 -1010 C(0) = 14 -1100 DX(1) = 18 -1105 DY(1) = 8 -1110 C(1) = 5 -1200 DX(2) = 7 -1205 DY(2) = -18 +1000 DX(0) = 19 +1005 DY(0) = 0 +1010 C(0) = 7 +1100 DX(1) = -8 +1105 DY(1) = -17 +1110 C(1) = 9 +1200 DX(2) = -14 +1205 DY(2) = -13 1210 C(2) = 12 -1300 DX(3) = 9 -1305 DY(3) = 17 -1310 C(3) = 3 -1400 DX(4) = 19 -1405 DY(4) = 2 +1300 DX(3) = -12 +1305 DY(3) = 15 +1310 C(3) = 5 +1400 DX(4) = -12 +1405 DY(4) = 15 1410 C(4) = 12 -1500 DX(5) = -19 -1505 DY(5) = 0 -1510 C(5) = 4 -1600 DX(6) = -2 -1605 DY(6) = 19 -1610 C(6) = 14 -1700 DX(7) = 0 -1705 DY(7) = -19 -1710 C(7) = 4 -1800 DX(8) = -18 -1805 DY(8) = -7 -1810 C(8) = 4 -1900 DX(9) = 14 -1905 DY(9) = 13 -1910 C(9) = 11 -2100 FOR T = 0 TO TS -2200 FOR I = 0 TO 9 +1500 DX(5) = 19 +1505 DY(5) = 5 +1510 C(5) = 13 +1600 DX(6) = 19 +1605 DY(6) = -1 +1610 C(6) = 5 +1700 DX(7) = 9 +1705 DY(7) = 17 +1710 C(7) = 14 +1800 DX(8) = -12 +1805 DY(8) = 15 +1810 C(8) = 5 +1900 DX(9) = 10 +1905 DY(9) = 16 +1910 C(9) = 13 +2100 T = 0 +2200 I = 0 2210 OX = X(I) : OY = Y(I) 2220 X(I) = 20 + DX(I) * T / TS 2230 Y(I) = 20 + DY(I) * T / TS 2240 COLOR=0 : PLOT OX, OY 2250 COLOR=C(I) : PLOT X(I), Y(I) -2260 NEXT -2300 NEXT -2310 GOTO 2100 +2260 I = I + 1 : IF I < 10 GOTO 2210 +2300 T = T + 1 : IF T = TS THEN T = 0 +2310 GOTO 2200 diff --git a/examples/stars.py b/examples/stars.py index c6ebf33..cf2e448 100644 --- a/examples/stars.py +++ b/examples/stars.py @@ -16,15 +16,13 @@ for i in range(0,10) : c = random.randrange(1,15) print str % {'init' : 10 + i, 'x' : x, 'y' : y, 'c' : c, 'which' : i} -print "2100 FOR T = 0 TO TS" - -print "2200 FOR I = 0 TO 9" +print "2100 T = 0" +print "2200 I = 0" print "2210 OX = X(I) : OY = Y(I)" print "2220 X(I) = 20 + DX(I) * T / TS" print "2230 Y(I) = 20 + DY(I) * T / TS" print "2240 COLOR=0 : PLOT OX, OY" print "2250 COLOR=C(I) : PLOT X(I), Y(I)" -print "2260 NEXT" - -print "2300 NEXT" -print "2310 GOTO 2100" +print "2260 I = I + 1 : IF I < 10 GOTO 2210" +print "2300 T = T + 1 : IF T = TS THEN T = 0" +print "2310 GOTO 2200"