COLOR 2 'for a phosphor look
CONST powerPelletMAX
= 7 'duration of the power pellet effects
state
AS _BYTE '0 = taken; 1 = dot; 2 = power pellet
setupMap
setupDots
endGame = false
direction = 1
lastMove! = 0
processInput
movePacMan
detectColision
drawLabyrinth
IF dot
(i
).x
= PacMan.x
AND dot
(i
).y
= PacMan.y
THEN 'dot
score = score + 10
dot(i).state = 0
'power pellet
score = score + 20
dot(i).state = 0
IF direction
= 1 OR direction
= 3 THEN refreshRate!
= .1 IF direction
= 2 OR direction
= 4 THEN refreshRate!
= .12
IF didMove
= false
AND lastMove!
> 0 THEN direction
= 0
'same axis changes are immediately applied
IF direction
= 1 OR direction
= 3 THEN direction
= nextDirection: nextDirection
= 0 IF direction
= 2 OR direction
= 4 THEN direction
= nextDirection: nextDirection
= 0
IF direction
= 0 THEN direction
= nextDirection
prevDirection = direction
direction = nextDirection
didMove = false
IF ASC(mapData
(PacMan.y
), PacMan.x
- 1) = 32 THEN PacMan.x = PacMan.x - 1
didMove = true
nextDirection = direction
direction = prevDirection
PacMan.x
= LEN(mapData
(1)) didMove = true
IF ASC(mapData
(PacMan.y
- 1), PacMan.x
) = 32 THEN PacMan.y = PacMan.y - 1
didMove = true
nextDirection = direction
direction = prevDirection
PacMan.y = 23
didMove = true
IF ASC(mapData
(PacMan.y
), PacMan.x
+ 1) = 32 THEN PacMan.x = PacMan.x + 1
didMove = true
nextDirection = direction
direction = prevDirection
PacMan.x = 1
didMove = true
IF ASC(mapData
(PacMan.y
+ 1), PacMan.x
) = 32 THEN PacMan.y = PacMan.y + 1
didMove = true
nextDirection = direction
direction = prevDirection
PacMan.y = 1
didMove = true
'dot
thisDot = thisDot + 1
dot(thisDot).x = c
dot(thisDot).y = i
dot(thisDot).state = 1
'power pellet
thisDot = thisDot + 1
dot(thisDot).x = c
dot(thisDot).y = i
dot(thisDot).state = 2
'ghost
thisGhost = thisGhost + 1
ghost(thisGhost).x = c
ghost(thisGhost).y = i
ghost(thisGhost).state = true
'PacMan
PacMan.x = c
PacMan.y = i
'wall separator
c$ = " "
IF dot
(i
).state
= 1 THEN c$
= "." IF dot
(i
).state
= 2 THEN c$
= "o"
PacManChar$ = "C"
IF PacMan.x
MOD 2 = 0 THEN PacManChar$
= "C" ELSE PacManChar$
= "c" IF PacMan.y
MOD 2 <> 0 THEN PacManChar$
= "C" ELSE PacManChar$
= "c"
IF TIMER - powerPelletTimer
< powerPelletMAX
THEN ghostChar$
= "m" ELSE ghostChar$
= "A"
'Map data
DATA "+-------------------+# #+# #+-------------------+" DATA "|#. . . . . . . . . . .#|#. . . . . . . . . . .#|" DATA "|#.#+-----+#.#+-----+#.#|#.#+-----+#.#+-----+#.#|" DATA "|#o#| |#.#| |#.#|#.#| |#.#| |#o#|" DATA "|#.#+-----+#.#+-----+#.#|#.#+-----+#.#+-----+#.#|" DATA "|#. . . . . . . . . . .#|#. . . . . . . . . . .#|" DATA "|#.#-------#.#|#.#------+------#.#|#.#-------#.#|" DATA "|#. . . . . .#|#. . . .#|#. . . .#|#. . . . . .#|" DATA "+---------+#.#------+# #|# #+-----+#.#+---------+" DATA "----------+#.#|# #+-----#-----+# #|#.#+----------" DATA " . #| A A A A |# . " DATA "----------+#.#|# #+-----#-----+# #|#.#+----------" DATA "+---------+#.#|# #------+------# #|#.#+---------+" DATA "|#. . . . . . . . . . .#|#. . . . . . . . . . .#|" DATA "|#.#------+#.#-------#.#|#.#-------#.#+------#.#|" DATA "|#o . . .#|#. . . . . . C . . . . . .#|#. . . o#|" DATA "+------#.#|#.#|# #-------------# #|#.#|#.#------+" DATA "|#. . . . . .#|#. . . . . . . . .#|#. . . . . .#|" DATA "|#.#----------+------#.#|#.#------+----------#.#|" DATA "|#. . . . . . . . . . .#|#. . . . . . . . . . .#|" DATA "+-------------------+# #+# #+-------------------+"