home *** CD-ROM | disk | FTP | other *** search
/ Run Magazine ReRun: Productivity Pak 2 / rerun-productivity-pak-ii.d64 / logo for kids (.txt) < prev    next >
Encoding:
Commodore BASIC  |  1986-01-01  |  11.3 KB  |  446 lines

  1. 10 rem    'elmer the turtle'
  2. 20 rem     (logo for kids)
  3. 30 :
  4. 40 rem    version l-14
  5. 50 :
  6. 60 rem    use on commodore 64
  7. 70 :
  8. 80 :
  9. 90 rem    arrays
  10. 100 :
  11. 110 dim b(12)
  12. 120 dim a$(36),b$(36),c$(12)
  13. 130 :
  14. 140 rem    variables
  15. 150 :
  16. 160 b=0
  17. 170 read b$:if b$="e" then bl=b:goto 200
  18. 180 b=b+1:b$(b)=b$:b(b)=len(b$)
  19. 190 read c(b):goto 170
  20. 200 s$="             "
  21. 210 er$="[145]"+s$+s$+s$+"[145]"
  22. 220 al=36:d=54272:u=10
  23. 230 t$="[158]* * * * * * *"
  24. 240 poke 53280,3:poke 53281,3:poke 646,6
  25. 250 :
  26. 260 rem   title page
  27. 270 :
  28. 280 poke 53280,3:poke 53281,3:poke 646,6
  29. 290 print "[147]",t$
  30. 300 print "[144]         elmer the turtle"
  31. 310 print ,t$
  32. 320 print "this game lets you draw and write on "
  33. 330 print "  this computer screen."
  34. 340 print "just like other games, there are some"
  35. 350 print "  rules for playing this game."
  36. 360 print "press the space bar if you want"
  37. 370 print "  to read the rules."
  38. 380 print "or press the return key if you know"
  39. 390 print "  them already and want to start"
  40. 400 print "  playing right away."
  41. 410 a$=""
  42. 420 get a$:if a$="" then 420
  43. 430 if asc(a$)=13 then 530
  44. 440 if asc(a$)<>32 then 420
  45. 450 :
  46. 460 rem   display all instructions
  47. 470 :
  48. 480 gosub 2910:gosub 3040:gosub 3170
  49. 490 gosub 3290:gosub 3400:gosub 3560
  50. 500 gosub 3650:gosub 3770:gosub 3920
  51. 510 gosub 4310
  52. 520 :
  53. 530 rem   continue directions?
  54. 540 :
  55. 550 print "[147]",t$
  56. 560 print "everyone sometimes makes mistakes"
  57. 570 print "  when they play this game."
  58. 580 print "the computer can often help you find"
  59. 590 print "  out what you did wrong and show you"
  60. 600 print "  the rule for that part."
  61. 610 print "please press the space bar if you want"
  62. 620 print "  the computer to help find mistakes,"
  63. 630 print "or press the return key if you do not."
  64. 640 print ,t$
  65. 650 q=0:a$=""
  66. 660 get a$:if a$="" then 660
  67. 670 if asc(a$)=13 then u=0:goto 700
  68. 680 if asc(a$)<>32 then 660
  69. 690 u=1
  70. 700 :
  71. 710 :
  72. 720 rem   statement list display
  73. 730 :
  74. 740 print "[147]";:n=18:for o=1 to 18
  75. 750 print "";right$(str$(o),2);". ";
  76. 760 print "";a$(o);tab(20);
  77. 770 print "";right$(str$(o+n),2);". ";
  78. 780 print "";a$(o+n):next o:print
  79. 790 if q=1 then 980
  80. 800 :
  81. 810 rem   line # input
  82. 820 :
  83. 830 input "line #, 'e' or 'new'";i$
  84. 840 print er$:if i$="e" then 1610
  85. 850 if i$<>"new" then 870
  86. 860 for a=1 to 36:a$(a)="":next:goto710
  87. 870 i=len(i$):if i<1 or i>3 then 940
  88. 880 if i$="0" then 940
  89. 890 n=asc(i$):if n<49 or n>57 then 940
  90. 900 n=asc(right$(i$,1))
  91. 910 if n<49 and n>57 then 940
  92. 920 a=val(i$)
  93. 930 if a>0 and a=<al then 980
  94. 940 gosub 2500:if u=0 then 810
  95. 950 print "[147]"
  96. 960 gosub 3040:gosub 4090:goto 710
  97. 970 :
  98. 980 rem  statement display
  99. 990 :
  100. 1000 q=1:print "[145]";
  101. 1010 for m=1 to 3:for n=0 to 3
  102. 1020 b=m+n*3:if b>bl then 1040
  103. 1030 print tab(n*10);b$(b);
  104. 1040 next n:print:next m
  105. 1050 print "i[158]nsert    d[158]elete    ";
  106. 1060 print "b[158]ack to line #"
  107. 1070 :
  108. 1080 rem  statement input
  109. 1090 :
  110. 1100 print "line";a;:i$="":input i$
  111. 1110 print er$:if i$="" then gosub 2500:goto 1070
  112. 1120 if i$="i" then 1540
  113. 1130 if i$="d" then 1580
  114. 1140 if i$="b" then q=0:goto 710
  115. 1150 :
  116. 1160 rem  is 'i$' valid?
  117. 1170 :
  118. 1180 b=0:i=len(i$)
  119. 1190 b=b+1:if b>bl then gosub 2500:goto 1070
  120. 1200 if left$(i$,b(b))<>b$(b) then 1190
  121. 1210 rem  ....stmt #c
  122. 1220 c=c(b):if c>0 then 1260
  123. 1230 rem  ....stmt type 0
  124. 1240 if i$=b$(b) then a$(a)=i$:q=0:goto 710
  125. 1250 goto 1370
  126. 1260 m$=right$(i$,i-b(b))
  127. 1270 gosub 2590
  128. 1280 j$=m$:j=len(j$):if c>1 then 1420
  129. 1290 rem  ....stmt type 1
  130. 1300 if j=0 or j>2 then 1370
  131. 1310 n=asc(left$(j$,1))
  132. 1320 if n<48 or n>57 then 1370
  133. 1330 n=asc(right$(j$,1))
  134. 1340 if n<48 or n>57 then 1370
  135. 1350 n=val(j$):if b=8 and n<16 then 1460
  136. 1360 if b<>8 and n>0 then 1460
  137. 1370 gosub 2500:if u=0 then 1070
  138. 1380 print "[147]":if b>4 then 1400
  139. 1390 gosub 3190:goto 710
  140. 1400 on b-4 gosub 3290,3290,3400,3560,3650,3770
  141. 1410 goto 710
  142. 1420 if c>2 then 1480
  143. 1430 rem  ....stmt type 2
  144. 1440 if j<>1 then 1370
  145. 1450 n=asc(j$):if n<33 or n>95 then 1400
  146. 1460 rem  ....i$ is valid statement
  147. 1470 a$(a)=b$(b)+" "+j$:q=0:goto 710
  148. 1480 if c>3 then 1370
  149. 1490 rem  ....stmt type 3
  150. 1500 if mid$(i$,5,1)=" " then 1520
  151. 1510 i$=left$(i$,4)+" "+mid$(i$,5)
  152. 1520 n=len(i$):if n<6 or n>15 then 1370
  153. 1530 a$(a)=i$:q=0:goto 710
  154. 1540 rem  ....insert blank line
  155. 1550 for m=35 to a step -1
  156. 1560 a$(m+1)=a$(m):next m
  157. 1570 a$(a)="":q=0:goto 710
  158. 1580 rem  ....delete line
  159. 1590 if a=36 then 1600
  160. 1595 for m=a to 35:a$(m)=a$(m+1):next
  161. 1600 a$(36)="":q=0:goto 710
  162. 1610 :
  163. 1620 rem   begin execution
  164. 1630 :
  165. 1640 x=1:y=1:rem    initial position
  166. 1650 e=2:rem        initial pen position
  167. 1660 h$="*":rem     initial character
  168. 1670 l=6:rem        initial color #
  169. 1680 poke 53280,5:rem  border color
  170. 1690 print "[147]":gosub 2770:gosub 2710
  171. 1700 rem   ....statement list
  172. 1710 for a=1 to al:a$=a$(a)
  173. 1720 if a$="" then 2330
  174. 1730 b=0
  175. 1740 b=b+1
  176. 1750 if left$(a$,b(b))<>b$(b) then 1740
  177. 1760 on b goto 1780,1850,1920,1990,2060,2100,2130,2170,2210,2290
  178. 1770 :
  179. 1780 rem   ....right
  180. 1790 m$=right$(a$,len(a$)-b(b))
  181. 1800 gosub 2590:m=val(m$)
  182. 1810 for n=1 to m:gosub 2370
  183. 1820 x=x+1:if x=41 then x=1
  184. 1830 gosub 2710:next n:goto 2330
  185. 1840 :
  186. 1850 rem   ....up
  187. 1860 m$=right$(a$,len(a$)-b(b))
  188. 1870 gosub 2590:m=val(m$)
  189. 1880 for n=1 to m:gosub 2370
  190. 1890 y=y-1:if y=0 then y=25
  191. 1900 gosub 2710:next n:goto 2330
  192. 1910 :
  193. 1920 rem   ....down
  194. 1930 m$=right$(a$,len(a$)-b(b))
  195. 1940 gosub 2590:m=val(m$)
  196. 1950 for n=1 to m:gosub 2370
  197. 1960 y=y+1:if y=26 then y=1
  198. 1970 gosub 2710:next n:goto 2330
  199. 1980 :
  200. 1990 rem   ....left
  201. 2000 m$=right$(a$,len(a$)-b(b))
  202. 2010 gosub 2590:m=val(m$)
  203. 2020 for n=1 to m:gosub 2370
  204. 2030 x=x-1:if x=0 then x=40
  205. 2040 gosub 2710:next n:goto 2330
  206. 2050 :
  207. 2060 rem   ....pen up
  208. 2070 if e=0 then e=1
  209. 2080 goto 2330
  210. 2090 :
  211. 2100 rem   ....pen down
  212. 2110 e=0:goto 2330
  213. 2120 :
  214. 2130 rem   ....char
  215. 2140 h$=right$(a$,1):gosub 2770
  216. 2150 p=983+x+y*40:poke p,k
  217. 2152 gosub 2750:goto 2330
  218. 2160 :
  219. 2170 rem   ....color
  220. 2180 l=val(mid$(a$,6)):p=983+x+y*40
  221. 2190 poke p+d,l:gosub 2750:goto 2330
  222. 2200 :
  223. 2210 rem   ....text
  224. 2220 a$=mid$(a$,6):m=len(a$)
  225. 2225 x=x-1:if x=0 then x=40
  226. 2230 gosub 2370:j=k:for n=1 to m
  227. 2240 h$=mid$(a$,n,1):gosub 2770
  228. 2250 x=x+1:if x=41 then x=1
  229. 2260 gosub 2710:next n
  230. 2270 k=j:f=1:m=1:goto 1810
  231. 2280 :
  232. 2290 rem   ....stop
  233. 2300 a$=""
  234. 2310 get a$:if a$="" then 2310
  235. 2320 goto 2330
  236. 2330 next a:q=0:goto 710
  237. 2340 :
  238. 2350 rem  subroutines
  239. 2360 :
  240. 2370 rem  ....erase previous point?
  241. 2380 if f=1 then f=0:return
  242. 2390 if e=1 then e=2:return
  243. 2400 if e=2 then poke p+d,v:poke p,w
  244. 2410 return
  245. 2420 :
  246. 2430 rem  ....instruction input
  247. 2440 print ""
  248. 2450 print "       press any key to ";
  249. 2460 print "continue":a$=""
  250. 2470 get a$:if a$="" then 2470
  251. 2480 print "[147]":return
  252. 2490 :
  253. 2500 rem ....error message
  254. 2510 print ,"[144]i don't understand that"
  255. 2520 gosub 2560:print er$
  256. 2530 print ,"please try again"
  257. 2540 gosub 2560:print er$:return
  258. 2550 :
  259. 2560 rem ....screen message delay
  260. 2570 for t=1 to 500:next t:return
  261. 2580 :
  262. 2590 rem ....truncate m$
  263. 2600 if m$="" then return
  264. 2610 m=asc(left$(m$,1))
  265. 2620 if m=32 then 2640
  266. 2630 if m<>160 then 2650
  267. 2640 m$=right$(m$,len(m$)-1):goto 2610
  268. 2650 if m$="" then return
  269. 2660 m=asc(right$(m$,1))
  270. 2670 if m=32 then 2690
  271. 2680 if m<>160 then return
  272. 2690 m$=left$(m$,len(m$)-1):goto 2650
  273. 2700 :
  274. 2710 rem ....poke screen character
  275. 2720 p=983+x+y*40
  276. 2730 v=peek(p+d):w=peek(p)
  277. 2740 poke p+d,l:poke p,k
  278. 2750 for t=1 to 50:next t:return
  279. 2760 :
  280. 2770 rem ....calc screen display value
  281. 2780 h=asc(h$):if h<64 then k=h:return
  282. 2790 k=h-64:return
  283. 2800 :
  284. 2810 rem  fixed data
  285. 2820 :
  286. 2830 data right,1,up,1,down,1,left,1
  287. 2840 data pen up,0,pen down,0,char,2
  288. 2850 data color,1,text,3,stop,0
  289. 2860 data e
  290. 2870 :
  291. 2880 :
  292. 2890 rem   title/instructions
  293. 2900 :
  294. 2910 print "[147][144]      how to play with elmer"
  295. 2920 print "this program provides you with a"
  296. 2930 print "  tiny, make-believe turtle named elmer"
  297. 2940 print "  who walks around the screen."
  298. 2950 print "elmer carries a pen so that he  "
  299. 2960 print "  can write on the screen as he walks."
  300. 2970 print "you can tell elmer what to do by"
  301. 2980 print "  giving him a list of instructions."
  302. 2990 print "each instruction has its own number"
  303. 3000 print "  and you can have up to 36
  304. 3010 [153] "  instructions on the list."
  305. 3020 [141] 2430:[142]
  306. 3030 :
  307. 3040 [143]  ....page 2
  308. 3050 [153] "for each instruction, you first enter"
  309. 3060 [153] "  its number or place on the list."
  310. 3070 [153] "then you enter the instruction with"
  311. 3080 [153] "  any number or letters it might need."
  312. 3090 [153] "you will be shown which of elmer's"
  313. 3100 [153] "  instructions need numbers or letters."
  314. 3110 [153] "you can make elmer walk by entering"
  315. 3120 [153] "  an 'e' instead of a list number."
  316. 3130 [153] "you can erase the list by entering"
  317. 3140 [153] "  'new' instead of the list number."
  318. 3150 [141] 2430:[142]
  319. 3160 :
  320. 3170 [143] ....page 3 (b=1,2,3,4)
  321. 3180 [153] "these are the instructions elmer knows:"
  322. 3190 [153] "elmer will walk down the screen if"
  323. 3200 [153] "  you write 'down' and a number."
  324. 3210 [153] "  'down 4' will move him down 4 steps."
  325. 3220 [153] "  'down 10' will move him down 10 steps."
  326. 3230 [153] "he does not understand 'down' if a     "
  327. 3240 [153] "  number doesn't follow it."
  328. 3250 [153] "he also understands 'up', 'right', and"
  329. 3260 [153] "  'left' in the same way."
  330. 3270 [141] 2430:[142]
  331. 3280 :
  332. 3290 [143] ....page 4 (b=5)
  333. 3300 [153] "if you tell elmer 'pen down', he will "
  334. 3310 [153] "  put his pen down on the screen and"
  335. 3320 [153] "  draw a trail behind him."
  336. 3330 [153] "if you tell him 'pen up', he will "
  337. 3340 [153] "  take it off the screen and not leave"
  338. 3350 [153] "  a trail behind him."
  339. 3360 [153] "'pen down' and 'pen up' do not need "
  340. 3370 [153] "  numbers or letters after them."
  341. 3380 [141] 2430:[142]
  342. 3390 :
  343. 3400 [143] ....page 5 (b=6)
  344. 3410 [153] "elmer usually draws a '*' for his"
  345. 3420 [153] "  trail because he thinks it looks "
  346. 3430 [153] "  like another turtle."
  347. 3440 [153] "but he will draw other characters"
  348. 3450 [153] "  if you tell him to do so."
  349. 3460 [153] "you do this by entering 'char', then "
  350. 3470 [153] "  a space, then the character you "
  351. 3480 [153] "  would like him to draw."
  352. 3490 [153] "the instruction 'char e' will tell"
  353. 3500 [153] "  him to leave a trail of e's."
  354. 3510 [153] "you can use any letter, number or"
  355. 3520 [153] "  punctuation mark, but graphics"
  356. 3530 [153] "  symbols will not work."
  357. 3540 [141] 2430:[142]
  358. 3550 :
  359. 3560 [143] ....page 6 (b=7)
  360. 3570 [153] "elmer can also draw in different"
  361. 3580 [153] "  colors if you change his colors."
  362. 3590 [153] "the instruction for this is 'color'"
  363. 3600 [153] "  and a number from 0 to 15."
  364. 3610 [153] "he will draw in black after 'color 0',"
  365. 3620 [153] "  and in orange after 'color 8'."
  366. 3630 [141] 2430:[142]
  367. 3640 :
  368. 3650 [143] ....page 7 (b=8)
  369. 3660 [153] "even though he is only a turtle,"
  370. 3670 [153] "  elmer can write messages if you"
  371. 3680 [153] "  tell him what to write."
  372. 3690 [153] "you can do this with the word 'text',"
  373. 3700 [153] "  then a space, then a short message."
  374. 3710 [153] "the message must be between one and"
  375. 3720 [153] "  ten letters or numbers long."
  376. 3730 [153] "if you have a long message, you can"
  377. 3740 [153] "  break it up into a few short ones."
  378. 3750 [141] 2430:[142]
  379. 3760 :
  380. 3770 [143] ....page 8 (b=9)
  381. 3780 [153] "you can make elmer stop moving at"
  382. 3790 [153] "  any time with the instruction 'stop'."
  383. 3800 [153] "this makes him stop moving until you"
  384. 3810 [153] "  press a key.  then he continues"
  385. 3820 [153] "  following the instructions you"
  386. 3830 [153] "  have written on the list for him."
  387. 3840 [153] "it is a good idea to have a 'stop'"
  388. 3850 [153] "  as the last instruction on the list."
  389. 3860 [153] "this will allow you to see when the "
  390. 3870 [153] "  instructions are finished."
  391. 3880 [139] u[179]10 [167] 3900
  392. 3900 [141] 2430:[142]
  393. 3910 :
  394. 3920 [143] ....page 9
  395. 3930 [153] "all these instructions will be shown"
  396. 3940 [153] "  at the bottom of the list in white."
  397. 3950 [153] "so all you have to remember is how"
  398. 3960 [153] "  to use them."
  399. 3970 [153] ,t$
  400. 3980 [153] "let's see how you can change your"
  401. 3990 [153] "  instructions after you have them"
  402. 4000 [153] "  written on your list..."
  403. 4010 [141] 2430
  404. 4020 :
  405. 4030 [153] "remember that entering 'new' instead"
  406. 4040 [153] "  of a line number will erase the"
  407. 4050 [153] "  whole list?"
  408. 4060 [153] "well, sometimes you may want to change"
  409. 4070 [153] "  a few things on the list without"
  410. 4080 [153] "  erasing everything."
  411. 4090 [153] "there are three ways to change lines:"
  412. 4110 [153] "first, to change one instruction,"
  413. 4120 [153] "  just enter the line number of the"
  414. 4130 [153] "  old instruction, then enter the new"
  415. 4140 [153] "  instruction.  it will replace the"
  416. 4150 [153] "  one you don't want any more."
  417. 4160 [141] 2430
  418. 4170 :
  419. 4180 [143] ....page 11
  420. 4190 [153] "second, if you want to erase just one "
  421. 4200 [153] "  line, enter its number, and then a"
  422. 4210 [153] "  'd' (for delete)."
  423. 4220 [153] "the 'd' will erase that instruction."
  424. 4230 [153] "third, you can add a line between    "
  425. 4240 [153] "  two others. just enter the line "
  426. 4250 [153] "  number of the line that will follow"
  427. 4260 [153] "  the new one, then 'i' (for insert)."
  428. 4270 [153] "you now have a new blank line between"
  429. 4280 [153] "  the two lines."
  430. 4290 [141] 2430:[142]
  431. 4300 :
  432. 4310 [143] ....page 12
  433. 4320 [153] "elmer may be kind of slow, but he"
  434. 4330 [153] "  never gets tired of walking around."
  435. 4340 [153] "you can use any instruction as many"
  436. 4350 [153] "  times as you want to, and he'll"
  437. 4360 [153] "  never complain."
  438. 4370 [153] "elmer will tell you if he does not"
  439. 4380 [153] "  understand something, and then give"
  440. 4390 [153] "  you as many tries as you need to fix"
  441. 4400 [153] "  the instruction."
  442. 4410 [153] "some of this may be hard for you to"
  443. 4420 [153] "  understand, but play with elmer and"
  444. 4430 [153] "  you will quickly become an expert."
  445. 4440 [141] 2430:[142]
  446.