Skip to content

Instantly share code, notes, and snippets.

@tomaes
Last active Mar 22, 2020
Embed
What would you like to do?
Snake ✕ Tron; CBM4032 / Commodore PET game.
0 rem cbm 4032 game test
1 :
2 sm=32768: h=sm+414
3 x=0: y=0: dx=1: dy=0
4 lv=0: g0=1: pl(0)=15: pl(1)=86
5 u$="w": l$="a": d$="s": r$="d"
6 print chr$(147)spc(250)spc(158)
7 print "snake * tron. get ready!"
8 fori=.to99:pokeh,32::::::::::pokeh,83:next
9 poke 59467,16: rem sound on
10 :
20 lv=lv+1: ob=48+lv
22 print chr$(147): gosub 200
24 fori=.to199:next
26 q=sm+490: s=10-lv*.2
27 fori=.to20steps:pokeq+i,pl(rnd(1)*2):next
28 u=int(rnd(1)*40): v=int(rnd(1)*25)
29 o=sm+40*v+u: if peek(o)<>32 then 28
32 :
40 p=sm+y*40+x: m=peek(p)
41 if m=pl(.)orm=pl(1) then g0=0
42 if m=obandg0 then 20
44 t=(t+1)and1
47 poke o,205:::: poke p,pl(t): poke o,ob
50 get a$
52 ifa$=l$thendx=-1:dy=.
54 ifa$=r$thendx=+1:dy=.
56 ifa$=u$thendy=-1:dx=.
58 ifa$=d$thendy=+1:dx=.
70 x=x+dx: y=y+dy
74 if x<0orx>39ory<0ory>24 then g0=0
84 if g0 then 40
85 :
90 gosub 200: gosub 200
91 fori=.to69: pokep,pl(iand1): next
92 fori=.to49: print: next
93 print "game over! level"lv
94 r$(5)="perfect "+chr$(211): r$(4)="well done!" : r$(3)="solid"
95 r$(0)="you can do better!": r$(2)="try harder!": r$(1)="not good"
96 q=lv/38: ra=5+(q<1.)+(q<.8)+(q<.5)+(q<.3)+(q<.1)
97 print str$(ra)"/5 "r$(ra)
98 end
99 :
200 poke 59466,51 : rem octave
201 poke 59464,238 : rem freq
203 fori=.to99: next
204 poke 59464,0 : rem ..off
205 return
control via cursor keys:
4 l$=chr$(157): r$=chr$(29): u$=chr$(145): d$=chr$(17)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment