Follow us
Pacman - that game of eating dots and being chased by ghosts.
This is my attempt to recreate it on the C64. Starting off writing the game in basic to get the fundamentals working.
Episode 1 - Video for this episode
Created a border, added the ability to move Pac char about using keys and then added 4 ghosts
100 print "{clear}";
110 poke 53280,0:poke 53281,0
120 pa=94 :rem pac char
130 pd=0: rem pac dir 0 = up, 1=down, 2=left, 3=right
140 px=20: xx=0 :rem pac x pos
150 py=12: yy=0 :rem pac y pos
160 gh=88: rem ghost
170 dim gx(4),gy(4),ga(4),gb(4):rem Ghost x, y, xmov, ymov
180 gosub 2000: rem set up ghosts
190 gosub 1000:rem show screen
200 rem mainloop
210 geta$:ifa$="" then 210
220 if a$="s" then yy=-1
230 if a$="x" then yy=1
240 if a$="," then xx=-1
250 if a$="." then xx=1
260 if px+xx<1 or px+xx>=39 then 300
270 if py+yy<1 or py+yy>=23 then 300
275 poke 1024+(40*py)+px,32
280 px=px+xx:py=py+yy
290 poke 1024+(40*py)+px,pa
300 xx=0:yy=0
310 gosub 2100 :rem moveghosts
400 goto 200
1000 rem screen is here
1010 print "{reverse on} {reverse off}";
1020 for x=0 to 21
1030 print "{reverse on} {reverse off} {reverse on} {reverse off}";
1040 next x
1050 print "{reverse on} {reverse off}{home}";
1300 return
2000 get a$:if a$="" then 2000
2010 for z=1 to 4
2015 q=rnd(-ti)
2020 q=int(rnd(0)*38)+1:gx(z)=q
2030 q=int(rnd(0)*22)+1:gy(z)=q
2040 next z
2050 return
2100 for z=1 to 4
2110 poke 1024+(40*gy(z))+gx(z),32
2120 w=int(rnd(0)*4)+1
2130 on w goto 2140,2142,2144,2146
2140 if gy(z)-1<1 then 2220
2142 if gy(z)+1>=23 then 2220
2144 if gx(z)-1<1 then 2220
2146 if gx(z)+1>=39 then 2220
2150 if w=1 then gy(z)=gy(z)-1:goto 2220
2160 if w=2 then gy(z)=gy(z)+1:goto 2220
2170 if w=3 then gx(z)=gx(z)-1:goto 2220
2180 if w=4 then gx(z)=gx(z)+1:goto 2220
2220 poke 1024+(40*gy(z)+gx(z)),gh
2230 next z
2240 return