Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Pacman Game. Can't stop at walls. Pls help
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Jynx101




PostPosted: Sat May 20, 2017 9:42 pm   Post subject: Pacman Game. Can't stop at walls. Pls help

What is it you are trying to achieve?
Replace all the <> with your answers/code and remove the

Make Pacman stop at the walls

What is the problem you are having?
<Answer Here>


Describe what you have tried to solve this problem

Using whatdotcolor, but doesn't work. You won't see it on the code, cause i removed it


Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)


Turing:


setscreen ("graphics:600;600")

drawfillbox (0, 0, maxx, maxy, black)

var font, font1 : int
font := Font.New ("Broadway:56:bold")
font1 := Font.New ("Broadway:30:bold")

Draw.Text ("PACMAN", 125, 400, font, yellow)
Draw.Text ("Classic", 232, 300, font1, brightblue)
Draw.Text ("Survival", 214, 250, font1, brightred)
Draw.Text ("Maze", 251, 200, font1, green)
Draw.Text ("Hell", 269, 150, font1, purple)






procedure Classic

    setscreen ("graphics:448,576,offscreenonly,nobuttonbar")
    View.Set ("offscreenonly")
    var chars : array char of boolean
    var xlocation, ylocation, xdirection, ydirection, r : int
    var pacstate : boolean

    xlocation := 0
    ylocation := 0
    xdirection := 225
    ydirection := 150

    r := 11
    pacstate := true

    var background := Pic.FileNew ("PacmanBack.bmp")

    loop
        Pic.Free (background)
        background := Pic.FileNew ("PacmanBack.bmp")
        Pic.Draw (background, 0, 0, picMerge)

        drawfillbox (100, 100, 200, 200, blue)



        Input.KeyDown (chars)
        if chars (KEY_RIGHT_ARROW) then
            if pacstate = true then     %Mouth Closed
                drawfilloval (xdirection, ydirection, r, r, yellow)
                xdirection := xdirection + 5
                pacstate := false     %Changes it so the next time around it's open
            else     %Mouth Open
                drawfilloval (xdirection, ydirection, r, r, yellow)
                drawfillarc (xdirection, ydirection, r, r, 310, 40, black)
                xdirection := xdirection + 5
                pacstate := true     %Changes it so the next time the mouth is closed
            end if

        elsif chars (KEY_LEFT_ARROW) then
            if pacstate = true then
                drawfilloval (xdirection, ydirection, r, r, yellow)
                xdirection := xdirection - 5
                pacstate := false
            else
                drawfilloval (xdirection, ydirection, r, r, yellow)
                drawfillarc (xdirection, ydirection, r, r, 130, 210, black)
                xdirection := xdirection - 5
                pacstate := true
            end if

        elsif chars (KEY_DOWN_ARROW) then
            if pacstate = true then
                drawfilloval (xdirection, ydirection, r, r, yellow)
                ydirection := ydirection - 5
                pacstate := false
            else
                drawfilloval (xdirection, ydirection, r, r, yellow)
                drawfillarc (xdirection, ydirection, r, r, 230, 310, black)
                ydirection := ydirection - 5
                pacstate := true
            end if

        elsif chars (KEY_UP_ARROW) then
            if pacstate = true then
                drawfilloval (xdirection, ydirection, r, r, yellow)
                ydirection := ydirection + 5
                pacstate := false
            else
                drawfilloval (xdirection, ydirection, r, r, yellow)
                drawfillarc (xdirection, ydirection, r, r, 70, 120, black)
                ydirection := ydirection + 5
                pacstate := true
            end if


        else
            drawfilloval (xdirection, ydirection, 12, 12, yellow)     %Draws Pacman when no keys are pressed
        end if

        View.UpdateArea (xdirection - 45, ydirection - 45, xdirection + 45, ydirection + 45)         %Updates just the area to reduce lag
        delay (12)


    end loop

end Classic










