home *** CD-ROM | disk | FTP | other *** search
/ Loadstar 3 / 003.d81 / headon (.txt) < prev    next >
Commodore BASIC  |  2022-08-26  |  5KB  |  172 lines

  1. 1 rem ******************************
  2. 2 rem **    headon                **
  3. 3 rem **     by paul jatkowski    **
  4. 4 rem **             11/15/83     **
  5. 5 rem ******************************
  6. 10 def fnx(q)=(q-(int(q/40)*40))*8+24
  7. 15 def fny(q)=int(q/40)*8+50
  8. 20 q%=0:gosub 6500:gosub1000: gosub 2000
  9. 100 rem new board starts here
  10. 110 gosub 1000:gosub1300
  11. 120 gosub 3000
  12. 122 if up%=p%then500
  13. 123 if qt%+q% > hs% then hs%=qt%+q%
  14. 125 print "   score=";q%+qt%;tab(15)"high score=";hs%
  15. 140 gosub 5000:rem move computer car
  16. 150 if up%=p%then 500
  17. 190 if q%=160 then qt%=qt%+q%:q%=0:goto100
  18. 200 goto 120
  19. 500 rem collision
  20. 510 pokenc+24,15:pokenc+4,128:pokenc+1,5:pokenc+5,68:pokenc+6,252:poke nc+4,129
  21. 520 fori=1to100:next:poke nc+4,128
  22. 570 for z=0to30:poke 53280,zand15
  23. 580 forzz=1to3:poke832+int(rnd(0)*8)*3,int(rnd(0)*256):next
  24. 590 next z
  25. 600 poke 53280,0
  26. 640 poke198,0
  27. 641 if (peek(pd)and16)<>0 then if peek(198)=0 then 641
  28. 650 if qt%+q% > hs% then hs%=qt%+q%
  29. 660 qt%=0:q%=0:goto 100
  30. 999 end
  31. 1000 rem "setup, initial and per game"
  32. 1020 poke 53280,0:poke 53281,0
  33. 1100 pd=56320:sc=1024:v=53248:cr=55296:nc=54272
  34. 1110 p%=96+rnd(0)*2:pl%=1:pv%=1:pc=7:ps=asc("[209]"):bl=asc(" ")
  35. 1120 rem:pokesc+p,ps:poke cr+p,pc
  36. 1130 for i=nctonc+23:pokei,o
  37. 1140 poke nc+0,75:pokenc+1,34:pokenc+4,16:pokenc+5,9:pokenc+6,64:pokenc+24,9
  38. 1150 rem set up sprite
  39. 1160 for i=832to895:pokei,0:nexti
  40. 1165 restore
  41. 1170 for i=0to7:reada:poke832+3*i,a:nexti
  42. 1180 data 195,219,060,102,102,060,219,195
  43. 1190 poke 2040,13:poke2041,13:poke2042,13
  44. 1195 pokev+39,7:pokev+40,5:pokev+41,5
  45. 1200 poke v+4,fnx(up%):pokev+5,fny(up%)
  46. 1210 rem set up computer car
  47. 1220 up%=894+rnd(0)*4:uv%=1:uc%=5:ul%=1:ua%=1
  48. 1230 poke v+4,fnx(up%):pokev+5,fny(up%)
  49. 1240 poke v+0,fnx(p%):pokev+1,fny(p%)
  50. 1250 q1=peek(v+30):rem clear colision reg
  51. 1299 return
  52. 1300 rem draw board
  53. 1310 print"[147][154]";
  54. 1470 print
  55. 1480 print"  [213][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][201]"
  56. 1490 print"  [221][209][160][215][160][215][160][215][160][215][160][215][144]d d[160][215][160][215][160][215][160][215][160][215][160][209][154][221]"
  57. 1500 print"  [221] [213][192][192][192][192][192][192][192][192][192]    [192][192][192][192][192][192][192][192][192][201] [221]"
  58. 1510 print"  [221][215][154][221][209] [215] [215][160][215][160][215][144]f f [215][160][215][160][215][160][215][160][209][154][221][215][154][221]"
  59. 1520 print"  [221] [221] [213][192][192][192][192][192][192][192]    [192][192][192][192][192][192][192][201] [221] [221]"
  60. 1530 print"  [221][215][154][221][215][154][221][209] [215] [215] [215][144]f f [215][160][215] [215] [209][154][221][215][154][221][215][154][221]"
  61. 1540 print"  [221] [221] [221] [213][192][192][192][192][192]    [192][192][192][192][192][201] [221] [221] [221]"
  62. 1550 print"  [221][215][154][221][215][154][221][215][154][221][209] [215] [215][144]f f [215] [215] [209][154][221][215][154][221][215][154][221][215][154][221]"
  63. 1560 print"  [221] [221] [221] [221] [213][192][192][192]    [192][192][192][201] [221] [221] [221] [221]"
  64. 1570 print"  [221][215][154][221][215][154][221][215][154][221][215][154][221][209] [215][144]u u [215] [209][154][221][215][154][221][215][154][221][215][154][221][215][154][221]"
  65. 1580 print"  [221][144]r t t t l        l t t t r[154][221]"
  66. 1585 print"  [221]                          [221]"
  67. 1587 print"  [221][144]r t t t l        l t t t r[154][221]"
  68. 1590 print"  [221][215][154][221][215][154][221][215][154][221][215][154][221][209] [215][144] u u[215] [209][154][221][215][154][221][215][154][221][215][154][221][215][154][221]"
  69. 1600 print"  [221] [221] [221] [221] [202][192][192][192]    [192][192][192][203] [221] [221] [221] [221]"
  70. 1610 print"  [221][215][154][221][215][154][221][215][154][221][209] [215] [215][144] f f[215] [215] [209][154][221][215][154][221][215][154][221][215][154][221]"
  71. 1620 print"  [221] [221] [221] [202][192][192][192][192][192]    [192][192][192][192][192][203] [221] [221] [221]"
  72. 1630 print"  [221][215][154][221][215][154][221][209] [215] [215] [215][144] f f[215] [215] [215] [209][154][221][215][154][221][215][154][221]"
  73. 1640 print"  [221] [221] [202][192][192][192][192][192][192][192]    [192][192][192][192][192][192][192][203] [221] [221]"
  74. 1650 print"  [221][215][154][221][209] [215] [215] [215] [215][144] f f[215] [215] [215] [215] [209][154][221][215][154][221]"
  75. 1660 print"  [221] [202][192][192][192][192][192][192][192][192][192]    [192][192][192][192][192][192][192][192][192][203] [221]"
  76. 1670 print"  [221][209][160][215][160][215][160][215][160][215][160][215][144] d d[215][160][215][160][215][160][215][160][215][160][209][154][221]"
  77. 1680 print"  [202][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][203]";
  78. 1700 poke v+21,5
  79. 1710 return
  80. 2000 rem set up translation arrays
  81. 2005 sc=1024
  82. 2010 dim k%(255),xy%(1000,1)
  83. 2020 k$=" [215][209]rltfudx"
  84. 2030 for i=1to len(k$):print"[218][157]";mid$(k$,i,1);:k%(peek(sc))=i:next
  85. 2040 k%(96)=1:k%(88)=10
  86. 2050 print"  ";
  87. 2060 if cr=0thenstop
  88. 2490 pokev+21,0
  89. 2500 for i=999to0step-1:xy%(i,0)=fnx(i):xy%(i,1)=fny(i):next
  90. 2999 return
  91. 3000 rem move player
  92. 3010 cc=k%(peek(sc+p%)):c1=peek(sc+p%)
  93. 3020 on cc goto 3100,3200,3300,3400,3500,3600,3700,3800,3900,4000
  94. 3030 stop
  95. 3100 rem " space - continue "
  96. 3110 p%=p%+pv%:goto 4100
  97. 3200 rem "[215] - score a point, erase dot"
  98. 3210 pokenc+4,17:q%=q%+1:poke sc+p%,32:p%=p%+pv%:goto4100
  99. 3300 rem "[209]- score 3 points, right turn"
  100. 3310 pokenc+4,17:q%=q%+3:poke sc+p%,24:pokecr+p%,0
  101. 3320 if pv%=1thenpv%=40:goto 3370
  102. 3330 if pv%=40thenpv%=-1:goto 3370
  103. 3340 if pv%=-1thenpv%=-40:goto 3370
  104. 3350 if pv%=-40thenpv%=1:goto 3370
  105. 3360 stop
  106. 3370 p%=p%+pv%:goto4100
  107. 3400 rem "r - optional right move"
  108. 3410 if(peek(pd)and8)=0thenp%=p%-2*sgn(pv%):pl%=pl%+1
  109. 3420 p%=p%+pv%:goto4100
  110. 3500 rem "l - optional left move"
  111. 3510 if(peek(pd)and4)=0thenp%=p%+2*sgn(pv%):pl%=pl%-1
  112. 3520 p%=p%+pv%:goto4100
  113. 3600 rem "t - optional left or right"
  114. 3610 if(peek(pd)and8)=0thenp%=p%-2*sgn(pv%):pl%=pl%+1
  115. 3620 if(peek(pd)and4)=0thenp%=p%+2*sgn(pv%):pl%=pl%-1
  116. 3630 p%=p%+pv%:goto4100
  117. 3700 rem "f - optional up or down"
  118. 3710 if(peek(pd)and4)=0thenp%=p%-80*sgn(pv%):pl%=pl%-1
  119. 3720 if(peek(pd)and8)=0thenp%=p%+80*sgn(pv%):pl%=pl%+1
  120. 3730 p%=p%+pv%:goto 4100
  121. 3800 rem "u - optional up"
  122. 3810 if(peek(pd)and4)=0thenp%=p%-80*sgn(pv%):pl%=pl%-1
  123. 3820 p%=p%+pv%:goto 4100
  124. 3900 rem "d - optional down"
  125. 3910 if(peek(pd)and8)=0thenp%=p%+80*sgn(pv%):pl%=pl%+1
  126. 3920 p%=p%+pv%:goto 4100
  127. 4000 rem "x - forces right turn"
  128. 4010 goto 3320
  129. 4100 rem "common move return point"
  130. 4110 poke v+0,xy%(p%,0):pokev+1,xy%(p%,1)
  131. 4120 rem:poke v+0,fnx(p%):pokev+1,fny(p%)
  132. 4130 pokenc+4,16
  133. 4140 return
  134. 5000 rem "move computer car"
  135. 5010 cc=k%(peek(sc+up%)):c1=peek(sc+up%)
  136. 5020 onccgoto 5100,5100,5200,5300,5300,5300,5400,5400,5400,5200
  137. 5100 rem "nothing of interest"
  138. 5110 up%=up%+uv%:goto 6000
  139. 5200 rem "turn left"
  140. 5210 if uv%=40thenuv%= 1:goto5270
  141. 5220 if uv%=-1thenuv%=40:goto5270
  142. 5230 if uv%=-40thenuv%=-1:goto5270
  143. 5240 if uv%=1thenuv%=-40:goto5270
  144. 5250 stop
  145. 5270 up%=up%+uv%:goto 6000
  146. 5300 rem "evaluate right or left move"
  147. 5310 ua%=-ua%:if ul%=pl%orua%=-1then up%=up%+uv%:goto6000
  148. 5320 up%=up%+2*sgn(pl%-ul%)*sgn(uv%):up%=up%+uv%:ul%=ul%+sgn(pl%-ul%):goto6000
  149. 5400 rem "evaluate up or down move"
  150. 5410 ua%=-ua%:if ul%=pl%orua%=-1then up%=up%+uv%:goto6000
  151. 5420 up%=up%-80*sgn(pl%-ul%)*sgn(uv%):up%=up%+uv%:ul%=ul%+sgn(pl%-ul%):goto6000
  152. 6000 rem computer move common return
  153. 6010 pokev+4,xy%(up%,0):pokev+5,xy%(up%,1)
  154. 6020 rem:pokev+4,fnx(up%):pokev+5,fny(up%)
  155. 6030 return
  156. 6500 rem initial page
  157. 6505 poke53280,0:poke53281,0
  158. 6510 print "[147]";
  159. 6520 print "";spc(16)"[158]        [157][157][157][157][157][157][157][157] headon [157][157][157][157][157][157][157][157]        [146]"
  160. 6530 print"[159]you control the [158]yellow[159] car with"
  161. 6540 print"the joystick in port 2."
  162. 6550 print"pushing left will turn the car left"
  163. 6560 print"pushing right will turn the car right"
  164. 6570 print "   (from the drivers point of view)"
  165. 6580 printspc(10);"[215][159]  - 1 point"
  166. 6590 printspc(1