
-----------------------------------
Waked
Fri Apr 06, 2012 3:10 pm

movement of pacman
-----------------------------------
i am making a pacman game as my final project. im just having some trouble making pacman move all the way until he hits a wall. i can only make him move as long as u hold the arrow.
this is what i have so please help:
 
var command : array char of boolean
var frame : int := 0
var Pacman : array 1 .. 4 of array 1 .. 4 of int

Pacman (1) (1) := Pic.FileNew ("pics/pClosed.bmp")
Pacman (1) (2) := Pic.FileNew ("pics/pUp1.bmp")
Pacman (1) (3) := Pic.FileNew ("pics/pUp2.bmp")
Pacman (1) (4) := Pacman (1) (2)

Pacman (2) (1) := Pic.FileNew ("pics/pClosed.bmp")
Pacman (2) (2) := Pic.FileNew ("pics/pLeft1.bmp")
Pacman (2) (3) := Pic.FileNew ("pics/pLeft2.bmp")
Pacman (2) (4) := Pacman (2) (2)

Pacman (3) (1) := Pic.FileNew ("pics/pClosed.bmp")
Pacman (3) (2) := Pic.FileNew ("pics/pDown1.bmp")
Pacman (3) (3) := Pic.FileNew ("pics/pDown2.bmp")
Pacman (3) (4) := Pacman (3) (2)

Pacman (4) (1) := Pic.FileNew ("pics/pClosed.bmp")
Pacman (4) (2) := Pic.FileNew ("pics/pRight1.bmp")
Pacman (4) (3) := Pic.FileNew ("pics/pRight2.bmp")
Pacman (4) (4) := Pacman (4) (2)

var pacman : int := Pacman (2) (2)

%---------------------------------------------------------------------------------

var font := Font.New ("comicsansms:19:bold")
var stage : int := Pic.FileNew ("pics/stage1.bmp")

proc Visuals ( px, py, score : int)
    Pic.Draw (stage, 0, 0, picCopy)
    Font.Draw ("GAME", 30, maxy - 50, font, 84)
    Font.Draw ("SCORE", 24, maxy - 75, font, 84)
    Font.Draw (intstr (score), 12, maxy - 110, font, 84)
    Pic.Draw (pacman, px, py, picMerge)
    for i : 1 .. 4
        if frame > 4 then
            frame := 1
        end if
        if command (KEY_UP_ARROW) then
            pacman := Pacman (1) (frame)
        end if
        if command (KEY_DOWN_ARROW) then
            pacman := Pacman (3) (frame)
        end if
        if command (KEY_RIGHT_ARROW) then
            pacman := Pacman (4) (frame)
        end if
        if command (KEY_LEFT_ARROW) then
            pacman := Pacman (2) (frame)
        end if
    end for

    View.Update
end Visuals

%----------------------------------------------------------------------------------

proc PacmanMove (var px, py : int)
    Input.KeyDown (command)
    if command (KEY_UP_ARROW) and whatdotcolor (px + 26, py + 26) = 7 and whatdotcolor (px + 15, py + 32) = 7 and whatdotcolor (px + 3, py + 26) = 7 then
        py += 1
        frame := frame + 1
    end if
    if command (KEY_DOWN_ARROW) and whatdotcolor (px + 26, py + 3) = 7 and whatdotcolor (px + 15, py - 5) = 7 and whatdotcolor (px + 3, py + 3) = 7 then
        py -= 1
        frame := frame + 1
    end if
    if command (KEY_RIGHT_ARROW) and whatdotcolor (px + 26, py + 3) = 7 and whatdotcolor (px + 32, py + 15) = 7 and whatdotcolor (px + 26, py + 26) = 7 then
        px += 1
        frame := frame + 1
    end if
    if command (KEY_LEFT_ARROW) and whatdotcolor (px + 3, py + 3) = 7 and whatdotcolor (px - 5, py + 15) = 7 and whatdotcolor (px + 3, py + 26) = 7 then
        px -= 1
        frame := frame + 1
    end if
end PacmanMove

%----------------------------------------------------------------------------------

proc Teleport (var px, py : int)
    if px = 340 and py = 697 and py >= 340 and py 