procedure Survival

    setscreen ("graphics:448,576,offscreenonly,nobuttonbar")
    View.Set ("offscreenonly")
    var chars : array char of boolean
    var x, y : int
    var pacstate : boolean

    x := 225
    y := 150
    pacstate := true

    var background := Pic.FileNew ("PacmanBack.bmp")

    loop
        Pic.Free (background)
        background := Pic.FileNew ("PacmanBack.bmp")
        Pic.Draw (background, 0, 0, picMerge)

        Input.KeyDown (chars)
        if chars (KEY_RIGHT_ARROW) then
            if pacstate = true then     %Mouth Closed
                drawfilloval (x, y, 11, 11, yellow)
                x := x + 5
                pacstate := false     %Changes it so the next time around it's open
            else     %Mouth Open
                drawfilloval (x, y, 12, 12, yellow)
                drawfillarc (x, y, 12, 12, 310, 40, black)
                x := x + 5
                pacstate := true     %Changes it so the next time the mouth is closed
            end if

        elsif chars (KEY_LEFT_ARROW) then
            if pacstate = true then
                drawfilloval (x, y, 12, 12, yellow)
                x := x - 5
                pacstate := false
            else
                drawfilloval (x, y, 12, 12, yellow)
                drawfillarc (x, y, 12, 12, 130, 210, black)
                x := x - 5
                pacstate := true
            end if

        elsif chars (KEY_DOWN_ARROW) then
            if pacstate = true then
                drawfilloval (x, y, 12, 12, yellow)
                y := y - 5
                pacstate := false
            else
                drawfilloval (x, y, 12, 12, yellow)
                drawfillarc (x, y, 12, 12, 230, 310, black)
                y := y - 5
                pacstate := true
            end if

        elsif chars (KEY_UP_ARROW) then
            if pacstate = true then
                drawfilloval (x, y, 12, 12, yellow)
                y := y + 5
                pacstate := false
            else
                drawfilloval (x, y, 12, 12, yellow)
                drawfillarc (x, y, 12, 12, 70, 120, black)
                y := y + 5
                pacstate := true
            end if
        else
            drawfilloval (x, y, 12, 12, yellow)     %Draws Pacman when no keys are pressed

        end if



        View.UpdateArea (x - 45, y - 45, x + 45, y + 45)     %Updates just the area to reduce lag
        delay (12)

    end loop


end Survival
















procedure Maze

    setscreen ("graphics:990,576,offscreenonly,nobuttonbar")
    View.Set ("offscreenonly")
    var chars : array char of boolean
    var x, y : int
    var pacstate : boolean


    x := 495
    y := 260
    pacstate := true

    var background := Pic.FileNew ("maze.bmp")

    loop
        Pic.Free (background)
        background := Pic.FileNew ("maze.bmp")
        Pic.Draw (background, 0, 0, picMerge)

        Input.KeyDown (chars)
        if chars (KEY_RIGHT_ARROW) then
            if pacstate = true then     %Mouth Closed
                drawfilloval (x, y, 12, 12, yellow)
                x := x + 5
                pacstate := false     %Changes it so the next time around it's open
            else     %Mouth Open
                drawfilloval (x, y, 12, 12, yellow)
                drawfillarc (x, y, 12, 12, 310, 40, black)
                x := x + 5
                pacstate := true     %Changes it so the next time the mouth is closed
            end if

        elsif chars (KEY_LEFT_ARROW) then
            if pacstate = true then
                drawfilloval (x, y, 12, 12, yellow)
                x := x - 5
                pacstate := false
            else
                drawfilloval (x, y, 12, 12, yellow)
                drawfillarc (x, y, 12, 12, 130, 210, black)
                x := x - 5
                pacstate := true
            end if

        elsif chars (KEY_DOWN_ARROW) then
            if pacstate = true then
                drawfilloval (x, y, 12, 12, yellow)
                y := y - 5
                pacstate := false
            else
                drawfilloval (x, y, 12, 12, yellow)
                drawfillarc (x, y, 12, 12, 230, 310, black)
                y := y - 5
                pacstate := true
            end if

        elsif chars (KEY_UP_ARROW) then
            if pacstate = true then
                drawfilloval (x, y, 12, 12, yellow)
                y := y + 5
                pacstate := false
            else
                drawfilloval (x, y, 12, 12, yellow)
                drawfillarc (x, y, 12, 12, 70, 120, black)
                y := y + 5
                pacstate := true
            end if
        else
            drawfilloval (x, y, 12, 12, yellow)     %Draws Pacman when no keys are pressed
        end if

        View.UpdateArea (x - 45, y - 45, x + 45, y + 45)     %Updates just the area to reduce lag
        delay (10)

    end loop

