home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Loadstar 3
/
003.d81
/
headon
(
.txt
)
< prev
next >
Wrap
Commodore BASIC
|
2022-08-26
|
5KB
|
172 lines
1 rem ******************************
2 rem ** headon **
3 rem ** by paul jatkowski **
4 rem ** 11/15/83 **
5 rem ******************************
10 def fnx(q)=(q-(int(q/40)*40))*8+24
15 def fny(q)=int(q/40)*8+50
20 q%=0:gosub 6500:gosub1000: gosub 2000
100 rem new board starts here
110 gosub 1000:gosub1300
120 gosub 3000
122 if up%=p%then500
123 if qt%+q% > hs% then hs%=qt%+q%
125 print " score=";q%+qt%;tab(15)"high score=";hs%
140 gosub 5000:rem move computer car
150 if up%=p%then 500
190 if q%=160 then qt%=qt%+q%:q%=0:goto100
200 goto 120
500 rem collision
510 pokenc+24,15:pokenc+4,128:pokenc+1,5:pokenc+5,68:pokenc+6,252:poke nc+4,129
520 fori=1to100:next:poke nc+4,128
570 for z=0to30:poke 53280,zand15
580 forzz=1to3:poke832+int(rnd(0)*8)*3,int(rnd(0)*256):next
590 next z
600 poke 53280,0
640 poke198,0
641 if (peek(pd)and16)<>0 then if peek(198)=0 then 641
650 if qt%+q% > hs% then hs%=qt%+q%
660 qt%=0:q%=0:goto 100
999 end
1000 rem "setup, initial and per game"
1020 poke 53280,0:poke 53281,0
1100 pd=56320:sc=1024:v=53248:cr=55296:nc=54272
1110 p%=96+rnd(0)*2:pl%=1:pv%=1:pc=7:ps=asc("[209]"):bl=asc(" ")
1120 rem:pokesc+p,ps:poke cr+p,pc
1130 for i=nctonc+23:pokei,o
1140 poke nc+0,75:pokenc+1,34:pokenc+4,16:pokenc+5,9:pokenc+6,64:pokenc+24,9
1150 rem set up sprite
1160 for i=832to895:pokei,0:nexti
1165 restore
1170 for i=0to7:reada:poke832+3*i,a:nexti
1180 data 195,219,060,102,102,060,219,195
1190 poke 2040,13:poke2041,13:poke2042,13
1195 pokev+39,7:pokev+40,5:pokev+41,5
1200 poke v+4,fnx(up%):pokev+5,fny(up%)
1210 rem set up computer car
1220 up%=894+rnd(0)*4:uv%=1:uc%=5:ul%=1:ua%=1
1230 poke v+4,fnx(up%):pokev+5,fny(up%)
1240 poke v+0,fnx(p%):pokev+1,fny(p%)
1250 q1=peek(v+30):rem clear colision reg
1299 return
1300 rem draw board
1310 print"[147][154]";
1470 print
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]"
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]"
1500 print" [221] [213][192][192][192][192][192][192][192][192][192] [192][192][192][192][192][192][192][192][192][201] [221]"
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]"
1520 print" [221] [221] [213][192][192][192][192][192][192][192] [192][192][192][192][192][192][192][201] [221] [221]"
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]"
1540 print" [221] [221] [221] [213][192][192][192][192][192] [192][192][192][192][192][201] [221] [221] [221]"
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]"
1560 print" [221] [221] [221] [221] [213][192][192][192] [192][192][192][201] [221] [221] [221] [221]"
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]"
1580 print" [221][144]r t t t l l t t t r[154][221]"
1585 print" [221] [221]"
1587 print" [221][144]r t t t l l t t t r[154][221]"
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]"
1600 print" [221] [221] [221] [221] [202][192][192][192] [192][192][192][203] [221] [221] [221] [221]"
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]"
1620 print" [221] [221] [221] [202][192][192][192][192][192] [192][192][192][192][192][203] [221] [221] [221]"
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]"
1640 print" [221] [221] [202][192][192][192][192][192][192][192] [192][192][192][192][192][192][192][203] [221] [221]"
1650 print" [221][215][154][221][209] [215] [215] [215] [215][144] f f[215] [215] [215] [215] [209][154][221][215][154][221]"
1660 print" [221] [202][192][192][192][192][192][192][192][192][192] [192][192][192][192][192][192][192][192][192][203] [221]"
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]"
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]";
1700 poke v+21,5
1710 return
2000 rem set up translation arrays
2005 sc=1024
2010 dim k%(255),xy%(1000,1)
2020 k$=" [215][209]rltfudx"
2030 for i=1to len(k$):print"[218][157]";mid$(k$,i,1);:k%(peek(sc))=i:next
2040 k%(96)=1:k%(88)=10
2050 print" ";
2060 if cr=0thenstop
2490 pokev+21,0
2500 for i=999to0step-1:xy%(i,0)=fnx(i):xy%(i,1)=fny(i):next
2999 return
3000 rem move player
3010 cc=k%(peek(sc+p%)):c1=peek(sc+p%)
3020 on cc goto 3100,3200,3300,3400,3500,3600,3700,3800,3900,4000
3030 stop
3100 rem " space - continue "
3110 p%=p%+pv%:goto 4100
3200 rem "[215] - score a point, erase dot"
3210 pokenc+4,17:q%=q%+1:poke sc+p%,32:p%=p%+pv%:goto4100
3300 rem "[209]- score 3 points, right turn"
3310 pokenc+4,17:q%=q%+3:poke sc+p%,24:pokecr+p%,0
3320 if pv%=1thenpv%=40:goto 3370
3330 if pv%=40thenpv%=-1:goto 3370
3340 if pv%=-1thenpv%=-40:goto 3370
3350 if pv%=-40thenpv%=1:goto 3370
3360 stop
3370 p%=p%+pv%:goto4100
3400 rem "r - optional right move"
3410 if(peek(pd)and8)=0thenp%=p%-2*sgn(pv%):pl%=pl%+1
3420 p%=p%+pv%:goto4100
3500 rem "l - optional left move"
3510 if(peek(pd)and4)=0thenp%=p%+2*sgn(pv%):pl%=pl%-1
3520 p%=p%+pv%:goto4100
3600 rem "t - optional left or right"
3610 if(peek(pd)and8)=0thenp%=p%-2*sgn(pv%):pl%=pl%+1
3620 if(peek(pd)and4)=0thenp%=p%+2*sgn(pv%):pl%=pl%-1
3630 p%=p%+pv%:goto4100
3700 rem "f - optional up or down"
3710 if(peek(pd)and4)=0thenp%=p%-80*sgn(pv%):pl%=pl%-1
3720 if(peek(pd)and8)=0thenp%=p%+80*sgn(pv%):pl%=pl%+1
3730 p%=p%+pv%:goto 4100
3800 rem "u - optional up"
3810 if(peek(pd)and4)=0thenp%=p%-80*sgn(pv%):pl%=pl%-1
3820 p%=p%+pv%:goto 4100
3900 rem "d - optional down"
3910 if(peek(pd)and8)=0thenp%=p%+80*sgn(pv%):pl%=pl%+1
3920 p%=p%+pv%:goto 4100
4000 rem "x - forces right turn"
4010 goto 3320
4100 rem "common move return point"
4110 poke v+0,xy%(p%,0):pokev+1,xy%(p%,1)
4120 rem:poke v+0,fnx(p%):pokev+1,fny(p%)
4130 pokenc+4,16
4140 return
5000 rem "move computer car"
5010 cc=k%(peek(sc+up%)):c1=peek(sc+up%)
5020 onccgoto 5100,5100,5200,5300,5300,5300,5400,5400,5400,5200
5100 rem "nothing of interest"
5110 up%=up%+uv%:goto 6000
5200 rem "turn left"
5210 if uv%=40thenuv%= 1:goto5270
5220 if uv%=-1thenuv%=40:goto5270
5230 if uv%=-40thenuv%=-1:goto5270
5240 if uv%=1thenuv%=-40:goto5270
5250 stop
5270 up%=up%+uv%:goto 6000
5300 rem "evaluate right or left move"
5310 ua%=-ua%:if ul%=pl%orua%=-1then up%=up%+uv%:goto6000
5320 up%=up%+2*sgn(pl%-ul%)*sgn(uv%):up%=up%+uv%:ul%=ul%+sgn(pl%-ul%):goto6000
5400 rem "evaluate up or down move"
5410 ua%=-ua%:if ul%=pl%orua%=-1then up%=up%+uv%:goto6000
5420 up%=up%-80*sgn(pl%-ul%)*sgn(uv%):up%=up%+uv%:ul%=ul%+sgn(pl%-ul%):goto6000
6000 rem computer move common return
6010 pokev+4,xy%(up%,0):pokev+5,xy%(up%,1)
6020 rem:pokev+4,fnx(up%):pokev+5,fny(up%)
6030 return
6500 rem initial page
6505 poke53280,0:poke53281,0
6510 print "[147]";
6520 print "";spc(16)"[158] [157][157][157][157][157][157][157][157] headon [157][157][157][157][157][157][157][157] [146]"
6530 print"[159]you control the [158]yellow[159] car with"
6540 print"the joystick in port 2."
6550 print"pushing left will turn the car left"
6560 print"pushing right will turn the car right"
6570 print " (from the drivers point of view)"
6580 printspc(10);"[215][159] - 1 point"
6590 printspc(1