00001 REM TACKER: papa (David Meyer) 00002 REM DATE: 10-Aug-16 18:02:32 00003 REM CHECKED: BASIC-10, bwbasic, bas 00100 rem *********************************************************** 00110 rem *** MCCRCL.BAS - Plot Minecraft block circle 00120 rem *** 2016 David Meyer +JMJ 00130 rem *** 00140 rem *** DESCRIPTION 00150 rem *** A tool for designing circular structures in the game 00160 rem *** Minecraft. Determine blocks within a circle of a given 00170 rem *** and make a 2D plot. 00180 rem *** 00190 rem *** A plot may be block-centered, diameter is odd number 00200 rem *** of blocks and axes run through center of blocks in a 00210 rem *** row/column, or edge-centered, diameter is evn number 00220 rem *** of blocks and axes run along edge between block rows/ 00230 rem *** columns. 00240 rem *** 00250 rem *** VARIABLES 00260 rem *** B Block-centered flag 00270 rem *** C0 Column index 00280 rem *** D Circle diameter blocks 00290 rem *** R Circle radius blocks (excludes axis if block-centered) 00300 rem *** R0 Row index 00310 rem *** S Distance of block (R0,C0) datum from origin 00320 rem *** 00330 rem *** ARRAYS 00340 rem *** Q2 Quadrant semi-chord block counts 00350 rem *** 00360 rem *********************************************************** 00370 rem 00380 goto 800 00390 rem 00400 rem ** SUBROUTINES 00410 rem 00420 rem ** Print exterior block 00430 print " "; 00440 return 00450 rem ** Print interior block 00460 print "[]"; 00470 return 00480 rem ** Print vertical axis [IN: B] 00490 if not (b = -1) then goto 520 00500 print "[|]"; 00510 goto 540 00520 rem ELSE 00530 print "|"; 00540 rem END IF 00550 return 00560 rem ** Print left horizontal axis [IN: B] 00570 if not (b = -1) then goto 600 00580 print "[-"; 00590 goto 620 00600 rem ELSE 00610 print "--"; 00620 rem END IF 00630 return 00640 rem ** Print origin [IN: B] 00650 if not (b = -1) then goto 680 00660 print "[+]"; 00670 goto 700 00680 rem ELSE 00690 print "+"; 00700 rem END IF 00710 return 00720 rem ** Print right horizontal axis [IN: B] 00730 if not (b = -1) then goto 760 00740 print "-]"; 00750 goto 780 00760 rem ELSE 00770 print "--"; 00780 rem END IF 00790 return 00800 rem ** MAIN ROUTINE 00810 rem 00820 dim q2(16) 00830 print "MINECRAFT BLOCK CIRCLE PLOTTER" 00840 print 00850 print "How many blocks is the circle diameter (<=32, 0 to quit)"; 00860 input d 00870 print 00880 rem * Main loop exit check 00890 if not(d=0) then goto 910 00900 stop 00910 rem END IF 00920 let r=int(d/2) 00930 if not (d <> 2*r) then goto 960 00940 let b = -1 00950 goto 980 00960 rem ELSE 00970 let b = 0 00980 rem END IF 00990 rem let b=not fne(d) 01000 rem * Check quadrant blocks by horiz. row 01010 for r0=1 to r 01020 let q2(r0)=0 01030 rem * Check quadrant row blocks by vert. column 01040 for c0=1 to r 01050 if not (b = -1) then goto 1090 01060 rem * Block-centered datum: block vertex closest to origin 01070 let s=sqr((r0-0.5)^2+(c0-0.5)^2) 01080 goto 1130 01090 rem ELSE 01100 rem let s=sqr((r0-1)^2+(c0-1)^2) 01110 rem * Edge-centered datum: block center 01120 let s=sqr((r0-.5)^2+(c0-.5)^2) 01130 rem END IF 01140 rem * Block (R0,C0) inside circle check 01150 if not(s<=r) then goto 1170 01160 let q2(r0)=q2(r0)+1 01170 rem END IF 01180 next c0 01190 next r0 01200 rem * Plot upper semicircle 01210 for r0=r to 1 step -1 01220 rem * Print row block count 01230 if not (b = -1) then goto 1260 01240 print q2(r0)*2+1, 01250 goto 1280 01260 rem ELSE 01270 print q2(r0)*2, 01280 rem END IF 01290 rem * Print filler exterior blocks 01300 for n=1 to r-q2(r0) 01310 gosub 420 01320 next n 01330 rem * Print interior blocks (left quadrant) 01340 for n=1 to q2(r0) 01350 gosub 450 01360 next n 01370 rem * Print vertical axis 01380 gosub 480 01390 rem * Print interior blocks (right quadrant) 01400 for n=1 to q2(r0) 01410 gosub 450 01420 next n 01430 print 01440 next r0 01450 rem * Print horizontal axis (left side) 01460 if not (b = -1) then goto 1490 01470 print d, 01480 goto 1510 01490 rem ELSE 01500 print " ", 01510 rem END IF 01520 for c0=1 to r 01530 gosub 560 01540 next c0 01550 rem * Print origin 01560 gosub 640 01570 rem * Print horizontal axis (right side) 01580 for c0=1 to r 01590 gosub 720 01600 next c0 01610 print 01620 rem * Plot lower semicircle 01630 for r0=1 to r 01640 rem * Print row block count 01650 if not (b = -1) then goto 1680 01660 print q2(r0)*2+1, 01670 goto 1700 01680 rem ELSE 01690 print q2(r0)*2, 01700 rem END IF 01710 rem * Print filler exterior blocks 01720 for n=1 to r-q2(r0) 01730 gosub 420 01740 next n 01750 rem * Print interior blocks (left quadrant) 01760 for n=1 to q2(r0) 01770 gosub 450 01780 next n 01790 rem * Print vertical axis 01800 gosub 480 01810 rem * Print interior blocks (right quadrant) 01820 for n=1 to q2(r0) 01830 gosub 450 01840 next n 01850 print 01860 next r0 01870 print 01880 goto 850 01890 end