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 Previous  1, 2, 3
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Jynx101




PostPosted: 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?
Sponsor
Sponsor
Sponsor
sponsor
Jynx101




PostPosted: 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
Insectoid




PostPosted: 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.
Jynx101




PostPosted: 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.
Jynx101




PostPosted: 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
Insectoid




PostPosted: 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.
Jynx101




PostPosted: 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.
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 3 of 3  [ 37 Posts ]
Goto page Previous  1, 2, 3
Jump to:   


Style:  
Search: