Log In  


Cart #hazikigage-0 | 2024-06-25 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA


...
the "ghosts" have a offset error
i don't know how to fix



1st, your ghosts do not start in the corridors. This is easily fixable.
Just to be sure, at least one of the X and Y coordinates should be a multiple of 8 at all times. use assert so you can crash the game as soon as something goes wrong before cumulative iterations over invalid values muddle things up.

2nd, your code assumes that your ghosts are in a tile and have four neighboring tiles. That's just not the case : when they are dead center inside a tile (x%8==0 and y%8==0), then you have four neighbors, but otherwise, the ghosts are covering parts of two tiles, you have 6 or 8 neighbor tiles depending on what you count.
The question is if your ghosts have the ability to turn around during chase phase (they don't in the original arcade).
If not, the "AI" is super simple when over multiple tiles, just go forward.
the original arcade what pushing this even further : if not at a crossroad, go onwards (potentially turning at corners).


@RealShadowCaster the ghost can't turn around, the code makes a check to see if the possible tile is not the reverse of the current direction and then don't add as a possible move to the tile array.



[Please log in to post a comment]