Collision Detection PacMan

Hi - I'm creating a PacMan style game, which involved the character colliding with the pills, which then disappear, and add to the score. However, whenever the PacMan is set to go over one of these "pills" - they just remain, and the score is never added to.

------------------------------------

LET pos = 0
DO
LET pos = pos + 1
LET m = dot_information(pos,1)
LET n = dot_information(pos,2)

IF m = x THEN
IF n = y THEN
LET dot_information(pos,3) = 1
END IF
END IF

IF dot_information(pos,3) = 0 THEN
BOX SHOW dot_image$ at m,n
END IF
LOOP UNTIL pos = 21

------------------------------------

That is the code, where x represents the horizontal position of the character, and y represents the vertical position. Both of these range from 0 to 1. I've tried a variation of IF statements, DO statements and everything, and I'm at my wit's end. Any advice is appreciated. Here is the other code I tried:

------------------------------------
IF m = x AND y = n THEN
LET dot_information(loop,3) = 1
END IF
------------------------------------

Comments

tb pac man game

one bug is visible right away! pos is a *keyword*, equivalent to instr in most (any) form of ms basic. change that "pos" to something else.

send me the jpeg graphics for the game, and let me work on it. instead of reinventing the wheel, get a qbasic / quickbasic version of the game and convert it.

keithkeller687@gmail.com

The whole code

CALL Read_image("JPEG",smile_l$,"images\left.JPG")
CALL Read_image("JPEG",smile_r$,"images\right.JPG")
CALL Read_image("JPEG",smile_u$,"images\up.JPG")
CALL Read_image("JPEG",smile_d$,"images\down.JPG")
CALL Read_image("JPEG",dot_image$,"images\dot.JPG")

DIM dot_information(21,3)

SUB initial_info
FOR loop = 1 to 7
LET z = (loop + 1) / 10
LET dot_information(loop,1) = z

LET dot_information(loop,2) = 0.2
LET dot_information(loop,3) = 0
NEXT loop

FOR loop = 8 to 14
LET integer = loop - 7
LET z = (integer + 1) / 10
LET dot_information(loop,1) = z

LET dot_information(loop,2) = 0.3
LET dot_information(loop,3) = 0
NEXT loop

FOR loop = 15 to 21
LET integer = loop - 14
LET z = (integer + 1) / 10
LET dot_information(loop,1) = z

LET dot_information(loop,2) = 0.4
LET dot_information(loop,3) = 0
NEXT loop
END SUB

SET BACKGROUND COLOR "red"
CLEAR

CALL initial_info

LET k = 303
LET x = 0.1
LET y = 0.2

DO
DO WHILE KEY INPUT
GET KEY k
LOOP

LET direction$ = ""
CALL key_input
LOOP

SUB key_input
IF k = 301 THEN
LET direction$ = "up"
CALL up
ELSEIF k = 302 THEN
LET direction$ = "down"
CALL down
ELSEIF k = 303 THEN
LET direction$ = "right"
CALL right
ELSEIF k = 304 THEN
LET direction$ = "left"
CALL left
END IF
END SUB

SUB up
IF y =< 0.9 THEN
LET y = y + 0.002
CLEAR
CALL dot_display
BOX SHOW smile_u$ at x,y
PAUSE 0.02
END IF
END SUB

SUB down
IF y => 0.1 THEN
LET y = y - 0.002
CLEAR
CALL dot_display
BOX SHOW smile_d$ at x,y
PAUSE 0.02
END IF
END SUB

SUB left
IF x => 0.1 THEN
LET x = x - 0.002
CLEAR
CALL dot_display
BOX SHOW smile_l$ at x,y
PAUSE 0.02
END IF
END SUB

SUB right
IF x =< 0.9 THEN
LET x = x + 0.002
CLEAR
CALL dot_display
BOX SHOW smile_r$ at x,y
PAUSE 0.02
END IF
END SUB

SUB dot_display
LET pos = 0
DO
LET pos = pos + 1
LET m = dot_information(pos,1)
LET n = dot_information(pos,2)

IF m = x THEN
IF n = y THEN
LET dot_information(pos,3) = 1
END IF
END IF

IF dot_information(pos,3) = 0 THEN
BOX SHOW dot_image$ at m,n
END IF
LOOP UNTIL pos = 21

END SUB

GET KEY PAUSE
END