#56515 - biubid_boy - Sun Oct 09, 2005 7:06 am
Hi. I'm using the following code in my pacman clone to make the enemy chase the pacman.
But when I move my pacman to the edge of the screen, then sideways, it appears in the middle of the screen again (like it should when it gets hit) even though none of my statements evaluate true. Can you please help me get to the bottom of this bug,
Biubid_boy.
Code: |
if (xpacman < xenemy) { xenemy--; if (xenemy <= xMin || (xenemy == xpacman + 8 && yenemy == ypacman) || (xenemy == xpacman && yenemy == ypacman + 8) || (xenemy == xpacman - 8 && yenemy == ypacman) || (xenemy == xpacman && yenemy == ypacman - 8)) { xpacman = 120; ypacman = 80; } } if (xpacman > xenemy) { xenemy++; if (xenemy >= xMax || (xenemy == xpacman + 8 && yenemy == ypacman) || (xenemy == xpacman && yenemy == ypacman + 8)|| (xenemy == xpacman - 8 && yenemy == ypacman) || (xenemy == xpacman && yenemy == ypacman - 8)) { xpacman = 120; ypacman = 80; } } if (ypacman < yenemy) { yenemy--; if (yenemy <= yMin || (xenemy == xpacman + 8 && yenemy == ypacman) || (xenemy == xpacman && yenemy == ypacman + 8)|| (xenemy == xpacman - 8 && yenemy == ypacman) || (xenemy == xpacman && yenemy == ypacman - 8)) { xpacman = 120; ypacman = 80; } } if (ypacman > yenemy) { yenemy++; if (yenemy >= yMax || (xenemy == xpacman + 8 && yenemy == ypacman) || (xenemy == xpacman && yenemy == ypacman + 8)|| (xenemy == xpacman - 8 && yenemy == ypacman) || (xenemy == xpacman && yenemy == ypacman - 8)) { xpacman = 120; ypacman = 80; } } } |
But when I move my pacman to the edge of the screen, then sideways, it appears in the middle of the screen again (like it should when it gets hit) even though none of my statements evaluate true. Can you please help me get to the bottom of this bug,
Biubid_boy.