load image "PacmanL.png",1
load image "PacmanR.png",2
load image "PacmanU.png",3
load image "PacmanD.png",4
load image "bblock.png",5
sync on
sync rate 0
hide mouse
pacx=320
pacy=336
pacd=3
distancex=0
distancey=0
pacmapx=20
pacmapy=21
pacs=0
pacin=1
dim map(28,30)
`read map data and store in the map array
restore map
for j = 0 to 28
for i = 0 to 28
read map(i,j)
next i
next j
`draw the map
Sprite 1,pacx,pacy,pacin
set sprite 1,1,1
for x = 0 to 28
for y = 0 to 29
if map(x,y) = 1 then box x*16,y*16,(x*16)+16,(y*16)+16
if map(x,y) = 2 then circle x*16+8, y*16+8, 3
if map(x,y) = 3 then circle x*16+8, y*16+8, 6
next y
next x
Do
`exit the program
if escapekey()=1 then end
`check directions and collision
if upkey()=1 then pacd=1 : pacin=3
if downkey()=1 then pacd=2 : pacin=4
if leftkey()=1 then pacd=3 : pacin=1
if rightkey()=1 then pacd=4 : pacin=2
if pacd=1 and map(pacmapx,pacmapy-1)<>1 then pacy=pacy-4 : distancey=distancey-4
if pacd=2 and map(pacmapx,pacmapy+1)<>1 then pacy=pacy+4 : distancey=distancey+4
if pacd=3 and map(pacmapx-1,pacmapy)<>1 then pacx=pacx-4 : distancex=distancex-4
if pacd=4 and map(pacmapx+1,pacmapy)<>1 then pacx=pacx+4 : distancex=distancex+4
if distancex=16 then inc pacmapx : map(pacmapx,pacmapy)=5 : distancex=0
if distancex=-16 then dec pacmapx : map(pacmapx,pacmapy)=5 : distancex=0
if distancey=16 then inc pacmapy : map(pacmapx,pacmapy)=5 : distancey=0
if distancey=-16 then dec pacmapy : map(pacmapx,pacmapy)=5 : distancey=0
for x = 0 to 28
for y = 0 to 29
if map(x,y) = 5 then paste image 5,x*16,y*16 : numpills=numpills-1
next y
next x
Sprite 1,pacx,pacy,pacin
if map(pacmapx,pacmapy)=2 then pacs=pacs+1
if numpills=0 then goto win
Sync
Loop
win:
cls
text 10,10,"score: " +STR$(pacs)
wait key
`data for the map
map:
data 0,0,0,0,0,0,0,0,0,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2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1
data 0,0,0,0,0,0,0,0,0,1,2,1,2,1,1,1,1,2,1,1,2,1,1,1,1,2,1,2,1
data 0,0,0,0,0,0,0,0,0,1,2,1,2,1,1,1,1,2,1,1,2,1,1,1,1,2,1,2,1
data 0,0,0,0,0,0,0,0,0,1,2,1,2,1,1,1,1,2,1,1,2,1,1,1,1,2,1,2,1
data 0,0,0,0,0,0,0,0,0,1,2,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,2,1
data 0,0,0,0,0,0,0,0,0,1,2,1,1,1,1,2,1,1,1,1,1,1,2,1,1,1,1,2,1
data 0,0,0,0,0,0,0,0,0,1,2,1,1,1,1,2,1,1,1,1,1,1,2,1,1,1,1,2,1
data 0,0,0,0,0,0,0,0,0,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1
data 0,0,0,0,0,0,0,0,0,1,2,1,1,2,1,2,1,1,1,1,1,1,2,1,2,1,1,2,1
data 0,0,0,0,0,0,0,0,0,1,2,1,1,2,1,2,1,1,1,1,1,1,2,1,2,1,1,2,1
data 0,0,0,0,0,0,0,0,0,1,2,2,2,2,1,2,2,2,2,2,2,2,2,1,2,2,2,2,1
data 0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
I have changed the code so that when he eats all of the pills (circles) it says his score but when i have eaten all the pills nothing happens why?