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

Username:   Password: 
 RegisterRegister   
 Help for Pacman eating dots. Have no idea to do it.
Index -> Programming, Turing -> Turing Help
Goto page 1, 2, 3  Next
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Jynx101




PostPosted: Wed May 24, 2017 12:19 pm   Post subject: Help for Pacman eating dots. Have no idea to do it.

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

I'm wanting to have Pacman eat dots, but I have no idea how to

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

I have no idea for making a code for pacman

Describe what you have tried to solve this problem
<Answer Here>

I had ideas of using whatdotcolor but then how would you make the dots disappear?

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

Turing:


%Starting Screen
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)

%PROCEDURES


procedure Classic

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

    x := 225
    y := 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)

        %Pacman borders
        %Turn each one a different color to figure which one is which if you don't know

        drawfillbox (0, 32, maxx, 40, brightblue) %Bottom border of stage
        drawfillbox (0, 520, maxx, 528, brightblue) %Top border of stage
        drawfillbox (0, 32, 7, 223, brightblue) %Bottom left of border
        drawfillbox (maxx - 7, 32, maxx, 223, brightblue) %Bottom right of border
        drawfillbox (0, 520, 7, 368, brightblue) %Top left of border
        drawfillbox (maxx - 7, 520, maxx, 368, brightblue) %Top right of border

        drawfillbox (0, 216, 87, 223, brightblue) %Bottom horizontal far left wall #1
        drawfillbox (maxx - 87, 216, maxx, 223, brightblue) %Bottom horizontal far right wall #1
        drawfillbox (0, 272, 87, 279, brightblue) %Bottom horizontal far left wall #2, above #1,
        drawfillbox (maxx - 87, 272, maxx, 279, brightblue) %Bottom horizontal far right wall #2, above #1

        drawfillbox (0, 312, 87, 319, brightblue) %Top horizontal far left wall #1
        drawfillbox (maxx - 87, 312, maxx, 319, brightblue) %Top horizontal far right wall #1
        drawfillbox (maxx - 87, 368, maxx, 375, brightblue) %Top horizontal far left wall #2, above #1
        drawfillbox (0, 368, 87, 375, brightblue) %Top horizontal far right wall #2, above #1

        drawfillbox (maxx - 87, 220, maxx - 80, 275, brightblue) %Bottom vertical right wall #1
        drawfillbox (80, 220, 87, 275, brightblue) %Bottom vertical left wall #1
        drawfillbox (80, 320, 87, 375, brightblue) %Top vertical left wall #2, above #1
        drawfillbox (maxx - 87, 320, maxx - 80, 375, brightblue) %Top vertical right wall #2, above #1

        %-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

        %Pacman obstacles
        %Again, change color if you don't know which obstacle is which
        %From left to right
        %Top to bottom


        drawfillbox (40, 456, 87, 487, brightblue) %Top far left box
        drawfillbox (45, 461, 82, 482, black) %Inside top far left box

        drawfillbox (120, 456, 183, 487, brightblue) %Top left box
        drawfillbox (125, 461, 178, 482, black) %Inside top left box

        drawfillbox (216, 455, 231, 520, brightblue) %Middle obstacle
        drawfillbox (221, 460, 226, 515, black) %Inside middle obstacle

        drawfillbox (maxx - 183, 456, maxx - 120, 487, brightblue) %Top right box
        drawfillbox (maxx - 178, 461, maxx - 125, 482, black) %Inside right box

        drawfillbox (maxx - 87, 456, maxx - 40, 487, brightblue) %Top far right box
        drawfillbox (maxx - 82, 461, maxx - 45, 482, black) %Inside top far right box

        drawfillbox (40, 408, 87, 423, brightblue) %Far left small box
        drawfillbox (45, 413, 82, 418, black) %Inside far left small box

        drawfillbox (120, 311, 136, 424, brightblue) %Left vertical T
        drawfillbox (120, 360, 183, 375, brightblue) %Left horizontal T
        drawfillbox (125, 316, 131, 419, black) %Inside lefr vertical T
        drawfillbox (125, 365, 178, 370, black) %Inside left horizontal T

        drawfillbox (168, 408, 279, 423, brightblue) %Middle top horizontal T
        drawfillbox (216, 360, 231, 410, brightblue) %Middle top vertical T
        drawfillbox (173, 413, 274, 418, black) %Inside middle top horizontal T
        drawfillbox (221, 365, 226, 413, black) %Inside middle top vertical T

        drawfillbox (maxx - 136, 311, maxx - 120, 424, brightblue) %Right vertical T
        drawfillbox (maxx - 183, 360, maxx - 120, 375, brightblue) %Right horizontal T
        drawfillbox (maxx - 131, 316, maxx - 125, 419, black) %Inside right vertical T
        drawfillbox (maxx - 178, 365, maxx - 125, 370, black) %Inside right horizontal T

        drawfillbox (maxx - 87, 408, maxx - 40, 423, brightblue) %Far right small box
        drawfillbox (maxx - 82, 413, maxx - 45, 418, black) %Inside far right small box

        drawfillbox (168, 264, 280, 327, brightblue) %Box where ghosts are contained
        drawfillbox (175, 271, 273, 320, black) %Inside box where ghosts are contained
        drawfillbox (200, 321, 250, 326, white) %Exit part of box for ghosts

        drawfillbox (120, 215, 135, 279, brightblue) %Middle-ish left box
        drawfillbox (125, 220, 130, 274, black) %Inside middle-ish box

        drawfillbox (168, 216, 279, 231, brightblue) %Middle lower horizontal T
        drawfillbox (216, 168, 231, 215, brightblue) %Middle lower vertical T
        drawfillbox (173, 221, 274, 226, black) %Inside middle lower horizontal T
        drawfillbox (221, 173, 226, 223, black) %Inside middle lower vertical T

        drawfillbox (maxx - 135, 215, maxx - 120, 279, brightblue) %Middle-ish right box
        drawfillbox (maxx - 130, 220, maxx - 125, 274, black) %Inside middle-ish right box

        drawfillbox (120, 168, 183, 183, brightblue) %Left bottom middle-ish box
        drawfillbox (125, 173, 178, 178, black) %Inside left bottom middle-ish box

        drawfillbox (maxx - 183, 168, maxx - 120, 183, brightblue) %Right bottom middle-ish box
        drawfillbox (maxx - 178, 173, maxx - 125, 178, black) %Inside right bottom middle-ish box

        drawfillbox (40, 168, 87, 183, brightblue) %Left hook horizontal
        drawfillbox (72, 120, 87, 183, brightblue) %Left hoot vertical
        drawfillbox (45, 173, 82, 178, black) %Inside left hook horizontal
        drawfillbox (77, 125, 82, 178, black) %Inside left hood vertical

        drawfillbox (maxx - 87, 168, maxx - 40, 183, brightblue) %Right hook horizontal
        drawfillbox (maxx - 87, 120, maxx - 72, 183, brightblue) %Right hook vertical
        drawfillbox (maxx - 82, 173, maxx - 45, 178, black) %Inside right hook horizontal
        drawfillbox (maxx - 82, 125, maxx - 77, 178, black) %Inside right hook vertical

        drawfillbox (0, 120, 39, 135, brightblue) %Left stub
        drawfillbox (10, 125, 34, 130, black) %Inside left stub

        drawfillbox (maxx - 39, 120, maxx, 135, brightblue) %Right stub
        drawfillbox (maxx - 34, 125, maxx - 10, 130, black) %Inside right stub

        drawfillbox (168, 120, 279, 135, brightblue) %Bottom horizontal T
        drawfillbox (216, 72, 231, 119, brightblue) %Bottom vertical T
        drawfillbox (173, 125, 274, 130, black) %Inside bottom horizontal T
        drawfillbox (221, 77, 226, 125, black) %Inside bottom vertical T

        drawfillbox (40, 72, 183, 87, brightblue) %Left horizontal tonfa
        drawfillbox (120, 80, 135, 135, brightblue) %Left vertical tonfa
        drawfillbox (45, 77, 178, 82, black) %Inside left horizontal tonfa
        drawfillbox (125, 83, 130, 130, black) %Inside left vertical tonfa

        drawfillbox (maxx - 183, 72, maxx - 40, 87, brightblue) %Right horizontal tonfa
        drawfillbox (maxx - 135, 80, maxx - 120, 135, brightblue) %Right vertical tonfa
        drawfillbox (maxx - 178, 77, maxx - 45, 82, black) %Inside right horizontal tonfa
        drawfillbox (maxx - 130, 83, maxx - 125, 130, black) %Inside right vertical tonfa

        %-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

        %Pacman himself!
        %Drawing him and if statements

        Input.KeyDown (chars)
        if chars (KEY_RIGHT_ARROW) then

            if pacstate = true then %Mouth Closed

                drawfilloval (x, y, r, r, yellow) %Draws pacman's body
                x := x + 5 %Drives him towards the right
                pacstate := false %Changes to open his mouth

                if whatdotcolor (x + r, y) = brightblue or whatdotcolor (x + r, y + r) = brightblue or whatdotcolor (x + r, y - r) = brightblue then %When it hits something brightblue...
                    x := x - 5 %As a loop, it will then back it up, thus nullfying the movement of pacman
                end if     %A.K.A. Collision Detection



            else %When mouth is open

                drawfilloval (x, y, r, r, yellow) %Draws pacmans' body
                drawfillarc (x, y, r, r, 310, 40, black) %Pacmans' mouth
                x := x + 5 %Changes to open his mouth
                pacstate := true  %Changes to close his mouth


                if whatdotcolor (x + r, y) = brightblue or whatdotcolor (x + r, y + r) = brightblue or whatdotcolor (x + r, y - r) = brightblue then %Radius of pacman hits something brightblue...
                    x := x - 5 %Backs it up, thus nullifying the movement of pacman
                end if

            end if

        elsif chars (KEY_LEFT_ARROW) then

            if pacstate = true then
                drawfilloval (x, y, r, r, yellow)
                x := x - 5
                pacstate := false

                if whatdotcolor (x - r, y) = brightblue or whatdotcolor (x - r, y + r) = brightblue or whatdotcolor (x - r, y - r) = brightblue then
                    x := x + 5
                end if

            else

                drawfilloval (x, y, r, r, yellow)
                drawfillarc (x, y, r, r, 130, 210, black)
                x := x - 5
                pacstate := true

                if whatdotcolor (x - r, y) = brightblue or whatdotcolor (x - r, y + r) = brightblue or whatdotcolor (x - r, y - r) = brightblue then
                    x := x + 5
                end if

            end if

        elsif chars (KEY_DOWN_ARROW) then

            if pacstate = true then
                drawfilloval (x, y, r, r, yellow)
                y := y - 5
                pacstate := false

                if whatdotcolor (x, y - r) = brightblue or whatdotcolor (x + r, y - r) = brightblue or whatdotcolor (x - r, y - r) = brightblue then
                    y := y + 5
                end if

            else

                drawfilloval (x, y, r, r, yellow)
                drawfillarc (x, y, r, r, 230, 310, black)
                y := y - 5
                pacstate := true

                if whatdotcolor (x, y - r) = brightblue or whatdotcolor (x + r, y - r) = brightblue or whatdotcolor (x - r, y - r) = brightblue then
                    y := y + 5
                end if

            end if

        elsif chars (KEY_UP_ARROW) then

            if pacstate = true then

                drawfilloval (x, y, r, r, yellow)
                y := y + 5
                pacstate := false

                if whatdotcolor (x, y + r) = brightblue or whatdotcolor (x - r, y + r) = brightblue or whatdotcolor (x + r, y + r) = brightblue then
                    y := y - 5
                end if

            else

                drawfilloval (x, y, r, r, yellow)
                drawfillarc (x, y, r, r, 70, 120, black)
                y := y + 5
                pacstate := true

                if whatdotcolor (x, y + r) = brightblue or whatdotcolor (x - r, y + r) = brightblue or whatdotcolor (x + r, y + r) = brightblue then
                    y := y - 5

                end if

            end if

        else

            drawfilloval (x, y, 12, 12, yellow)     %Draws Pacman when no keys are pressed

        end if

        delay (40)
        View.UpdateArea (x - 45, y - 45, x + 45, y + 45)     %Updates pacman's area to reduce lag

    end loop
    View.Update
end Classic

%Starting Screen Options

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
    end if
end loop



Please specify what version of Turing you are using
<Answer Here>

4.1.1
Sponsor
Sponsor
Sponsor
sponsor
Insectoid




PostPosted: Wed May 24, 2017 5:11 pm   Post subject: RE:Help for Pacman eating dots. Have no idea to do it.

You are going to need to keep track of every dot somehow. An array will work. Every time you go through the main loop, look at every dot in the array. If it hasn't been eaten yet, draw it. If it has, don't.
The one they call Greed




PostPosted: Wed May 24, 2017 5:40 pm   Post subject: RE:Help for Pacman eating dots. Have no idea to do it.

a Boolean would be able to check if something is true or false, although that might not be the best option for something like this.
Insectoid




PostPosted: Wed May 24, 2017 6:56 pm   Post subject: RE:Help for Pacman eating dots. Have no idea to do it.

A boolean might be exactly the best option for something like this.
The one they call Greed




PostPosted: Wed May 24, 2017 7:51 pm   Post subject: RE:Help for Pacman eating dots. Have no idea to do it.

I would assume it would involve putting the boolean variables into an array and checking each time a dot is touched it turns the boolean false to show it is missing?
Insectoid




PostPosted: Wed May 24, 2017 7:57 pm   Post subject: RE:Help for Pacman eating dots. Have no idea to do it.

That sounds like a good place to start. Why not try it out and see how it goes?
Jynx101




PostPosted: Wed May 24, 2017 9:20 pm   Post subject: RE:Help for Pacman eating dots. Have no idea to do it.

Alright ill see how it goes
Jynx101




PostPosted: Thu May 25, 2017 12:54 pm   Post subject: RE:Help for Pacman eating dots. Have no idea to do it.

Ok, so I'm feeling pretty stupid rn. How dyou drawfilloval in arrays. And how dyou located every dot at a different place?
Sponsor
Sponsor
Sponsor
sponsor
Insectoid




PostPosted: Thu May 25, 2017 7:50 pm   Post subject: RE:Help for Pacman eating dots. Have no idea to do it.

Maybe you need to store more information than just a single boolean then. If every dot needs a place, maybe you should keep track of those places as well.

You can't drawfilloval in an array any more than you can drawfilloval in an int or a string. Drawfilloval takes ints as parameters. Those ints could come from an array though.
The one they call Greed




PostPosted: Thu May 25, 2017 10:04 pm   Post subject: RE:Help for Pacman eating dots. Have no idea to do it.

You need perimeters; x and y, if you can figure out the location for those, store them in an array, you can call them back later when needed.
Jynx101




PostPosted: Sun May 28, 2017 12:27 pm   Post subject: RE:Help for Pacman eating dots. Have no idea to do it.

Ok, i figured that i am not good with arrays and boolean statements, so what i did was i coded every single dot (took a lot less than i though) and trying to do drawfilloval behind pacman so that it would erase the dots, but its not overlapping.

The code is the exact same but:

%Starting Screen
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)

%PROCEDURES

procedure Classic

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

x := 225
y := 150
r := 11
p := 4
c := 7

pacstate := true
dots := true

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

loop

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

%Pacman borders
%Turn each one a different color to figure which one is which if you don't know

drawfillbox (0, 32, maxx, 40, brightblue) %Bottom border of stage
drawfillbox (0, 520, maxx, 528, brightblue) %Top border of stage
drawfillbox (0, 32, 7, 223, brightblue) %Bottom left of border
drawfillbox (maxx - 7, 32, maxx, 223, brightblue) %Bottom right of border
drawfillbox (0, 520, 7, 368, brightblue) %Top left of border
drawfillbox (maxx - 7, 520, maxx, 368, brightblue) %Top right of border

drawfillbox (0, 216, 87, 223, brightblue) %Bottom horizontal far left wall #1
drawfillbox (maxx - 87, 216, maxx, 223, brightblue) %Bottom horizontal far right wall #1
drawfillbox (0, 272, 87, 279, brightblue) %Bottom horizontal far left wall #2, above #1,
drawfillbox (maxx - 87, 272, maxx, 279, brightblue) %Bottom horizontal far right wall #2, above #1

drawfillbox (0, 312, 87, 319, brightblue) %Top horizontal far left wall #1
drawfillbox (maxx - 87, 312, maxx, 319, brightblue) %Top horizontal far right wall #1
drawfillbox (maxx - 87, 368, maxx, 375, brightblue) %Top horizontal far left wall #2, above #1
drawfillbox (0, 368, 87, 375, brightblue) %Top horizontal far right wall #2, above #1

drawfillbox (maxx - 87, 220, maxx - 80, 275, brightblue) %Bottom vertical right wall #1
drawfillbox (80, 220, 87, 275, brightblue) %Bottom vertical left wall #1
drawfillbox (80, 320, 87, 375, brightblue) %Top vertical left wall #2, above #1
drawfillbox (maxx - 87, 320, maxx - 80, 375, brightblue) %Top vertical right wall #2, above #1

%-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

%Pacman obstacles
%Again, change color if you don't know which obstacle is which
%From left to right
%Top to bottom

drawfillbox (40, 456, 87, 487, brightblue) %Top far left box
drawfillbox (45, 461, 82, 482, black) %Inside top far left box

drawfillbox (120, 456, 183, 487, brightblue) %Top left box
drawfillbox (125, 461, 178, 482, black) %Inside top left box

drawfillbox (216, 455, 231, 520, brightblue) %Middle obstacle
drawfillbox (221, 460, 226, 515, black) %Inside middle obstacle

drawfillbox (maxx - 183, 456, maxx - 120, 487, brightblue) %Top right box
drawfillbox (maxx - 178, 461, maxx - 125, 482, black) %Inside right box

drawfillbox (maxx - 87, 456, maxx - 40, 487, brightblue) %Top far right box
drawfillbox (maxx - 82, 461, maxx - 45, 482, black) %Inside top far right box

drawfillbox (40, 408, 87, 423, brightblue) %Far left small box
drawfillbox (45, 413, 82, 418, black) %Inside far left small box

drawfillbox (120, 311, 136, 423, brightblue) %Left vertical T
drawfillbox (120, 360, 183, 375, brightblue) %Left horizontal T
drawfillbox (125, 316, 131, 418, black) %Inside lefr vertical T
drawfillbox (125, 365, 178, 370, black) %Inside left horizontal T

drawfillbox (168, 408, 279, 423, brightblue) %Middle top horizontal T
drawfillbox (216, 360, 231, 410, brightblue) %Middle top vertical T
drawfillbox (173, 413, 274, 418, black) %Inside middle top horizontal T
drawfillbox (221, 365, 226, 413, black) %Inside middle top vertical T

drawfillbox (maxx - 136, 311, maxx - 120, 423, brightblue) %Right vertical T
drawfillbox (maxx - 183, 360, maxx - 120, 375, brightblue) %Right horizontal T
drawfillbox (maxx - 131, 316, maxx - 125, 418, black) %Inside right vertical T
drawfillbox (maxx - 178, 365, maxx - 125, 370, black) %Inside right horizontal T

drawfillbox (maxx - 87, 408, maxx - 40, 423, brightblue) %Far right small box
drawfillbox (maxx - 82, 413, maxx - 45, 418, black) %Inside far right small box

drawfillbox (168, 264, 280, 327, brightblue) %Box where ghosts are contained
drawfillbox (175, 271, 273, 320, black) %Inside box where ghosts are contained
drawfillbox (200, 321, 250, 326, white) %Exit part of box for ghosts

drawfillbox (120, 215, 135, 279, brightblue) %Middle-ish left box
drawfillbox (125, 220, 130, 274, black) %Inside middle-ish box

drawfillbox (168, 216, 279, 231, brightblue) %Middle lower horizontal T
drawfillbox (216, 168, 231, 215, brightblue) %Middle lower vertical T
drawfillbox (173, 221, 274, 226, black) %Inside middle lower horizontal T
drawfillbox (221, 173, 226, 223, black) %Inside middle lower vertical T

drawfillbox (maxx - 135, 215, maxx - 120, 279, brightblue) %Middle-ish right box
drawfillbox (maxx - 130, 220, maxx - 125, 274, black) %Inside middle-ish right box

drawfillbox (120, 168, 183, 183, brightblue) %Left bottom middle-ish box
drawfillbox (125, 173, 178, 178, black) %Inside left bottom middle-ish box

drawfillbox (maxx - 183, 168, maxx - 120, 183, brightblue) %Right bottom middle-ish box
drawfillbox (maxx - 178, 173, maxx - 125, 178, black) %Inside right bottom middle-ish box

drawfillbox (40, 168, 87, 183, brightblue) %Left hook horizontal
drawfillbox (72, 120, 87, 183, brightblue) %Left hoot vertical
drawfillbox (45, 173, 82, 178, black) %Inside left hook horizontal
drawfillbox (77, 125, 82, 178, black) %Inside left hood vertical

drawfillbox (maxx - 87, 168, maxx - 40, 183, brightblue) %Right hook horizontal
drawfillbox (maxx - 87, 120, maxx - 72, 183, brightblue) %Right hook vertical
drawfillbox (maxx - 82, 173, maxx - 45, 178, black) %Inside right hook horizontal
drawfillbox (maxx - 82, 125, maxx - 77, 178, black) %Inside right hook vertical

drawfillbox (0, 120, 39, 135, brightblue) %Left stub
drawfillbox (10, 125, 34, 130, black) %Inside left stub

drawfillbox (maxx - 39, 120, maxx, 135, brightblue) %Right stub
drawfillbox (maxx - 34, 125, maxx - 10, 130, black) %Inside right stub

drawfillbox (168, 120, 279, 135, brightblue) %Bottom horizontal T
drawfillbox (216, 72, 231, 119, brightblue) %Bottom vertical T
drawfillbox (173, 125, 274, 130, black) %Inside bottom horizontal T
drawfillbox (221, 77, 226, 125, black) %Inside bottom vertical T

drawfillbox (40, 72, 183, 87, brightblue) %Left horizontal tonfa
drawfillbox (120, 80, 135, 135, brightblue) %Left vertical tonfa
drawfillbox (45, 77, 178, 82, black) %Inside left horizontal tonfa
drawfillbox (125, 83, 130, 130, black) %Inside left vertical tonfa

drawfillbox (maxx - 183, 72, maxx - 40, 87, brightblue) %Right horizontal tonfa
drawfillbox (maxx - 135, 80, maxx - 120, 135, brightblue) %Right vertical tonfa
drawfillbox (maxx - 178, 77, maxx - 45, 82, black) %Inside right horizontal tonfa
drawfillbox (maxx - 130, 83, maxx - 125, 130, black) %Inside right vertical tonfa

%-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

%Drawing dots that pacman eat

%Dots
%Starting from the bottom, up

%Row 1
drawfilloval (25, 55, p, p, white)
drawfilloval (41, 55, p, p, white)
drawfilloval (57, 55, p, p, white)
drawfilloval (73, 55, p, p, white)
drawfilloval (89, 55, p, p, white)
drawfilloval (105, 55, p, p, white)
drawfilloval (121, 55, p, p, white)
drawfilloval (137, 55, p, p, white)
drawfilloval (153, 55, p, p, white)
drawfilloval (169, 55, p, p, white)
drawfilloval (185, 55, p, p, white)
drawfilloval (201, 55, p, p, white)
drawfilloval (217, 55, p, p, white)
drawfilloval (233, 55, p, p, white)
drawfilloval (249, 55, p, p, white)
drawfilloval (265, 55, p, p, white)
drawfilloval (281, 55, p, p, white)
drawfilloval (297, 55, p, p, white)
drawfilloval (313, 55, p, p, white)
drawfilloval (329, 55, p, p, white)
drawfilloval (345, 55, p, p, white)
drawfilloval (361, 55, p, p, white)
drawfilloval (377, 55, p, p, white)
drawfilloval (393, 55, p, p, white)
drawfilloval (409, 55, p, p, white)
drawfilloval (425, 55, p, p, white)

%Row 2
drawfilloval (25, 71, p, p, white)
drawfilloval (201, 71, p, p, white)
drawfilloval (249, 71, p, p, white)
drawfilloval (425, 71, p, p, white)

%Row 3
drawfilloval (25, 87, p, p, white)
drawfilloval (201, 87, p, p, white)
drawfilloval (249, 87, p, p, white)
drawfilloval (425, 87, p, p, white)

%Row 4
drawfilloval (25, 103, p, p, white)
drawfilloval (41, 103, p, p, white)
drawfilloval (57, 103, p, p, white)
drawfilloval (73, 103, p, p, white)
drawfilloval (89, 103, p, p, white)
drawfilloval (105, 103, p, p, white)
drawfilloval (153, 103, p, p, white)
drawfilloval (169, 103, p, p, white)
drawfilloval (185, 103, p, p, white)
drawfilloval (201, 103, p, p, white)
drawfilloval (249, 103, p, p, white)
drawfilloval (265, 103, p, p, white)
drawfilloval (281, 103, p, p, white)
drawfilloval (297, 103, p, p, white)
drawfilloval (345, 103, p, p, white)
drawfilloval (361, 103, p, p, white)
drawfilloval (377, 103, p, p, white)
drawfilloval (393, 103, p, p, white)
drawfilloval (409, 103, p, p, white)
drawfilloval (425, 103, p, p, white)

%Row 5
drawfilloval (57, 119, p, p, white)
drawfilloval (105, 119, p, p, white)
drawfilloval (153, 119, p, p, white)
drawfilloval (297, 119, p, p, white)
drawfilloval (345, 119, p, p, white)
drawfilloval (393, 119, p, p, white)

%Row 5
drawfilloval (57, 135, p, p, white)
drawfilloval (105, 135, p, p, white)
drawfilloval (153, 135, p, p, white)
drawfilloval (297, 135, p, p, white)
drawfilloval (345, 135, p, p, white)
drawfilloval (393, 135, p, p, white)

%Row 6
drawfilloval (25, 151, p, p, white)
drawfilloval (41, 151, p, p, white)
drawfilloval (57, 151, p, p, white)
drawfilloval (105, 151, p, p, white)
drawfilloval (121, 151, p, p, white)
drawfilloval (137, 151, p, p, white)
drawfilloval (153, 151, p, p, white)
drawfilloval (169, 151, p, p, white)
drawfilloval (185, 151, p, p, white)
drawfilloval (201, 151, p, p, white)
drawfilloval (217, 151, p, p, white)
drawfilloval (233, 151, p, p, white)
drawfilloval (249, 151, p, p, white)
drawfilloval (265, 151, p, p, white)
drawfilloval (281, 151, p, p, white)
drawfilloval (297, 151, p, p, white)
drawfilloval (313, 151, p, p, white)
drawfilloval (329, 151, p, p, white)
drawfilloval (345, 151, p, p, white)
drawfilloval (393, 151, p, p, white)
drawfilloval (409, 151, p, p, white)
drawfilloval (425, 151, p, p, white)

%Row 7
drawfilloval (25, 167, p, p, white)
drawfilloval (105, 167, p, p, white)
drawfilloval (201, 167, p, p, white)
drawfilloval (249, 167, p, p, white)
drawfilloval (345, 167, p, p, white)
drawfilloval (425, 167, p, p, white)

%Row 8
drawfilloval (25, 183, p, p, white)
drawfilloval (105, 183, p, p, white)
drawfilloval (201, 183, p, p, white)
drawfilloval (249, 183, p, p, white)
drawfilloval (345, 183, p, p, white)
drawfilloval (425, 183, p, p, white)

%Row 9
drawfilloval (25, 199, p, p, white)
drawfilloval (41, 199, p, p, white)
drawfilloval (57, 199, p, p, white)
drawfilloval (73, 199, p, p, white)
drawfilloval (89, 199, p, p, white)
drawfilloval (105, 199, p, p, white)
drawfilloval (121, 199, p, p, white)
drawfilloval (137, 199, p, p, white)
drawfilloval (153, 199, p, p, white)
drawfilloval (169, 199, p, p, white)
drawfilloval (185, 199, p, p, white)
drawfilloval (201, 199, p, p, white)
drawfilloval (249, 199, p, p, white)
drawfilloval (265, 199, p, p, white)
drawfilloval (281, 199, p, p, white)
drawfilloval (297, 199, p, p, white)
drawfilloval (313, 199, p, p, white)
drawfilloval (329, 199, p, p, white)
drawfilloval (345, 199, p, p, white)
drawfilloval (361, 199, p, p, white)
drawfilloval (377, 199, p, p, white)
drawfilloval (393, 199, p, p, white)
drawfilloval (409, 199, p, p, white)
drawfilloval (425, 199, p, p, white)

%Row 10
drawfilloval (105, 215, p, p, white)
drawfilloval (153, 215, p, p, white)
drawfilloval (297, 215, p, p, white)
drawfilloval (345, 215, p, p, white)

%Row 11
drawfilloval (105, 231, p, p, white)
drawfilloval (153, 231, p, p, white)
drawfilloval (297, 231, p, p, white)
drawfilloval (345, 231, p, p, white)

%Row 12
drawfilloval (105, 247, p, p, white)
drawfilloval (153, 247, p, p, white)
drawfilloval (169, 247, p, p, white)
drawfilloval (185, 247, p, p, white)
drawfilloval (201, 247, p, p, white)
drawfilloval (217, 247, p, p, white)
drawfilloval (233, 247, p, p, white)
drawfilloval (249, 247, p, p, white)
drawfilloval (265, 247, p, p, white)
drawfilloval (281, 247, p, p, white)
drawfilloval (297, 247, p, p, white)
drawfilloval (345, 247, p, p, white)

%Row 13
drawfilloval (105, 263, p, p, white)
drawfilloval (153, 263, p, p, white)
drawfilloval (297, 263, p, p, white)
drawfilloval (345, 263, p, p, white)

%Row 14
drawfilloval (105, 279, p, p, white)
drawfilloval (153, 279, p, p, white)
drawfilloval (297, 279, p, p, white)
drawfilloval (345, 279, p, p, white)

%Row 15
drawfilloval (105, 295, p, p, white)
drawfilloval (121, 295, p, p, white)
drawfilloval (137, 295, p, p, white)
drawfilloval (153, 295, p, p, white)
drawfilloval (297, 295, p, p, white)
drawfilloval (313, 295, p, p, white)
drawfilloval (329, 295, p, p, white)
drawfilloval (345, 295, p, p, white)

%Row 16
drawfilloval (105, 311, p, p, white)
drawfilloval (153, 311, p, p, white)
drawfilloval (297, 311, p, p, white)
drawfilloval (345, 311, p, p, white)

%Row 17
drawfilloval (105, 327, p, p, white)
drawfilloval (153, 327, p, p, white)
drawfilloval (297, 327, p, p, white)
drawfilloval (345, 327, p, p, white)

%Row 18
drawfilloval (105, 343, p, p, white)
drawfilloval (153, 343, p, p, white)
drawfilloval (169, 343, p, p, white)
drawfilloval (185, 343, p, p, white)
drawfilloval (201, 343, p, p, white)
drawfilloval (217, 343, p, p, white)
drawfilloval (233, 343, p, p, white)
drawfilloval (249, 343, p, p, white)
drawfilloval (265, 343, p, p, white)
drawfilloval (281, 343, p, p, white)
drawfilloval (297, 343, p, p, white)
drawfilloval (345, 343, p, p, white)

%Row 19
drawfilloval (105, 359, p, p, white)
drawfilloval (201, 359, p, p, white)
drawfilloval (249, 359, p, p, white)
drawfilloval (345, 359, p, p, white)

%Row 20
drawfilloval (105, 375, p, p, white)
drawfilloval (201, 375, p, p, white)
drawfilloval (249, 375, p, p, white)
drawfilloval (345, 375, p, p, white)

%Row 21
drawfilloval (25, 391, p, p, white)
drawfilloval (41, 391, p, p, white)
drawfilloval (57, 391, p, p, white)
drawfilloval (73, 391, p, p, white)
drawfilloval (89, 391, p, p, white)
drawfilloval (105, 391, p, p, white)
drawfilloval (153, 391, p, p, white)
drawfilloval (169, 391, p, p, white)
drawfilloval (185, 391, p, p, white)
drawfilloval (201, 391, p, p, white)
drawfilloval (249, 391, p, p, white)
drawfilloval (265, 391, p, p, white)
drawfilloval (281, 391, p, p, white)
drawfilloval (297, 391, p, p, white)
drawfilloval (345, 391, p, p, white)
drawfilloval (361, 391, p, p, white)
drawfilloval (377, 391, p, p, white)
drawfilloval (393, 391, p, p, white)
drawfilloval (409, 391, p, p, white)
drawfilloval (425, 391, p, p, white)

