Computer Science Canada Help for Pacman eating dots. Have no idea to do it. |
Author: | Jynx101 [ 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>
Please specify what version of Turing you are using <Answer Here> 4.1.1 |
Author: | Insectoid [ 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. |
Author: | The one they call Greed [ 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. |
Author: | Insectoid [ 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. |
Author: | The one they call Greed [ 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? |
Author: | Insectoid [ 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? |
Author: | Jynx101 [ 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 |
Author: | Jynx101 [ 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? |
Author: | Insectoid [ 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. |
Author: | The one they call Greed [ 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. |
Author: | Jynx101 [ 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 |
Author: | Jynx101 [ 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 |
Author: | Insectoid [ 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? |
Author: | Jynx101 [ 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. |
Author: | Insectoid [ 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. |
Author: | Jynx101 [ Sun May 28, 2017 10:34 pm ] |
Post subject: | RE:Help for Pacman eating dots. Have no idea to do it. |
It's telling me that the variable has no value on the for loop: %Drawing dots that pacman eat var dotx : array 1 .. 290 of int var doty : array 1 .. 290 of int %X-Coordinates dotx (1) := 25 dotx (2) := 41 dotx (3) := 57 dotx (4) := 73 dotx (5) := 89 dotx (6) := 105 dotx (7) := 121 dotx (8) := 137 dotx (9) := 153 dotx (10) := 169 dotx (11) := 185 dotx (12) := 201 dotx (13) := 217 dotx (14) := 233 dotx (15) := 249 dotx (16) := 265 dotx (17) := 281 dotx (18) := 297 dotx (19) := 313 dotx (20) := 329 dotx (21) := 345 dotx (22) := 361 dotx (23) := 377 dotx (24) := 393 dotx (25) := 409 dotx (26) := 425 dotx (27) := 25 dotx (28) := 201 dotx (29) := 249 dotx (30) := 425 dotx (31) := 25 dotx (32) := 201 dotx (33) := 249 dotx (34) := 425 dotx (35) := 25 dotx (36) := 41 dotx (37) := 57 dotx (38) := 73 dotx (39) := 89 dotx (40) := 105 dotx (41) := 153 dotx (42) := 169 dotx (43) := 185 dotx (44) := 201 dotx (45) := 249 dotx (46) := 265 dotx (47) := 281 dotx (48) := 297 dotx (49) := 345 dotx (50) := 361 dotx (51) := 377 dotx (52) := 393 dotx (53) := 409 dotx (54) := 425 dotx (55) := 57 dotx (56) := 105 dotx (57) := 153 dotx (58) := 297 dotx (59) := 345 dotx (60) := 393 dotx (61) := 57 dotx (62) := 105 dotx (63) := 153 dotx (64) := 297 dotx (65) := 345 dotx (66) := 393 dotx (67) := 25 dotx (68) := 41 dotx (69) := 57 dotx (70) := 105 dotx (71) := 121 dotx (72) := 137 dotx (73) := 153 dotx (74) := 169 dotx (75) := 185 dotx (76) := 201 dotx (77) := 217 dotx (78) := 233 dotx (79) := 249 dotx (80) := 265 dotx (81) := 281 dotx (82) := 297 dotx (83) := 313 dotx (84) := 329 dotx (85) := 345 dotx (86) := 393 dotx (87) := 409 dotx (88) := 425 dotx (89) := 25 dotx (90) := 105 dotx (91) := 201 dotx (92) := 249 dotx (93) := 345 dotx (94) := 425 dotx (95) := 25 dotx (96) := 105 dotx (97) := 201 dotx (98) := 249 dotx (99) := 345 dotx (100) := 425 dotx (101) := 25 dotx (102) := 41 dotx (103) := 57 dotx (104) := 73 dotx (105) := 89 dotx (106) := 105 dotx (107) := 121 dotx (108) := 137 dotx (109) := 153 dotx (110) := 169 dotx (111) := 185 dotx (112) := 201 dotx (113) := 249 dotx (114) := 265 dotx (115) := 281 dotx (116) := 297 dotx (117) := 313 dotx (118) := 329 dotx (119) := 345 dotx (120) := 361 dotx (121) := 377 dotx (122) := 393 dotx (123) := 409 dotx (124) := 425 dotx (125) := 105 dotx (126) := 153 dotx (127) := 297 dotx (128) := 345 dotx (129) := 105 dotx (130) := 153 dotx (131) := 297 dotx (132) := 345 dotx (133) := 105 dotx (134) := 153 dotx (135) := 169 dotx (136) := 185 dotx (137) := 201 dotx (138) := 217 dotx (139) := 233 dotx (140) := 249 dotx (141) := 265 dotx (142) := 281 dotx (143) := 297 dotx (144) := 345 dotx (145) := 105 dotx (146) := 153 dotx (147) := 297 dotx (148) := 345 dotx (149) := 105 dotx (150) := 153 dotx (151) := 297 dotx (152) := 345 dotx (153) := 105 dotx (154) := 121 dotx (155) := 137 dotx (156) := 153 dotx (157) := 297 dotx (158) := 313 dotx (159) := 329 dotx (160) := 345 dotx (161) := 105 dotx (162) := 153 dotx (163) := 297 dotx (164) := 345 dotx (165) := 105 dotx (166) := 153 dotx (167) := 297 dotx (168) := 345 dotx (169) := 105 dotx (170) := 153 dotx (171) := 169 dotx (172) := 185 dotx (173) := 201 dotx (174) := 217 dotx (175) := 233 dotx (176) := 249 dotx (177) := 265 dotx (178) := 281 dotx (179) := 297 dotx (180) := 345 dotx (181) := 105 dotx (182) := 201 dotx (183) := 249 dotx (184) := 345 dotx (185) := 105 dotx (186) := 201 dotx (187) := 249 dotx (188) := 345 dotx (189) := 25 dotx (190) := 41 dotx (191) := 57 dotx (192) := 73 dotx (193) := 89 dotx (194) := 105 dotx (195) := 153 dotx (196) := 169 dotx (197) := 185 dotx (198) := 201 dotx (199) := 249 dotx (201) := 265 dotx (202) := 281 dotx (203) := 297 dotx (204) := 345 dotx (205) := 361 dotx (206) := 377 dotx (207) := 393 dotx (208) := 409 dotx (209) := 435 dotx (211) := 25 dotx (212) := 105 dotx (213) := 153 dotx (214) := 297 dotx (215) := 345 dotx (216) := 425 dotx (217) := 25 dotx (218) := 105 dotx (219) := 153 dotx (220) := 297 dotx (221) := 345 dotx (222) := 435 dotx (223) := 25 dotx (224) := 41 dotx (225) := 57 dotx (226) := 73 dotx (227) := 89 dotx (228) := 105 dotx (229) := 121 dotx (230) := 137 dotx (231) := 153 dotx (232) := 169 dotx (233) := 185 dotx (234) := 201 dotx (235) := 217 dotx (236) := 233 dotx (237) := 249 dotx (238) := 265 dotx (239) := 281 dotx (240) := 297 dotx (241) := 313 dotx (242) := 329 dotx (243) := 345 dotx (244) := 361 dotx (245) := 377 dotx (246) := 393 dotx (247) := 409 dotx (248) := 425 dotx (249) := 25 dotx (250) := 105 dotx (251) := 201 dotx (252) := 249 dotx (253) := 345 dotx (254) := 425 dotx (255) := 25 dotx (256) := 105 dotx (257) := 201 dotx (258) := 249 dotx (259) := 345 dotx (260) := 425 dotx (261) := 25 dotx (262) := 105 dotx (263) := 201 dotx (264) := 249 dotx (265) := 345 dotx (266) := 425 dotx (267) := 25 dotx (268) := 41 dotx (269) := 57 dotx (270) := 73 dotx (271) := 89 dotx (272) := 105 dotx (273) := 121 dotx (274) := 137 dotx (275) := 153 dotx (276) := 169 dotx (277) := 185 dotx (278) := 201 dotx (279) := 249 dotx (280) := 265 dotx (281) := 281 dotx (282) := 297 dotx (283) := 313 dotx (284) := 329 dotx (285) := 234 dotx (286) := 361 dotx (287) := 377 dotx (288) := 393 dotx (289) := 409 dotx (290) := 425 %Y-Coordinates doty (1) := 55 doty (2) := 55 doty (3) := 55 doty (4) := 55 doty (5) := 55 doty (6) := 55 doty (7) := 55 doty (8) := 55 doty (9) := 55 doty (10) := 55 doty (11) := 55 doty (12) := 55 doty (13) := 55 doty (14) := 55 doty (15) := 55 doty (16) := 55 doty (17) := 55 doty (18) := 55 doty (19) := 55 doty (20) := 55 doty (21) := 55 doty (22) := 55 doty (23) := 55 doty (24) := 55 doty (25) := 55 doty (26) := 55 doty (27) := 71 doty (28) := 71 doty (29) := 71 doty (30) := 71 doty (31) := 87 doty (32) := 87 doty (33) := 87 doty (34) := 87 doty (35) := 103 doty (36) := 103 doty (37) := 103 doty (38) := 103 doty (39) := 103 doty (40) := 103 doty (41) := 103 doty (42) := 103 doty (43) := 103 doty (44) := 103 doty (45) := 103 doty (46) := 103 doty (47) := 103 doty (48) := 103 doty (49) := 103 doty (50) := 103 doty (51) := 103 doty (52) := 103 doty (53) := 103 doty (54) := 103 doty (55) := 119 doty (56) := 119 doty (57) := 119 doty (58) := 119 doty (59) := 119 doty (60) := 119 doty (61) := 135 doty (62) := 135 doty (63) := 135 doty (64) := 135 doty (65) := 135 doty (66) := 135 doty (67) := 151 doty (68) := 151 doty (69) := 151 doty (70) := 151 doty (71) := 151 doty (72) := 151 doty (73) := 151 doty (74) := 151 doty (75) := 151 doty (76) := 151 doty (77) := 151 doty (78) := 151 doty (79) := 151 doty (80) := 151 doty (81) := 151 doty (82) := 151 doty (83) := 151 doty (84) := 151 doty (85) := 151 doty (86) := 151 doty (87) := 151 doty (88) := 151 doty (89) := 167 doty (90) := 167 doty (91) := 167 doty (92) := 167 doty (93) := 167 doty (94) := 167 doty (95) := 183 doty (96) := 183 doty (97) := 183 doty (98) := 183 doty (99) := 183 doty (100) := 183 doty (101) := 199 doty (102) := 199 doty (103) := 199 doty (104) := 199 doty (105) := 199 doty (106) := 199 doty (107) := 199 doty (108) := 199 doty (109) := 199 doty (110) := 199 doty (111) := 199 doty (112) := 199 doty (113) := 199 doty (114) := 199 doty (115) := 199 doty (116) := 199 doty (117) := 199 doty (118) := 199 doty (119) := 199 doty (120) := 199 doty (121) := 199 doty (122) := 199 doty (123) := 199 doty (124) := 199 doty (125) := 215 doty (126) := 215 doty (127) := 215 doty (128) := 215 doty (129) := 231 doty (130) := 231 doty (131) := 231 doty (132) := 231 doty (133) := 247 doty (134) := 247 doty (135) := 247 doty (136) := 247 doty (137) := 247 doty (138) := 247 doty (139) := 247 doty (140) := 247 doty (141) := 247 doty (142) := 247 doty (143) := 247 doty (144) := 247 doty (145) := 263 doty (146) := 263 doty (147) := 263 doty (148) := 263 doty (149) := 279 doty (150) := 279 doty (151) := 279 doty (152) := 279 doty (153) := 295 doty (154) := 295 doty (155) := 295 doty (156) := 295 doty (157) := 295 doty (158) := 295 doty (159) := 295 doty (160) := 295 doty (161) := 311 doty (162) := 311 doty (163) := 311 doty (164) := 311 doty (165) := 327 doty (166) := 327 doty (167) := 327 doty (168) := 327 doty (169) := 343 doty (170) := 343 doty (171) := 343 doty (172) := 343 doty (173) := 343 doty (174) := 343 doty (175) := 343 doty (176) := 343 doty (177) := 343 doty (178) := 343 doty (179) := 343 doty (180) := 343 doty (181) := 343 doty (182) := 359 doty (183) := 359 doty (184) := 359 doty (185) := 359 doty (186) := 375 doty (187) := 375 doty (188) := 375 doty (189) := 375 doty (190) := 391 doty (191) := 391 doty (192) := 391 doty (193) := 391 doty (194) := 391 doty (195) := 391 doty (196) := 391 doty (197) := 391 doty (198) := 391 doty (199) := 391 doty (201) := 391 doty (202) := 391 doty (203) := 391 doty (204) := 391 doty (205) := 391 doty (206) := 391 doty (207) := 391 doty (208) := 391 doty (209) := 391 doty (211) := 391 doty (212) := 407 doty (213) := 407 doty (214) := 407 doty (215) := 407 doty (216) := 407 doty (217) := 407 doty (218) := 423 doty (219) := 423 doty (220) := 423 doty (221) := 423 doty (222) := 423 doty (223) := 423 doty (224) := 439 doty (225) := 439 doty (226) := 439 doty (227) := 439 doty (228) := 439 doty (229) := 439 doty (230) := 439 doty (231) := 439 doty (232) := 439 doty (233) := 439 doty (234) := 439 doty (235) := 439 doty (236) := 439 doty (237) := 439 doty (238) := 439 doty (239) := 439 doty (240) := 439 doty (241) := 439 doty (242) := 439 doty (243) := 439 doty (244) := 439 doty (245) := 439 doty (246) := 439 doty (247) := 439 doty (248) := 439 doty (249) := 439 doty (250) := 455 doty (251) := 455 doty (252) := 455 doty (253) := 455 doty (254) := 455 doty (255) := 455 doty (256) := 471 doty (257) := 471 doty (258) := 471 doty (259) := 471 doty (260) := 471 doty (261) := 471 doty (262) := 487 doty (263) := 487 doty (264) := 487 doty (265) := 487 doty (266) := 487 doty (267) := 487 doty (268) := 503 doty (269) := 503 doty (270) := 503 doty (271) := 503 doty (272) := 503 doty (273) := 503 doty (274) := 503 doty (275) := 503 doty (276) := 503 doty (277) := 503 doty (278) := 503 doty (279) := 503 doty (280) := 503 doty (281) := 503 doty (282) := 503 doty (283) := 503 doty (284) := 503 doty (285) := 503 doty (286) := 503 doty (287) := 503 doty (288) := 503 doty (289) := 503 doty (290) := 503 for i : 1 .. 290 drawfilloval (dotx (i), doty (i), 4, 4, white) end for |
Author: | Jynx101 [ Sun May 28, 2017 10:57 pm ] |
Post subject: | RE:Help for Pacman eating dots. Have no idea to do it. |
i forgot to add this. it goes at the bottom: for i : 1 .. 290 drawfilloval (dotx (i), doty (i), 4, 4, white) end for for i : 1 .. 290 DotsEaten (i) := false if DotsEaten (i) = false then drawfilloval (dotx (i), doty (i), 4, 4, white) elsif DotsEaten (i) = true then exit end if end for |
Author: | Insectoid [ Mon May 29, 2017 5:36 am ] |
Post subject: | RE:Help for Pacman eating dots. Have no idea to do it. |
What do you think that error message might be trying to tell you? |
Author: | Jynx101 [ Mon May 29, 2017 8:43 am ] |
Post subject: | RE:Help for Pacman eating dots. Have no idea to do it. |
Yeah, ik that it says variable has no value, but it doesn't say which variable. It usually highlights which variable has no value, but it highlights the whole drawfilloval statement. |
Author: | Insectoid [ Mon May 29, 2017 9:49 am ] |
Post subject: | RE:Help for Pacman eating dots. Have no idea to do it. |
What variables are in the drawfilloval statement? |
Author: | Jynx101 [ Mon May 29, 2017 10:24 am ] |
Post subject: | RE:Help for Pacman eating dots. Have no idea to do it. |
dotx, doty, and i |
Author: | Insectoid [ Mon May 29, 2017 10:45 am ] |
Post subject: | RE:Help for Pacman eating dots. Have no idea to do it. |
No, the variables are dotx (i), doty (i), and i. This includes dotx (0), dotx (10), doty (50), etc. Do you think it's possible that you simply forgot to initialize one of your dotx or doty variables? Maybe there's a typo and you typed dotx (17) instead of (18)? |
Author: | Jynx101 [ Mon May 29, 2017 11:44 am ] |
Post subject: | RE:Help for Pacman eating dots. Have no idea to do it. |
Yeah, you're right. I didn't do several of my dots properly. Thanks. |
Author: | Jynx101 [ Mon May 29, 2017 11:47 am ] |
Post subject: | Re: RE:Help for Pacman eating dots. Have no idea to do it. |
Insectoid @ Sun May 28, 2017 6:14 pm wrote: 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. |
Author: | Jynx101 [ Mon May 29, 2017 11:48 am ] |
Post subject: | RE:Help for Pacman eating dots. Have no idea to do it. |
Btw, when you said to do the if statement, in english this says that is none of the dots are eaten, to draw all of them, right? |
Author: | Insectoid [ Mon May 29, 2017 12:12 pm ] |
Post subject: | RE:Help for Pacman eating dots. Have no idea to do it. |
That if statement goes inside a loop. It looks at each dot, asks 'has this been eaten yet?' and then draws or doesn't, depending on the answer. |
Author: | Jynx101 [ Tue May 30, 2017 8:33 am ] |
Post subject: | RE:Help for Pacman eating dots. Have no idea to do it. |
So i did it using collision detection, but it isn't working... for i : 1 .. 288 drawfilloval (dotx (i), doty (i), 2, 2, white) DotsEaten (i) := false if DotsEaten (i) = false then drawfilloval (dotx (i), doty (i), 2, 2, white) elsif DotsEaten (i) = true then drawfilloval (dotx (i), doty (i), 3, 3, black) end if if whatdotcolor (x + r, y) = white or whatdotcolor (x + r, y + r) = white or whatdotcolor (x + r, y - r) = white then DotsEaten (i) := true end if end for |
Author: | Insectoid [ Tue May 30, 2017 2:43 pm ] |
Post subject: | RE:Help for Pacman eating dots. Have no idea to do it. |
You've got all the pieces, but they're all in the wrong spots. Tell me, does this make sense? DotsEaten (i) := false if DotsEaten (i) = false then Think about that for a minute- what exactly is happening here? You need to break that big loop up into several smaller loops. |
Author: | Jynx101 [ Tue May 30, 2017 8:45 pm ] |
Post subject: | RE:Help for Pacman eating dots. Have no idea to do it. |
oh right...i'm stupid...its already set at false drawing all the dots |
Author: | The one they call Greed [ Wed May 31, 2017 12:00 pm ] |
Post subject: | RE:Help for Pacman eating dots. Have no idea to do it. |
You are making every dot false every time it is scanned. Move that into a different loop and that should fix everything |
Author: | Jynx101 [ Wed May 31, 2017 11:58 pm ] |
Post subject: | RE:Help for Pacman eating dots. Have no idea to do it. |
So this is how i understand it: for i : 1 .. 288 drawfilloval (dotx (i), doty (i), 2, 2, white) end for for i : 1 .. 288 DotsEaten (i) := false end for for i : 1 .. 288 if DotsEaten (i) = false then drawfilloval (dotx (i), doty (i), 2, 2, white) elsif DotsEaten (i) = true then drawfilloval (dotx (i), doty (i), 2, 2, black) end if if whatdotcolor (x + r, y) = white or whatdotcolor (x + r, y + r) = white or whatdotcolor (x + r, y - r) = white then DotsEaten (i) := true end if end for The first for loop draws the dots The second for loop sets all of them to false The third for loop scans them whether Pacman ate them or not. So how can you get the ones eaten to stay true, and not be overwritten as false again? |
Author: | Jynx101 [ Thu Jun 01, 2017 12:42 am ] |
Post subject: | RE:Help for Pacman eating dots. Have no idea to do it. |
Oh, and i need the dots done by Thursday at 6pm, so it would be really helpful if you guys could help me so i can start the AI |
Author: | Insectoid [ Thu Jun 01, 2017 8:19 am ] |
Post subject: | RE:Help for Pacman eating dots. Have no idea to do it. |
You only set the dots to false once at the beginning of the program. Why are you drawing the dots before checking if you want to draw them? Shouldn't you check first? Erasing the dots is hard. It's far easier to just not draw them the ones that have been eaten in the first place. |
Author: | Jynx101 [ Fri Jun 02, 2017 1:46 pm ] |
Post subject: | RE:Help for Pacman eating dots. Have no idea to do it. |
Mmk. So I did not understand, so i what i though of was i located every single dot with a true\false statement with an if statement: if dottrue (1) = true then drawfilloval (dotx (1), doty (1), 2, 2, white) else end if And to see whether it's been eaten or not, i used Math.Distance with pacman's (x,y) coordinates with each dots coordinates: if Math.Distance (x, y, dotx (1), doty (1)) < 11 then dottrue (1) := false end if Not the way you probably had in mind, and it would have been alot shorter, but i couldn't get to it. |
Author: | Jynx101 [ Fri Jun 02, 2017 1:47 pm ] |
Post subject: | RE:Help for Pacman eating dots. Have no idea to do it. |
However, thanks for helping me |
Author: | Insectoid [ Fri Jun 02, 2017 2:05 pm ] |
Post subject: | RE:Help for Pacman eating dots. Have no idea to do it. |
That is exactly the method I had in mind. I thought it might confuse you to introduce Math.Distance right away, so I let you carry on with whatdotcolor. I'm glad you figured it out though. |
Author: | Jynx101 [ Fri Jun 02, 2017 8:47 pm ] |
Post subject: | RE:Help for Pacman eating dots. Have no idea to do it. |
I just started fiddling around with all the possible types of commands in Turing (which took awhile) until I found Math.Distance. I found that using it would enable me to "detect" each dot if I used a boolean statement and it worked. |