Need help with AI for pacman
Author |
Message |
maxxxpain
|
Posted: Sun Jan 14, 2007 11:12 am Post subject: Need help with AI for pacman |
|
|
sorry that i used "need help" but i just seriously needed help. I'm a stoner and i lack in logic, i just didnt no who to turn to for help and ISP is due in 3 days. All i need help with is to make the pacman follow me and thats all. Sorry that i posted an "i need help" post.
|
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
[Gandalf]
![](http://compsci.ca/v3/uploads/user_avatars/189297994e4c716fec7f1.png)
|
Posted: Sun Jan 14, 2007 12:37 pm Post subject: RE:Need help with AI for pacman |
|
|
Why don't you attach the code you already have?
Basically what you'll need to do is check your position (the mouse? or what?) against the position of pacman. For example if the mouse is higher than pacman, you'll have to make him move up, as long as nothing is blocking the path in between.
|
|
|
|
|
![](images/spacer.gif) |
maxxxpain
|
Posted: Sun Jan 14, 2007 1:27 pm Post subject: Re: Need help with AI for pacman |
|
|
this is my game so far
Description: |
|
![](http://compsci.ca/v3/pafiledb/images/icons/clip.gif) Download |
Filename: |
PacDisplay.t |
Filesize: |
11.78 KB |
Downloaded: |
98 Time(s) |
|
|
|
|
|
![](images/spacer.gif) |
CodeMonkey2000
|
Posted: Sun Jan 14, 2007 2:13 pm Post subject: Re: Need help with AI for pacman |
|
|
Your enemy procedure should be something like this:
code: |
procedure enemy
if my x > enemy x and whatdotcolor (enemy x + 5, enemy y) not= green then
enemy x += 5
end if
if my x < x2 and whatdotcolor (enemy x - 5, enemy y) not= green then
enemy x-= 5
end if
if my y > enemy y and whatdotcolor enemy x, enemy y+ 5) not= green then
enemy y += 5
end if
if my y < enemy y and whatdotcolor (enemy x,enemy x- 5) not= green then
enemy y -= 5
end if
drawfilloval (x2, y2, 15, 15, 1)
end enemy
|
also whatdotcolour isn't the best solution to this problem. It is now imposible to do a cirular collision now.
|
|
|
|
|
![](images/spacer.gif) |
Nova
|
Posted: Mon Jan 15, 2007 1:55 pm Post subject: Re: Need help with AI for pacman |
|
|
The ghosts in Pacman follow a pre planned path until it comes into proximity with the player
So you should have them going a pattern and if the you come into a short enough distance from them they chase you and leave their path
|
|
|
|
|
![](images/spacer.gif) |
|
|