%Row 22
drawfilloval (25, 407, p, p, white)
drawfilloval (105, 407, p, p, white)
drawfilloval (153, 407, p, p, white)
drawfilloval (297, 407, p, p, white)
drawfilloval (345, 407, p, p, white)
drawfilloval (425, 407, p, p, white)

%Row 23
drawfilloval (25, 423, p, p, white)
drawfilloval (105, 423, p, p, white)
drawfilloval (153, 423, p, p, white)
drawfilloval (297, 423, p, p, white)
drawfilloval (345, 423, p, p, white)
drawfilloval (425, 423, p, p, white)

%Row 24
drawfilloval (25, 439, p, p, white)
drawfilloval (41, 439, p, p, white)
drawfilloval (57, 439, p, p, white)
drawfilloval (73, 439, p, p, white)
drawfilloval (89, 439, p, p, white)
drawfilloval (105, 439, p, p, white)
drawfilloval (121, 439, p, p, white)
drawfilloval (137, 439, p, p, white)
drawfilloval (153, 439, p, p, white)
drawfilloval (169, 439, p, p, white)
drawfilloval (185, 439, p, p, white)
drawfilloval (201, 439, p, p, white)
drawfilloval (217, 439, p, p, white)
drawfilloval (233, 439, p, p, white)
drawfilloval (249, 439, p, p, white)
drawfilloval (265, 439, p, p, white)
drawfilloval (281, 439, p, p, white)
drawfilloval (297, 439, p, p, white)
drawfilloval (313, 439, p, p, white)
drawfilloval (329, 439, p, p, white)
drawfilloval (345, 439, p, p, white)
drawfilloval (361, 439, p, p, white)
drawfilloval (377, 439, p, p, white)
drawfilloval (393, 439, p, p, white)
drawfilloval (409, 439, p, p, white)
drawfilloval (425, 439, p, p, white)

%Row 25
drawfilloval (25, 455, p, p, white)
drawfilloval (105, 455, p, p, white)
drawfilloval (201, 455, p, p, white)
drawfilloval (249, 455, p, p, white)
drawfilloval (345, 455, p, p, white)
drawfilloval (425, 455, p, p, white)

%Row 26
drawfilloval (25, 471, p, p, white)
drawfilloval (105, 471, p, p, white)
drawfilloval (201, 471, p, p, white)
drawfilloval (249, 471, p, p, white)
drawfilloval (345, 471, p, p, white)
drawfilloval (425, 471, p, p, white)

%Row 27
drawfilloval (25, 487, p, p, white)
drawfilloval (105, 487, p, p, white)
drawfilloval (201, 487, p, p, white)
drawfilloval (249, 487, p, p, white)
drawfilloval (345, 487, p, p, white)
drawfilloval (425, 487, p, p, white)

%Row 28
drawfilloval (25, 503, p, p, white)
drawfilloval (41, 503, p, p, white)
drawfilloval (57, 503, p, p, white)
drawfilloval (73, 503, p, p, white)
drawfilloval (89, 503, p, p, white)
drawfilloval (105, 503, p, p, white)
drawfilloval (121, 503, p, p, white)
drawfilloval (137, 503, p, p, white)
drawfilloval (153, 503, p, p, white)
drawfilloval (169, 503, p, p, white)
drawfilloval (185, 503, p, p, white)
drawfilloval (201, 503, p, p, white)
drawfilloval (249, 503, p, p, white)
drawfilloval (265, 503, p, p, white)
drawfilloval (281, 503, p, p, white)
drawfilloval (297, 503, p, p, white)
drawfilloval (313, 503, p, p, white)
drawfilloval (329, 503, p, p, white)
drawfilloval (345, 503, p, p, white)
drawfilloval (361, 503, p, p, white)
drawfilloval (377, 503, p, p, white)
drawfilloval (393, 503, p, p, white)
drawfilloval (409, 503, p, p, white)
drawfilloval (425, 503, p, p, white)


%-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

%Pacman himself!
%Drawing him and if statements

Input.KeyDown (chars)
if chars (KEY_RIGHT_ARROW) then

if whatdotcolor (x + r, y) = white or whatdotcolor (x + r, y + r) = white or whatdotcolor (x + r, y - r) = white then
drawfilloval (x - 2*r, y, r, r, black)
end if


if pacstate = true then %Mouth Closed

drawfilloval (x, y, r, r, yellow) %Draws pacman's body
x := x + 5 %Drives him towards the right
pacstate := false %Changes to open his mouth

if whatdotcolor (x + r, y) = brightblue or whatdotcolor (x + r, y + r) = brightblue or whatdotcolor (x + r, y - r) = brightblue then %When it hits something brightblue...
x := x - 5 %As a loop, it will then back it up, thus nullfying the movement of pacman
end if %A.K.A. Collision Detection



else %When mouth is open

drawfilloval (x, y, r, r, yellow) %Draws pacmans' body
drawfillarc (x, y, r, r, 310, 40, black) %Pacmans' mouth
x := x + 5 %Changes to open his mouth
pacstate := true %Changes to close his mouth

if whatdotcolor (x + r, y) = brightblue or whatdotcolor (x + r, y + r) = brightblue or whatdotcolor (x + r, y - r) = brightblue then
%Radius of pacman hits something brightblue...
x := x - 5 %Backs it up, thus nullifying the movement of pacman
end if

end if

elsif chars (KEY_LEFT_ARROW) then

if pacstate = true then
drawfilloval (x, y, r, r, yellow)
x := x - 5
pacstate := false

if whatdotcolor (x - r, y) = brightblue or whatdotcolor (x - r, y + r) = brightblue or whatdotcolor (x - r, y - r) = brightblue then
x := x + 5
end if

else

drawfilloval (x, y, r, r, yellow)
drawfillarc (x, y, r, r, 130, 210, black)
x := x - 5
pacstate := true

if whatdotcolor (x - r, y) = brightblue or whatdotcolor (x - r, y + r) = brightblue or whatdotcolor (x - r, y - r) = brightblue then
x := x + 5
end if

end if

elsif chars (KEY_DOWN_ARROW) then

if pacstate = true then
drawfilloval (x, y, r, r, yellow)
y := y - 5
pacstate := false

if whatdotcolor (x, y - r) = brightblue or whatdotcolor (x + r, y - r) = brightblue or whatdotcolor (x - r, y - r) = brightblue then
y := y + 5
end if

else

drawfilloval (x, y, r, r, yellow)
drawfillarc (x, y, r, r, 230, 310, black)
y := y - 5
pacstate := true

if whatdotcolor (x, y - r) = brightblue or whatdotcolor (x + r, y - r) = brightblue or whatdotcolor (x - r, y - r) = brightblue then
y := y + 5
end if

end if

elsif chars (KEY_UP_ARROW) then

if pacstate = true then

drawfilloval (x, y, r, r, yellow)
y := y + 5
pacstate := false

if whatdotcolor (x, y + r) = brightblue or whatdotcolor (x - r, y + r) = brightblue or whatdotcolor (x + r, y + r) = brightblue then
y := y - 5
end if

else

drawfilloval (x, y, r, r, yellow)
drawfillarc (x, y, r, r, 70, 120, black)
y := y + 5
pacstate := true

if whatdotcolor (x, y + r) = brightblue or whatdotcolor (x - r, y + r) = brightblue or whatdotcolor (x + r, y + r) = brightblue then
y := y - 5

end if

end if

else

drawfilloval (x, y, 12, 12, yellow) %Draws Pacman when no keys are pressed

end if

delay (40)
View.UpdateArea (x - 45, y - 45, x + 45, y + 45) %Updates pacman's area to reduce lag

end loop

end Classic

%Starting Screen Options

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
end if
end loop
Jynx101




PostPosted: Sun May 28, 2017 12:29 pm   Post subject: RE:Help for Pacman eating dots. Have no idea to do it.

Just at the input.keydown part, is the whatdotcolor
Insectoid




PostPosted: Sun May 28, 2017 1:53 pm   Post subject: RE:Help for Pacman eating dots. Have no idea to do it.

You are detecting collisions? with dots when Pacman's forward edge hits the rear edge of the dot. They are not in the same spot, they're only close to each other. Your eraser dot is being drawn where pacman is, not where the dot is.

This method will work, however it will take at least as much effort to get right as the array method, and the only thing you'll learn is how awful this method is. I strongly recommend you go back to arrays, because you will use that method for the rest of your programming career and the lessons you will learn from it are actually useful.

Where did you run into trouble with the array method?
Jynx101




PostPosted: Sun May 28, 2017 2:58 pm   Post subject: RE:Help for Pacman eating dots. Have no idea to do it.

Okay, so first things first:

1. How to use arrays to draw dots, at specific places?

2. Boolean statements, if true, draw dot. If false, then don't. I get that, but again, can't do it without the array.

3. I somewhat get how arrays work, seeing as i read tutorials, but not enough so that i can get this far. If i had an example of a circle "eating" dots, that would be great.
Insectoid




PostPosted: Sun May 28, 2017 6:14 pm   Post subject: RE:Help for Pacman eating dots. Have no idea to do it.

First things first, every dot gets an x and y coordinate. You already have that in your hundreds of draw commands. Let's make two arrays, one for each x, and one for each y:

Var dotX : array 0..100 of int
var dotY : array 0..100 of int

This will give you enough coordinates for 100 dots. Replace 100 with however many dots you have. Fill the array with your coordinates:

dotX (0) := 15
DotY (0) := 15

This creates a dot at (15, 15). Replace those numbers with appropriate coordinates, and repeat for every dot. There's a better way to do this, but for now we'll do it the long tedious way.

Once you've created coordinates for every dot, we can use a loop to draw them:

for i : 0..100
Draw.FillOval (dotX (i), dotY (I), 10, 10, yellow)
End for

Those three lines of code will draw every dot. But we only want to draw dots that haven't been eaten yet, so we'll create another array of boolean to store whether to draw or not:

var dotsEaten : array 0..100 of boolean

And since all of them start out not eaten, we can set everything to false right away:

for i : 0..100
dotsEaten (i) := false
end for

Now inside the draw loop, we'll add an if statement:

if dotsEaten (i) == false then
draw.filloval (dotsX (I), dotsY (i), etc)
end if

Now you only need to figure out how to detect if a dot was eaten, and set that dot to true in the eaten array. It will then no longer be drawn.
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 3  [ 37 Posts ]
Goto page 1, 2, 3  Next
Jump to:   


Style:  
Search: