mirror of
https://github.com/inexorabletash/jsbasic.git
synced 2024-12-29 08:33:29 +00:00
Add samples by Gregg Buntin
This commit is contained in:
parent
3cb6079d58
commit
2553fe88ea
@ -73,6 +73,7 @@ By <a href="mailto:inexorabletash@gmail.com">Joshua Bell</a>
|
|||||||
<option value="sample.hangman"> Hangman (Mike Gleason)</option>
|
<option value="sample.hangman"> Hangman (Mike Gleason)</option>
|
||||||
<option value="sample.raindrops"> Catch the Raindrop (Nicholas Merchant)</option>
|
<option value="sample.raindrops"> Catch the Raindrop (Nicholas Merchant)</option>
|
||||||
<option value="sample.jot"> JOT (Mike Gleason)</option>
|
<option value="sample.jot"> JOT (Mike Gleason)</option>
|
||||||
|
<option value="sample.miniindy"> Mini Indy (Gregg Buntin)</option>
|
||||||
|
|
||||||
<option disabled>____________________________________________</option>
|
<option disabled>____________________________________________</option>
|
||||||
<option disabled>Graphics</option>
|
<option disabled>Graphics</option>
|
||||||
@ -94,6 +95,9 @@ By <a href="mailto:inexorabletash@gmail.com">Joshua Bell</a>
|
|||||||
<option value="sample.mandelbrot2"> Mandelbrot Set in Color</option>
|
<option value="sample.mandelbrot2"> Mandelbrot Set in Color</option>
|
||||||
<option value="sample.steve"> Steve (Nicola Foggi)</option>
|
<option value="sample.steve"> Steve (Nicola Foggi)</option>
|
||||||
<option value="sample.logo"> Apple Logo (Brendan Robert)</option>
|
<option value="sample.logo"> Apple Logo (Brendan Robert)</option>
|
||||||
|
<option value="sample.loresdrawing"> Graphics Drawing (Gregg Buntin)</option>
|
||||||
|
<option value="sample.calculatedimage"> Calculated Image (Gregg Buntin)</option>
|
||||||
|
<option value="sample.xmastree"> Christmas Tree (Gregg Buntin and Rich Orde)</option>
|
||||||
|
|
||||||
<option disabled>____________________________________________</option>
|
<option disabled>____________________________________________</option>
|
||||||
<option disabled>Other</option>
|
<option disabled>Other</option>
|
||||||
|
22
samples/sample.calculatedimage.txt
Normal file
22
samples/sample.calculatedimage.txt
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
10 TEXT : HOME : REM Clear the screen
|
||||||
|
20 VTAB 4 : HTAB 14 : PRINT "Calculated Image"
|
||||||
|
30 VTAB 10 : HTAB 7 : PRINT "By Gregg Buntin - Dec 2, 2016"
|
||||||
|
40 VTAB 12 : HTAB 5 : PRINT "Adapted from an ancient one liner"
|
||||||
|
50 VTAB 19 : PRINT "Type a number from 2 to 9"
|
||||||
|
60 GET NUM$ : REM read input
|
||||||
|
70 IF NUM$ < "2" OR NUM$ > "9" THEN 10 : REM Check for 2 through 9
|
||||||
|
200 P = VAL(NUM$) / 10 : REM Divide by 10 because we want a decimal
|
||||||
|
210 HGR2 : REM Hires screen 2
|
||||||
|
220 FOR Y = -95 TO 0 : REM roughly half the screen height
|
||||||
|
230 Y2 = Y * Y : REM used in the math
|
||||||
|
240 FOR X = -139 TO 0 : REM roughly half the screen width
|
||||||
|
250 R = (1E7 - INT ((Y2 + X * X) ^ P)) / 2 : REM Math is fun
|
||||||
|
260 HCOLOR= 3 * (R < > INT (R)) : REM White or Black
|
||||||
|
270 X1 = X + 139 : REM so we plot X > 0 and start at the outsides
|
||||||
|
280 Y1 = Y + 95 : REM so we plot Y > 0 and start at the top
|
||||||
|
290 HPLOT X1,Y1 : REM Plot a dot from left to right (TOP)
|
||||||
|
300 HPLOT 278 - X1,Y1 : REM Plot a dot from right to left (TOP)
|
||||||
|
310 HPLOT X1,190 - Y1 : REM Plot a dot from left to right (Bottom)
|
||||||
|
320 HPLOT 278 - X1,190 - Y1 : REM Plot a dot from right to left (Bottom)
|
||||||
|
330 NEXT : REM next X
|
||||||
|
340 NEXT : REM next Y
|
45
samples/sample.loresdrawing.txt
Normal file
45
samples/sample.loresdrawing.txt
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
10 TEXT : HOME : REM Clear the screen
|
||||||
|
20 VTAB 4 : HTAB 14 : PRINT "LoRes Drawing"
|
||||||
|
30 VTAB 10 : HTAB 7 : PRINT "By Gregg Buntin - Dec 2, 2016"
|
||||||
|
40 VTAB 12 : HTAB 2 : PRINT "Adapted from ancient code (circa 1985)"
|
||||||
|
50 VTAB 19 : PRINT "Do you want instructions?"
|
||||||
|
60 GET ANS$ : REM read input
|
||||||
|
70 IF ANS$ = "Y" OR ANS$ = "y" THEN 500
|
||||||
|
200 X = 1:Y = 1:C = 2 : REM Set x,y and color defaults
|
||||||
|
210 TEXT : HOME : GR : REM Clear screen and set graphics mode
|
||||||
|
220 MESS$ = "Not Plotting" : GOSUB 800
|
||||||
|
230 GOTO 400 : REM Jump to plot current dot then continue
|
||||||
|
240 K = PEEK ( - 16384): IF K < 128 THEN 240 : REM Read Keyboard
|
||||||
|
250 X1 = X:Y1 = Y: POKE - 16368,0 : REM Save last position
|
||||||
|
260 IF K = 155 THEN TEXT : HOME : END : REM Esc
|
||||||
|
270 IF K = 136 THEN X = X - 1: IF X < 0 THEN X = 39 : REM Left
|
||||||
|
280 IF K = 149 THEN X = X + 1: IF X > 39 THEN X = 0 : REM Right
|
||||||
|
290 IF K = 139 THEN Y = Y - 1: IF Y < 0 THEN Y = 39 : REM Up
|
||||||
|
300 IF K = 138 THEN Y = Y + 1: IF Y > 39 THEN Y = 0 : REM Down
|
||||||
|
310 IF K = 195 THEN VTAB 24: INPUT "COLOR:";C: COLOR= C : HOME : REM Color
|
||||||
|
320 IF K = 208 THEN PL = 1 : MESS$ = "Plotting" : REM P (Plot)
|
||||||
|
330 IF K = 206 THEN PL = 0 : MESS$ = "Not Plotting" :REM N (No Plot)
|
||||||
|
340 IF K = 197 THEN PL = 2 : MESS$ = "Erasing" : REM E (Erase)
|
||||||
|
350 IF K = 210 THEN GOSUB 700 : REM R (Reset / Clear)
|
||||||
|
360 GOSUB 800
|
||||||
|
370 IF PL = 0 THEN COLOR= OC: PLOT X1,Y1 : REM Plot the current position non destuctively
|
||||||
|
380 IF PL = 2 THEN COLOR= 0: PLOT X1,Y1 : REM Erase the current positon
|
||||||
|
390 OC = SCRN( X,Y) : REM Save current position Color
|
||||||
|
400 COLOR= C: PLOT X,Y : REM Plot the current position
|
||||||
|
410 GOTO 240 : REM go read another key
|
||||||
|
500 TEXT : HOME
|
||||||
|
510 PRINT "Arrow keys move up, down, left, right"
|
||||||
|
520 PRINT "C key changes color"
|
||||||
|
530 PRINT " (valid values are from 0 to 15)"
|
||||||
|
540 PRINT "P plot dots (draw)"
|
||||||
|
550 PRINT "N No plot dots (don't draw)"
|
||||||
|
560 PRINT "E Erase dots"
|
||||||
|
570 PRINT "R Reset (clear screen)"
|
||||||
|
580 PRINT "Esc Quits"
|
||||||
|
590 PRINT : PRINT "Press any key to continue"
|
||||||
|
600 GET ANS$
|
||||||
|
610 GOTO 200
|
||||||
|
700 VTAB 23 : HTAB 1 : PRINT "Really clear screen?"; : GET ANS$ : IF ANS$ = "Y" OR ANS$ = "y" THEN TEXT : HOME : GR
|
||||||
|
710 RETURN
|
||||||
|
800 HOME : VTAB 23 : HTAB 1 : PRINT MESS$ : RETURN
|
||||||
|
|
27
samples/sample.miniindy.txt
Normal file
27
samples/sample.miniindy.txt
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
10 TEXT : HOME : REM Clear the screen
|
||||||
|
20 VTAB 4 : HTAB 15 : PRINT "Mini Indy"
|
||||||
|
30 VTAB 10 : HTAB 7 : PRINT "By Gregg Buntin - Dec 2, 2016"
|
||||||
|
40 VTAB 12 : HTAB 5 : PRINT "Adapted from an ancient one liner"
|
||||||
|
50 VTAB 18 : HTAB 6 : PRINT "Left & Right Arrow Keys move"
|
||||||
|
60 VTAB 19 : HTAB 7 : PRINT "any other key goes straight"
|
||||||
|
70 VTAB 21 : PRINT "Press any key to play"
|
||||||
|
80 GET KEY : TEXT : HOME : REM wait for keypress then clear screen and begin
|
||||||
|
90 DIM RL(13) : DIM RR(13) : FOR X = 1 TO 13 : RL(X) = 1 : RR(X) = 35 : NEXT : REM Set default road width
|
||||||
|
100 REM left & right arrow keys, any other straight
|
||||||
|
110 W = (W = 0) * 10 + W - .01 + (W < 0) : REM determine width of road
|
||||||
|
120 K = PEEK (49152) : REM read the keyboard
|
||||||
|
130 X = X - (K = 136) + (K = 149) + (X = 0) * 10 : REM determine "car" position
|
||||||
|
140 L = (L < 4) * 2 + L + SGN ( RND (1) - .5) - (L + W > 30) : REM Determine where road begins
|
||||||
|
150 VTAB 23 : HTAB 1 : FOR I = 1 TO L : PRINT "@"; : NEXT : REM Draw left "grass"
|
||||||
|
160 RS = L + W + 1 : REM deterine right start position
|
||||||
|
170 VTAB 23 : HTAB RS : FOR I = RS TO 34 : PRINT "@"; : NEXT : REM Draw right "grass"
|
||||||
|
180 C = 0 : IF X < RL(1) OR X > RR(1) THEN C = 1 : REM check for collision
|
||||||
|
190 HTAB (X) : VTAB 10 : PRINT "V" : REM Draw "car"
|
||||||
|
200 T = T + 1 : REM Increment score
|
||||||
|
210 HTAB 35 : VTAB 24 : PRINT T : REM display score
|
||||||
|
220 FOR MY = 2 TO 13 : RL(MY-1) = RL(MY) : RR(MY-1) = RR(MY) : NEXT : REM for collision detection
|
||||||
|
230 RL(13) = L : RR(13) = RS : REM newest road position
|
||||||
|
240 FOR MY = 1 TO 1000 : NEXT MY : REM Slow the emulator down some
|
||||||
|
250 IF C = 0 THEN 100 : REM check if still on the road
|
||||||
|
260 HOME : PRINT "YOUR SCORE WAS:"T : REM And you're done
|
||||||
|
|
31
samples/sample.xmastree.txt
Normal file
31
samples/sample.xmastree.txt
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
10 TEXT : HOME : REM Clear the screen
|
||||||
|
20 VTAB 4 : HTAB 14 : PRINT "Christmas Tree"
|
||||||
|
30 VTAB 10 : HTAB 1 : PRINT "By Gregg Buntin and Rich Orde (1983ish)"
|
||||||
|
40 VTAB 12 : HTAB 5 : PRINT "Adapted for JSBasic Dec 2, 2016"
|
||||||
|
50 VTAB 19 : PRINT "Press any key to continue"
|
||||||
|
60 GET NUM$ : REM read input
|
||||||
|
200 DIM X(20),Y(20)
|
||||||
|
210 HGR : POKE - 16302,0: HCOLOR= 1 : REM Set Hires, full screen, color green
|
||||||
|
220 FOR I = 40 TO 140 STEP 10: FOR J = 0 TO 9 : REM Loops for Tree
|
||||||
|
230 HPLOT 140 - J * 1.4 + 20 - I / 2,I + J TO 140 + J * 1.4 - 20 + I / 2,I + J: NEXT : NEXT : REM Draw Tree
|
||||||
|
240 HCOLOR= 0: HPLOT 100,149 TO 180,149: HPLOT 105,148 TO 175,148: HPLOT 125,147 TO 155,147 : REM Bottom of tree
|
||||||
|
250 HCOLOR= 5: FOR I = 147 TO 160: HPLOT 132,I TO 148,I: NEXT : REM Tree Trunk
|
||||||
|
260 HCOLOR= 2 : FOR I = 161 TO 163: HPLOT 0,I TO 279,I: NEXT : REM Ground
|
||||||
|
270 HCOLOR= 6: HPLOT 140,30 TO 140,40: HPLOT 133,35 TO 147,35: HPLOT 135,30 TO 145,40: HPLOT 135,40 TO 145,30 : REM Star
|
||||||
|
280 DATA 140,50,135,95,145,135,110,100,160,111 : REM Data for ornaments
|
||||||
|
290 DATA 102,135,127,120,128,75,150,85,170,133 : REM Data for ornaments
|
||||||
|
300 HCOLOR= 2: FOR I = 1 TO 10 : REM 10 purple ornaments
|
||||||
|
310 READ X,Y: HPLOT X + 1,Y TO X + 3,Y: HPLOT X + 1,Y + 4 TO X + 3,Y + 4 : REM top & bottom of ornaments
|
||||||
|
320 FOR J = Y + 1 TO Y + 3: HPLOT X,J TO X + 4,J: NEXT : NEXT : REM middle of Ornaments
|
||||||
|
315 REM Start with 'random' snow
|
||||||
|
330 DATA 20,20,70,50,30,100,60,130,10,60
|
||||||
|
340 DATA 25,25,75,55,35,95,65,125,15,65
|
||||||
|
350 DATA 210,50,270,60,220,130,255,100,240,20
|
||||||
|
360 DATA 215,55,275,65,225,135,260,105,245,25
|
||||||
|
370 FOR I = 1 TO 20: READ X(I),Y(I): NEXT : REM get snow starting locations
|
||||||
|
380 FOR I = 1 TO 20: HCOLOR= 0: HPLOT X(I),Y(I) TO X(I) + 1,Y(I):Y(I) = Y(I) + 5: IF Y(I) > 158 THEN 400
|
||||||
|
390 HCOLOR= 3: HPLOT X(I),Y(I) TO X(I) + 1,Y(I): NEXT : GOTO 380
|
||||||
|
400 HCOLOR= 3: HPLOT X(I),160 TO X(I) + 1,160
|
||||||
|
410 Y(I) = 0: IF X(I) > 140 THEN X(I) = INT ( RND (1) * 75) + 204
|
||||||
|
420 IF X(I) < 140 THEN X(I) = INT ( RND (1) * 80)
|
||||||
|
430 GOTO 390
|
Loading…
Reference in New Issue
Block a user