end Maze













procedure Hell
    setscreen ("graphics:500,500,offscreenonly,nobuttonbar")
    View.Set ("offscreenonly")
    var chars : array char of boolean
    var x, y : int
    var pacstate : boolean


    x := 250
    y := 70
    pacstate := true

    var background := Pic.FileNew ("Hell.bmp")

    loop
        Pic.Free (background)
        background := Pic.FileNew ("Hell.bmp")
        Pic.Draw (background, 0, 0, picMerge)

        Input.KeyDown (chars)
        if chars (KEY_RIGHT_ARROW) then
            if pacstate = true then     %Mouth Closed
                drawfilloval (x, y, 8, 8, yellow)
                x := x + 5
                pacstate := false     %Changes it so the next time around it's open
            else     %Mouth Open
                drawfilloval (x, y, 8, 8, yellow)
                drawfillarc (x, y, 8, 8, 310, 40, black)
                x := x + 5
                pacstate := true     %Changes it so the next time the mouth is closed
            end if

        elsif chars (KEY_LEFT_ARROW) then
            if pacstate = true then
                drawfilloval (x, y, 8, 8, yellow)
                x := x - 5
                pacstate := false
            else
                drawfilloval (x, y, 8, 8, yellow)
                drawfillarc (x, y, 8, 8, 130, 210, black)
                x := x - 5
                pacstate := true
            end if

        elsif chars (KEY_DOWN_ARROW) then
            if pacstate = true then
                drawfilloval (x, y, 8, 8, yellow)
                y := y - 5
                pacstate := false
            else
                drawfilloval (x, y, 8, 8, yellow)
                drawfillarc (x, y, 8, 8, 230, 310, black)
                y := y - 5
                pacstate := true
            end if

        elsif chars (KEY_UP_ARROW) then
            if pacstate = true then
                drawfilloval (x, y, 8, 8, yellow)
                y := y + 5
                pacstate := false
            else
                drawfilloval (x, y, 8, 8, yellow)
                drawfillarc (x, y, 8, 8, 70, 120, black)
                y := y + 5
                pacstate := true
            end if
        else
            drawfilloval (x, y, 8, 8, yellow)     %Draws Pacman when no keys are pressed
        end if

        View.UpdateArea (x - 45, y - 45, x + 45, y + 45)     %Updates just the area to reduce lag
        delay (10)

    end loop


end Hell












var x, y, button : int
loop
    mousewhere (x, y, button)
    locate (1, 1)
    if button = 1 and x > 230 and x < 385 and y > 300 and y < 340 then
        cls
        Classic
    elsif button = 1 and x > 214 and x < 420 and y > 250 and y < 300 then
        cls
        Survival
    elsif button = 1 and x > 249 and x < 370 and y > 200 and y < 250 then
        cls
        Maze
    elsif button = 1 and x > 267 and x < 460 and y > 150 and y < 200 then
        cls
        Hell
    end if
end loop





Please specify what version of Turing you are using
4.1.1
Sponsor
Sponsor
Sponsor
sponsor
Insectoid




PostPosted: Sun May 21, 2017 1:30 pm   Post subject: RE:Pacman Game. Can\'t stop at walls. Pls help

Quote:
You won't see it on the code, cause i removed it


I suggest you put it back in the code, and re-post it here, so we can see where you went wrong.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 2 Posts ]
Jump to:   


Style:  
Search: