Pac-Man Movements

TheouAegis

Member
Make sure you removed the code that's like

{
direction=180;
sprite_index=sprite_left;
}

If the ghost is not changing directions, either means
  1. You have that old code still which is setting the direction manually
  2. The ghost is never align to the grid so can't change directions, which in theory shouldn't be happening because we're doing everything the same as with Pac-Man I think
  3. Um.. or some other issue LOL
 
I think what it is is the way I've put the code in because I have it looking like this:

///Step Event
if (x - grid/2) mod grid == 0 && (y-grid/2) mod grid == 0 {
for(var paths, i=0; i<4; i++;)
paths = -1;
var n = 0;
for(i=0; i<360; i+= 90;) {
if i != (direction + 180) mod 360
if !place_meeting(x+lengthdir_x(grid/2,i), y+lengthdir_y(grid/2,i), obj_Pac_Collision)
paths[n++] = i;
}
if paths[0] == -1 { //this should NEVER happen, but just in case...
direction = 270;
exit;
}
if paths[1] == -1 { //this means there is only one path available
direction = paths[0];
exit;
}
var h = abs(targetX - x);
var v = abs(targetY - y);
var dx = point_direction(x,y,targetX,y);
var dy = point_direction(x,y,x,targetY);
if h > v {
//Try to move horizontally
for(i=0; i<4; i++;)
if paths == dx {
direction = dx;
exit;
}
for(i=0; i<4; i++;)
if paths == dy {
direction = dy;
exit;;
}
}
else
if v > h {
//Try to move vertically
for(i=0; i<4; i++;)
if paths == dy {
direction = dy;
exit;
}
for(i=0; i<4; i++;)
if paths == dx {
direction = dx;
exit;
}
}
//If both distances are the same or both desired paths are unavailable, pick a random one
i = irandom(3);
while paths == -1
i = ++i mod 4;
direction = paths;
}
{
move_wrap(1,1,2);
}
switch direction {
case 0: sprite_index = sprite_right; break
case 90: sprite_index = sprite_up; break
case 180: sprite_index = sprite_left; break
case 270: sprite_index = sprite_down; break
}

maybe I can put the switch part into create
 

TheouAegis

Member
So wait, everything worked fine until you added the switch? Just adding the switch shouldn't have broken anything. Go back to the code you had when the ghosts were working just fine.

Blinky's Create event should initialize all the variables used by the Step Event. Inside Blinky, define his sprite_up, sprite_right, sprite_down, and sprite_left. Give Blinky the End Step event switch.
Code:
switch direction {
case 0: sprite_index = sprite_right; break;
case 90: sprite_index = sprite_up; break;
case 180: sprite_index = sprite_left; break;
case 270: sprite_index = sprite_down; break;
}
Put the movement code in Blinky's Step event. Set Blinky's target in the Begin Step event.

In each of the other ghosts, set their own target in their own Begin Step events. In the Create Event for each of the other ghosts, FIRST call Blinky's Create Event using event_inherited(), then define their own sprite_right, sprite_up, sprite_left, and sprite_down. The other ghosts should have no other events -- just Create and Begin Step.


Blinky (no parent):
Create Event:
  1. Define all new variables used by the movement code
  2. Define sprite_right, sprite_up, sprite_left, and sprite_down
Begin Step Event:
  1. Get the targetX and targetY coordinates
Step Event:
  1. The AI movement code
End Step Event:
  1. Switch statement specifying which sprite to use
Other Ghosts (Blinky set as their parent):
Create Event:
  1. event_inherited();
  2. Define sprite_right, sprite_up, sprite_left, and sprite_down
Begin Step Event:
  1. Get the targetX and targetY coordinates
 
Last edited:
So this is what it should look like?:

Create:
goHome = false;
global.PowerPellet = false;
grid = 32;
speed = 4;
sprite_up = Blinky_up;
sprite_down = Blinky_down;
sprite_right = Blinky_right;
sprite_left = Blinky_left;

Step:
///Step Event
if (x - grid/2) mod grid == 0 && (y-grid/2) mod grid == 0 {
for(var paths, i=0; i<4; i++;)
paths = -1;
var n = 0;
for(i=0; i<360; i+= 90;) {
if i != (direction + 180) mod 360
if !place_meeting(x+lengthdir_x(grid/2,i), y+lengthdir_y(grid/2,i), obj_Pac_Collision)
paths[n++] = i;
}
if paths[0] == -1 { //this should NEVER happen, but just in case...
direction = 270;
exit;
}
if paths[1] == -1 { //this means there is only one path available
direction = paths[0];
exit;
}
var h = abs(targetX - x);
var v = abs(targetY - y);
var dx = point_direction(x,y,targetX,y);
var dy = point_direction(x,y,x,targetY);
if h > v {
//Try to move horizontally
for(i=0; i<4; i++;)
if paths == dx {
direction = dx;
exit;
}
for(i=0; i<4; i++;)
if paths == dy {
direction = dy;
exit;;
}
}
else
if v > h {
//Try to move vertically
for(i=0; i<4; i++;)
if paths == dy {
direction = dy;
exit;
}
for(i=0; i<4; i++;)
if paths == dx {
direction = dx;
exit;
}
}
//If both distances are the same or both desired paths are unavailable, pick a random one
i = irandom(3);
while paths == -1
i = ++i mod 4;
direction = paths;
}
{
move_wrap(1,1,2);
}

Begin Step:
///Begin Step Event
if goHome {
targetX = 511//whatever the x-coordinate is for the ghost's home;
targetY = 528//whatever the y-coordinate is for the ghost's home;
speed = 4;
}
else
if global.PowerPellet {
targetX = 0;
targetY = 0;
speed = 4;
}
else {
targetX = obj_Player_1.x;
targetY = obj_Player_1.y;
speed = 4;
}

End Step:
switch direction {
case 0: sprite_index = sprite_right; break;
case 90: sprite_index = sprite_up; break;
case 180: sprite_index = sprite_left; break;
case 270: sprite_index = sprite_down; break;
}
 

TheouAegis

Member
Something bugging me about my code that I can't test right now...

Change this part:

var dx = point_direction(x,y,targetX,y);
var dy = point_direction(x,y,x,targetY);


To this:
Code:
var dx,dy;
if targetX<x dx=180
else if targetX>x dx = 0;
else dx = 360;
if targetY<y dy=90
else if targetY>y dy=270
else dy = 360;
 

TheouAegis

Member
I'll try to not get distracted by YouTube tonight and see if there is a glitch and the code I gave you specifically.

What is the size of Blinky's sprites? More importantly, what is the size of the bounding box or mask for Blinky? Remember, we had to change Pac-Man Sprite because that one was not set right and was too big for your grid. If Blinky is also too big for the grid, you need to make sure he has the same mask that fits the grid like Pac-Man does.
 
Blinky is pretty much the same size as Pac-Man as well as the bounding box which is 32. But the thing is before you gave me said code He was moving just fine, just not animating.
 
Last edited:

TheouAegis

Member
Well, the only changes I needed to make to the original code was to replace place_meeting() with position_meeting(); and instead of using grid/2 in that function, I used just grid. My guess is your ghost sprite was still too big. Even if you used a mask, perhaps the code was still trying to read the ghost's own sprite data instead of the mask's data, which was causing errors. By switching my code to use position_meeting(), it effectively ignores the the ghost completely, which really is what we want -- the ghost shouldn't check for collisions with walls, it should just check for walls in the direction it wants to go. In a free-roaming game, you would usually want to use place_meeting(), but in this case since everything is aligned to a grid, we use position_meeting() instead.

I also expanded the path-finding. My original code let the ghost pick a path too randomly. In some cases even if it could move toward the target, it'd randomly choose to move away from the target. I corrected that in the code below as well.

You will notice the ghost goes straight to Pac-Man now, assuming it works. I'll explain how to deal with that later.

Code:
///Step Event
if (floor(x) - grid/2) mod grid == 0 && (floor(y)-grid/2) mod grid == 0 {
    for(var paths, i=0; i<4; i++;)
        paths[i] = -1;
    var n = 0;
    for(i=0; i<360; i+= 90;) {
        if i != (direction + 180) mod 360
        if !position_meeting(x+lengthdir_x(grid,i), y+lengthdir_y(grid,i), oWall)
            paths[n++] = i;
    }
   show_debug_message(paths)
    if paths[0] == -1 {  //this should NEVER happen, but just in case...
        direction = 270;
        exit;
    }
    if paths[1] == -1 {  //this means there is only one path available
        direction = paths[0];
        exit;
    }
    var h = abs(targetX - x);
    var v = abs(targetY - y);
   var dx = point_direction(x,y,targetX,y);
   var dy = point_direction(x,y,x,targetY);

    if h > v {
    //Try to move horizontally
        for(i=0; i<4; i++;)
            if paths[i] == dx {
                direction = dx;
                exit;
            }
        for(i=0; i<4; i++;)
            if paths[i] == dy {
                direction = dy;
                exit;;
            }
    }
    if v > h {
    //Try to move vertically
        for(i=0; i<4; i++;)
            if paths[i] == dy {
                direction = dy;
                exit;
            }
        for(i=0; i<4; i++;)
            if paths[i] == dx {
                direction = dx;
                exit;
            }
    }
    //If both distances are the same or both desired paths are unavailable, pick a random one
   n = -1
   for(i=0; i<4; i++)
       if paths[i] == dx
           if n == -1
               n = dx;
           else {
               n = choose(dx,dy);
               break;
           }
       else
       if paths[i] == dy
           if n == -1
               n = dy;
           else {
               n = choose(dx,dy);
               break;
           }
   if n != -1
       direction = n;
   else {
       i = irandom(3);
       while paths[i] == -1
           i = ++i mod 4;
       direction = paths[i];
   }
}
I handled my ghost's animation differently than you, but the switch at the End Step event does the same thing.

I simplified my Create and Begin events since this was just a test run for me. The Begin Step just set targetX, targetY and speed. The Create just set grid to my wall size and set direction to 180, as well as calling randomize() because my ghost kept ignoring certain paths.
 
Last edited:

GMWolf

aka fel666
So I didn't read the entire thread.
I'm fact, I barely read any of it, so I apologize if I am missing something important piece of info.

But pacman movement with place_meating and other collision functions? You are gonna have a bad time!
Collision functions are finicky due to them working with floating point positions.
Great when you are dealing with continuous movement but for movement on a grid like pacman you will just end up with off by one (or less) errors and get your characters caught up against edges of walls, etc.

I strongly recommend the use of tilemaps instead.
They may seem come complex to use at first, and yes, they do require a little more coding to check collisions against to get started.
However, in reality, tilemap collisions are far less complex that instance collisions, and end up being far easier to reason about, and have far fewer edge cases to worry about.
They will also end up speeding up your workflow, and once you are used to them, greatly simplifies your code.


It's one of those things that can seem a little more complex to a beginner, but any experienced users will know tilemaps are indeed the easier option.
It's somewhat akin to using a physics engine for Tetris. It might seem easier at first because you can get the blocks to fall and stop moving when they hit each other, but now you need to stop them from rotating, control how fast they fall, find a way to check when a line has been completed, etc. It would have been easier to use a simpler model like a grid/tiles.

The same idea applies here.
You might find it easier to check collisions this way, but then to move along a grid, avoid getting snagged against the edges of wall tiles, path finding etc, it becomes far more complicated.
 
OK I'm back, sorry for the lack of communication. So what I end up doing is change up almost all the sprites I have made (some still getting fixed) into a more proper proportion by first making it 8-bit and then import it to the program as a proper 64-bit type size. After doing that the original code you gave me for the ghost's change event is working properly now. What I think was the problem was not just the sprite size but the canvas size as well considering that it was mostly an odd amount of pixels rather than even amount. I also went and made down-sized version of the project as well being 32-bit and everything works there too.
 

TheouAegis

Member
Starting small and scaling up in post-render is the easiest in my opinion. After posting my last code, I switched the project over to tile-based and started modifying speeds. One would think a larger grid size gives more room to work with, but it also gives more room for error. Speeds less than 1 are the simplest, but as soon as you get over 1pps, errors start popping up more frequently. Working with tile-based collisions, there are still movement speed considerations, but a little more room for dealing with possible errors.
 
Starting small and scaling up in post-render is the easiest in my opinion. After posting my last code, I switched the project over to tile-based and started modifying speeds. One would think a larger grid size gives more room to work with, but it also gives more room for error. Speeds less than 1 are the simplest, but as soon as you get over 1pps, errors start popping up more frequently. Working with tile-based collisions, there are still movement speed considerations, but a little more room for dealing with possible errors.
OK with the sprite change done how should I go about giving each ghost their own specific target/personality command?
 

TheouAegis

Member
You set their targetX and targetY in their Begin Step event.This will force them to ignore Blinky's Begin Step event if they have him as a parent, so they won't use his target.
 
I figured that, I mean like for instance Pinky. How would I implement her to to always try to get ahead of the player? like do I say Target = 4 + obj_Player_1.x and etc.?
 

TheouAegis

Member
Okay, here's the breakdown of how each of the ghosts work using speed variables:

Blinky
targetX = Pacman.x
targetY = Pacman.y

Pinky
targetX = Pacman.x + grid * 3 * sign(Pacman.hspeed)
targetY = Pacman.y + grid * 3 * sign(Pacman.vspeed)

Inky
targetX = ( Pacman.x * 2 - Blinky.x ) mod maze_width maze_width is how many pixels wide the maze itself is
targetY = ( Pacman.y * 2 - Blinky.y) mod maze_height maze_height is how many pixels high the maze itself is

Clyde
if abs(Pacman.x - x) < grid*4 && abs(Pacman.y - y) < grid*4 {
var r = irandom(3),n;
repeat 4 {
n = paths[r];
if n > -1 && n != (direction + 180) mod 360 {
direction = n;
break;​
}
r = ++r mod 4;​
}​
}
else {
targetX = Pacman.x
targetY = Pacman.y​
}

Fruit
targetX = horizontal middle of ghost house
targetY = vertical middle of ghost house
(since the fruit can't cross the ghosts' door, it just circles around the ghost house)


A note about Inky's code. In the original code, maze_width and maze_height were both 256 pixels, which was larger than both the maze and the room. Regardless... Whether you should use maze_width vs. room_width or maze_height vs. room_height depends on how your room is set up. If the maze takes up the full width of the room, use room_width. If the maze takes up the full height of the room, use room_height. If the score is to the right of the maze, you should use maze_width. If the score is below the maze, use maze_height. If the score is to the left of the maze, the formula changes to (Pacman.x * 2 - Blinky.x - maze_left) mod maze_width + maze_left, where maze_left is how many pixels away from the left edge of the room the maze is. If the score is above the maze, the formula changes to (Pacman.y * 2 - Blinky.y - maze_top) mod maze_height + maze_top, where maze_top is how many pixels away from the top of the room the maze is. In any case, you could opt to just use room_width and room_height, which would cause a slight difference in Inky's behavior. For example, if the score is on the left or right side of the maze and you used room_width instead of maze_width, there is a possibility that targetX would be a point outside the maze. This is not as bad as it my seem, as the original code is just as quirky. See, Inky's behavior is to get on the opposite side of Pac-Man as Blinky using a pincer attack. However, the way the code is written, it's possible for Inky to try to move behind Blinky sometimes or get between Blinky and Pac-Man other times. This is because (Pacman.x * 2 - Blinky.x) might fall outside the maze, which makes "mod maze_width" put targetX on the opposite side of the maze. It was a glitch that wasn't game-breaking because of how the rest of the AI code works. Likewise, if you just used room_width and room_height instead of maze_width and maze_height, then targetX or targetY could potentially get set outside the maze, but as the ghost's AI prevents it from leaving the maze, there's no problem. A professional Pac-Man player might spot the difference in behavior, but the average gamer won't.
 
Last edited:
Okay, here's the breakdown of how each of the ghosts work using speed variables:

Blinky
targetX = Pacman.x
targetY = Pacman.y

Pinky
targetX = Pacman.x + grid * 3 * sign(Pacman.hspeed)
targetY = Pacman.y + grid * 3 * sign(Pacman.vspeed)

Inky
targetX = ( Pacman.x * 2 - Blinky.x ) mod maze_width maze_width is how many pixels wide the maze itself is
targetY = ( Pacman.y * 2 - Blinky.y) mod maze_height maze_height is how many pixels high the maze itself is

Clyde
if abs(Pacman.x - x) < grid*4 && abs(Pacman.y - y) < grid*4 {
var r = irandom(3),n;
repeat 4 {
n = paths[r];
if n > -1 && n != (direction + 180) mod 360 {
direction = n;
break;​
}
r = ++r mod 4;​
}​
}
else {
targetX = Pacman.x
targetY = Pacman.y​
}

Fruit
targetX = horizontal middle of ghost house
targetY = vertical middle of ghost house
(since the fruit can't cross the ghosts' door, it just circles around the ghost house)


A note about Inky's code. In the original code, maze_width and maze_height were both 256 pixels, which was larger than both the maze and the room. Regardless... Whether you should use maze_width vs. room_width or maze_height vs. room_height depends on how your room is set up. If the maze takes up the full width of the room, use room_width. If the maze takes up the full height of the room, use room_height. If the score is to the right of the maze, you should use maze_width. If the score is below the maze, use maze_height. If the score is to the left of the maze, the formula changes to (Pacman.x * 2 - Blinky.x - maze_left) mod maze_width + maze_left, where maze_left is how many pixels away from the left edge of the room the maze is. If the score is above the maze, the formula changes to (Pacman.y * 2 - Blinky.y - maze_top) mod maze_height + maze_top, where maze_top is how many pixels away from the top of the room the maze is. In any case, you could opt to just use room_width and room_height, which would cause a slight difference in Inky's behavior. For example, if the score is on the left or right side of the maze and you used room_width instead of maze_width, there is a possibility that targetX would be a point outside the maze. This is not as bad as it my seem, as the original code is just as quirky. See, Inky's behavior is to get on the opposite side of Pac-Man as Blinky using a pincer attack. However, the way the code is written, it's possible for Inky to try to move behind Blinky sometimes or get between Blinky and Pac-Man other times. This is because (Pacman.x * 2 - Blinky.x) might fall outside the maze, which makes "mod maze_width" put targetX on the opposite side of the maze. It was a glitch that wasn't game-breaking because of how the rest of the AI code works. Likewise, if you just used room_width and room_height instead of maze_width and maze_height, then targetX or targetY could potentially get set outside the maze, but as the ghost's AI prevents it from leaving the maze, there's no problem. A professional Pac-Man player might spot the difference in behavior, but the average gamer won't.
for Clyde's code, it says that the variable paths is only referenced once while in the movement code it doesn't and it's only referenced once. Do I just say Paths = something in the create code?
 

TheouAegis

Member
Damn, I forgot I made paths a temporary variable in this thread. Ok then, Clyde doesn't need a Begin Step event. His Step event is going to need to be changed. I will fix it up after Christmas.
 

TheouAegis

Member
You could use choose(). But he only has one sound. Whenever Pac-Man eats a pill, it makes the chompy sound. The ghosts make a ghostly sound on loop (they themselves don't make it, but the game's controller does), which changes when the power pill is eaten, and then changes again when a ghost is eaten.
 
but from what I was told by a friend that actually made a Pac-Man game of his own it turns out the chomp sound is actually to different sounds alternating one another with every dot being eaten.
 

TheouAegis

Member
So first off, remove "var paths" from Blinky's Step event; it'd have been fine as a temporary variable if not for Clyde's AI. Just copy Blinky's Begin Step into Clyde, but change which corner he should run to if Pac-Man ate a power pill. Then change the beginning of Blinky's Step event to:
Code:
if (floor(x) - grid/2) mod grid == 0 && (floor(y)-grid/2) mod grid == 0 {
   for(var i=0; i<4; i++;)
       paths[i] = -1;
   var n = 0;
   for(i=0; i<360; i+= 90;) {
       if i != (direction + 180) mod 360
       if !position_meeting(x+lengthdir_x(grid,i), y+lengthdir_y(grid,i), oWall)
           paths[n++] = i;
   }

//Add this next block of code in
if object_index == Clyde && abs(Pacman.x - x) < grid*4 && abs(Pacman.y - y) < grid*4 {
    var r = irandom(3),n;
     repeat 4 {
        n = paths[r];
        if n > -1 && n != (direction + 180) mod 360 {
            direction = n;
            exit;
        }
        r = ++r mod 4;    }
}

//The rest of Blinky's code is the same

Are your ghosts still able to move back and forth sometimes? I've got a weird bug in my porgram I'm trying to figure out which is causing them to move back and forth.

Edit: I think I resolved my bug. I was using speeds less than 1, so I needed to make sure the ghost moved at least 1 pixel before checking for a new path.
 
Last edited:
So first off, remove "var paths" from Blinky's Step event; it'd have been fine as a temporary variable if not for Clyde's AI. Just copy Blinky's Begin Step into Clyde, but change which corner he should run to if Pac-Man ate a power pill. Then change the beginning of Blinky's Step event to:
Code:
if (floor(x) - grid/2) mod grid == 0 && (floor(y)-grid/2) mod grid == 0 {
   for(var paths, i=0; i<4; i++;)
       paths[i] = -1;
   var n = 0;
   for(i=0; i<360; i+= 90;) {
       if i != (direction + 180) mod 360
       if !position_meeting(x+lengthdir_x(grid,i), y+lengthdir_y(grid,i), oWall)
           paths[n++] = i;
   }

//Add this next block of code in
if object_index == Clyde && abs(Pacman.x - x) < grid*4 && abs(Pacman.y - y) < grid*4 {
    var r = irandom(3),n;
     repeat 4 {
        n = paths[r];
        if n > -1 && n != (direction + 180) mod 360 {
            direction = n;
            exit;
        }
        r = ++r mod 4;    }
}

//The rest of Blinky's code is the same

Are your ghosts still able to move back and forth sometimes? I've got a weird bug in my porgram I'm trying to figure out which is causing them to move back and forth.

Edit: I think I resolved my bug. I was using speeds less than 1, so I needed to make sure the ghost moved at least 1 pixel before checking for a new path.
What do you mean by remove var paths? doesn't the new code you gave me still have that in there? Also do I just put this new block of code right under the one on top?
 

TheouAegis

Member
What do you mean by remove var paths? doesn't the new code you gave me still have that in there? Also do I just put this new block of code right under the one on top?
Oh wow oops my bad. I edited the code now.

So in that code where it says "//Add this...", Copy everything from that comment down. Then go into Blinky step event and paste that code into his step event so that the beginning of the step event looks like what I had posted.

One thing I just realized about the code is it won't make Clyde run oh way every time. I have to go back and double-check the original code verify that was intended behavior or if I mist a step in the code, but I'm pretty sure it's intended.
 
Oh wow oops my bad. I edited the code now.

So in that code where it says "//Add this...", Copy everything from that comment down. Then go into Blinky step event and paste that code into his step event so that the beginning of the step event looks like what I had posted.

One thing I just realized about the code is it won't make Clyde run oh way every time. I have to go back and double-check the original code verify that was intended behavior or if I mist a step in the code, but I'm pretty sure it's intended.
So Iput in the new code for Blinky's Step and all the ghost are now able to go back and forth instead of only finding a new path. I know you mentioned about speed and the only highest speed they can go to is 2 since I got everything on a 32 pixel scale and that's the current speed i got them going now. How can I fix that problem?
 

TheouAegis

Member
Post your full Blinky code now. A grid of 32 and speed of 2 should be fine, and my project was working fine.

You can reduce grid to 16 or 8 and it SHOULD still be ok, in theory.
 
Post your full Blinky code now. A grid of 32 and speed of 2 should be fine, and my project was working fine.

You can reduce grid to 16 or 8 and it SHOULD still be ok, in theory.
STEP
if (floor(x) - grid/2) mod grid == 0 && (floor(y)-grid/2) mod grid == 0 {
for(var i=0; i<4; i++;)
paths = -1;
var n = 0;
for(i=0; i<360; i+= 90;) {
if i != (direction + 180) mod 360
if !position_meeting(x+lengthdir_x(grid,i), y+lengthdir_y(grid,i), obj_Pac_Collision)
paths[n++] = i;
}
//Add this next block of code in
if object_index == obj_Clyde && abs(obj_Player_1.x - x) < grid*4 && abs(obj_Player_1.y - y) < grid*4 {
var r = irandom(3),n;
repeat 4 {
n = paths[r];
if n > -1 && n != (direction + 180) mod 360 {
direction = n;
exit;
}
r = ++r mod 4; }
}
if paths[0] == -1 { //this should NEVER happen, but just in case...
direction = 270;
exit;
}
if paths[1] == -1 { //this means there is only one path available
direction = paths[0];
exit;
}
var h = abs(targetX - x);
var v = abs(targetY - y);
var dx = point_direction(x,y,targetX,y);
var dy = point_direction(x,y,x,targetY);
if h > v {
//Try to move horizontally
for(i=0; i<4; i++;)
if paths == dx {
direction = dx;
exit;
}
for(i=0; i<4; i++;)
if paths == dy {
direction = dy;
exit;;
}
}
else
if v > h {
//Try to move vertically
for(i=0; i<4; i++;)
if paths == dy {
direction = dy;
exit;
}
for(i=0; i<4; i++;)
if paths == dx {
direction = dx;
exit;
}
}
//If both distances are the same or both desired paths are unavailable, pick a random one
i = irandom(3);
while paths == -1
i = ++i mod 4;
direction = paths;
}
{
move_wrap(1,1,2);
}


CREATE

goHome = false;
global.PowerPellet = false;
grid = 16;
speed = 2;
sprite_up = Blinky_up;
sprite_down = Blinky_down;
sprite_right = Blinky_right;
sprite_left = Blinky_left;

BEGIN STEP
if goHome {
targetX = 511//whatever the x-coordinate is for the ghost's home;
targetY = 528//whatever the y-coordinate is for the ghost's home;
speed = 2;
}
else
if global.PowerPellet {
targetX = 0;
targetY = 0;
speed = 2;
}
else {
targetX = obj_Player_1.x;
targetY = obj_Player_1.y;
speed = 2;
}

END STEP

switch direction {
case 0: sprite_index = sprite_right; break;
case 90: sprite_index = sprite_up; break;
case 180: sprite_index = sprite_left; break;
case 270: sprite_index = sprite_down; break;
}
 
Last edited:
STEP
if (floor(x) - grid/2) mod grid == 0 && (floor(y)-grid/2) mod grid == 0 {
for(var i=0; i<4; i++;)
paths = -1;
var n = 0;
for(i=0; i<360; i+= 90;) {
if i != (direction + 180) mod 360
if !position_meeting(x+lengthdir_x(grid,i), y+lengthdir_y(grid,i), obj_Pac_Collision)
paths[n++] = i;
}
//Add this next block of code in
if object_index == obj_Clyde && abs(obj_Player_1.x - x) < grid*4 && abs(obj_Player_1.y - y) < grid*4 {
var r = irandom(3),n;
repeat 4 {
n = paths[r];
if n > -1 && n != (direction + 180) mod 360 {
direction = n;
exit;
}
r = ++r mod 4; }
}
if paths[0] == -1 { //this should NEVER happen, but just in case...
direction = 270;
exit;
}
if paths[1] == -1 { //this means there is only one path available
direction = paths[0];
exit;
}
var h = abs(targetX - x);
var v = abs(targetY - y);
var dx = point_direction(x,y,targetX,y);
var dy = point_direction(x,y,x,targetY);
if h > v {
//Try to move horizontally
for(i=0; i<4; i++;)
if paths == dx {
direction = dx;
exit;
}
for(i=0; i<4; i++;)
if paths == dy {
direction = dy;
exit;;
}
}
else
if v > h {
//Try to move vertically
for(i=0; i<4; i++;)
if paths == dy {
direction = dy;
exit;
}
for(i=0; i<4; i++;)
if paths == dx {
direction = dx;
exit;
}
}
//If both distances are the same or both desired paths are unavailable, pick a random one
i = irandom(3);
while paths == -1
i = ++i mod 4;
direction = paths;
}
{
move_wrap(1,1,2);
}


CREATE

goHome = false;
global.PowerPellet = false;
grid = 16;
speed = 2;
sprite_up = Blinky_up;
sprite_down = Blinky_down;
sprite_right = Blinky_right;
sprite_left = Blinky_left;

BEGIN STEP
if goHome {
targetX = 511//whatever the x-coordinate is for the ghost's home;
targetY = 528//whatever the y-coordinate is for the ghost's home;
speed = 2;
}
else
if global.PowerPellet {
targetX = 0;
targetY = 0;
speed = 2;
}
else {
targetX = obj_Player_1.x;
targetY = obj_Player_1.y;
speed = 2;
}

END STEP

switch direction {
case 0: sprite_index = sprite_right; break;
case 90: sprite_index = sprite_up; break;
case 180: sprite_index = sprite_left; break;
case 270: sprite_index = sprite_down; break;
}
I also tried to make a small opening for the ghost to come out of the ghost base but for some reason they can't and their collision mask is the same as always. I'm thinking it's the grid size.
 
Last edited:

TheouAegis

Member
Make sure all the ghosts' coordinates are even numbers (0,2,4,6,8,10,12,14,16, etc.) for both starting x and y.

Are your ghosts all inside the ghost house? First off, Blinky starts in the maze, not in the house. But anyway, if you have them all inside the house, put them outside the house. We can deal with the house later as long as the ghosts move fine the rest of the time.

Also, the middle of the ghost house should be 512, not 511.
 
Make sure all the ghosts' coordinates are even numbers (0,2,4,6,8,10,12,14,16, etc.) for both starting x and y.

Are your ghosts all inside the ghost house? First off, Blinky starts in the maze, not in the house. But anyway, if you have them all inside the house, put them outside the house. We can deal with the house later as long as the ghosts move fine the rest of the time.

Also, the middle of the ghost house should be 512, not 511.
No it was just Pinky, Inky and Clyde but OK. Did you also I ended up going back to the code where they all was still working properly. I might be doing something wrong with the new code you gave me or the "/2" might be throwing me off.
 

TheouAegis

Member
No it was just Pinky, Inky and Clyde but OK. Did you also I ended up going back to the code where they all was still working properly. I might be doing something wrong with the new code you gave me or the "/2" might be throwing me off.
I'm testing out your code now. I'm curious why it stopped working, too.
 
where they're currently standing at-

Blinky: 224, 216
Pinky: 256, 216
Inky: 184, 264
Clyde: 328, 264
Summer: 288, 216
Sue: 256, 120
Funky: 184, 168
Spunky: 328, 168
 

TheouAegis

Member
Hm...

They should be working... Everyone there is aligned properly so that as long as they start moving left or right (instead of up or down), they should stay aligned to the grid so that the pathing executes.

Right before the "//Add this next block of code in" line, put this debug line back in:
Code:
show_debug_message(object_get_name(object_index)+":  "+string(paths));
Then run the game for, oh, 3 seconds. Then close the game. Go to the Output form and copy everything from
**********************************.
Entering main loop.
**********************************.
onward and paste them here.

Also, what I was looking for with the coordinates is you need to make sure that x is even and that (y-grid/2)mod grid is 0. So if grid is 16, then it should work for everyone. If you set grid to 8, then it wouldn't work.
 
Last edited:

TheouAegis

Member
where they're currently standing at-

Blinky: 224, 216
Pinky: 256, 216
Inky: 184, 264
Clyde: 328, 264
Summer: 288, 216
Sue: 256, 120
Funky: 184, 168
Spunky: 328, 168
One more thing. Does your room look like this (ignore the ghosts and Pac-Man):

where each wall and pellet take up exactly one cell, where each cell is 16pixels x 16pixels?
 
**********************************.
Entering main loop.
**********************************.
obj_Inky: { { 90,270,-1,-1 }, }
obj_Clyde: { { 0,90,270,-1 }, }
obj_Funky: { { 0,90,-1,-1 }, }
obj_Spunky: { { 90,-1,-1,-1 }, }
obj_Blinky: { { 0,90,-1,-1 }, }
obj_Pinky: { { 0,-1,-1,-1 }, }
obj_Summer: { { 0,-1,-1,-1 }, }
obj_Sue: { { 0,-1,-1,-1 }, }
obj_Inky: { { 90,-1,-1,-1 }, }
obj_Clyde: { { 270,-1,-1,-1 }, }
obj_Funky: { { 0,-1,-1,-1 }, }
obj_Spunky: { { 90,-1,-1,-1 }, }
obj_Blinky: { { 0,270,-1,-1 }, }
obj_Pinky: { { 0,90,-1,-1 }, }
obj_Summer: { { 0,-1,-1,-1 }, }
obj_Sue: { { 0,90,-1,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Inky: { { 90,-1,-1,-1 }, }
obj_Clyde: { { 270,-1,-1,-1 }, }
obj_Funky: { { 0,-1,-1,-1 }, }
obj_Spunky: { { 90,-1,-1,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Pinky: { { 0,-1,-1,-1 }, }
obj_Summer: { { 270,-1,-1,-1 }, }
obj_Sue: { { 90,-1,-1,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Inky: { { 0,-1,-1,-1 }, }
obj_Clyde: { { 180,270,-1,-1 }, }
obj_Funky: { { 270,-1,-1,-1 }, }
obj_Spunky: { { 0,180,-1,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Pinky: { { 0,-1,-1,-1 }, }
obj_Summer: { { 270,-1,-1,-1 }, }
obj_Sue: { { 90,-1,-1,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Inky: { { 0,-1,-1,-1 }, }
obj_Clyde: { { 180,-1,-1,-1 }, }
obj_Funky: { { 270,-1,-1,-1 }, }
obj_Spunky: { { 180,-1,-1,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Pinky: { { 270,-1,-1,-1 }, }
obj_Summer: { { 270,-1,-1,-1 }, }
obj_Sue: { { 90,-1,-1,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Inky: { { 0,-1,-1,-1 }, }
obj_Clyde: { { 180,-1,-1,-1 }, }
obj_Funky: { { 270,-1,-1,-1 }, }
obj_Spunky: { { 180,-1,-1,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Pinky: { { 270,-1,-1,-1 }, }
obj_Summer: { { 0,270,-1,-1 }, }
obj_Sue: { { 0,-1,-1,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Inky: { { 0,90,-1,-1 }, }
obj_Clyde: { { 180,-1,-1,-1 }, }
obj_Funky: { { 0,180,-1,-1 }, }
obj_Spunky: { { 90,180,-1,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Pinky: { { 270,-1,-1,-1 }, }
obj_Summer: { { 270,-1,-1,-1 }, }
obj_Sue: { { 0,-1,-1,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Inky: { { 90,-1,-1,-1 }, }
obj_Clyde: { { 180,-1,-1,-1 }, }
obj_Funky: { { 0,270,-1,-1 }, }
obj_Spunky: { { 180,-1,-1,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Pinky: { { 0,270,-1,-1 }, }
obj_Summer: { { 270,-1,-1,-1 }, }
obj_Sue: { { 0,-1,-1,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Inky: { { 90,-1,-1,-1 }, }
obj_Clyde: { { 180,-1,-1,-1 }, }
obj_Funky: { { 0,-1,-1,-1 }, }
obj_Spunky: { { 180,-1,-1,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Pinky: { { 270,-1,-1,-1 }, }
obj_Summer: { { 180,270,-1,-1 }, }
obj_Sue: { { 0,-1,-1,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Inky: { { 180,-1,-1,-1 }, }
obj_Clyde: { { 180,-1,-1,-1 }, }
obj_Funky: { { 0,90,-1,-1 }, }
obj_Spunky: { { 90,180,-1,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Pinky: { { 270,-1,-1,-1 }, }
obj_Summer: { { 180,-1,-1,-1 }, }
obj_Sue: { { 0,-1,-1,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Inky: { { 180,-1,-1,-1 }, }
obj_Clyde: { { 180,-1,-1,-1 }, }
obj_Funky: { { 90,-1,-1,-1 }, }
obj_Spunky: { { 90,-1,-1,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Pinky: { { 180,270,-1,-1 }, }
obj_Summer: { { 180,-1,-1,-1 }, }
obj_Sue: { { 0,-1,-1,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Inky: { { 180,-1,-1,-1 }, }
obj_Clyde: { { 180,-1,-1,-1 }, }
obj_Funky: { { 90,-1,-1,-1 }, }
obj_Spunky: { { 90,-1,-1,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Pinky: { { 180,-1,-1,-1 }, }
obj_Summer: { { 180,-1,-1,-1 }, }
obj_Sue: { { 0,270,-1,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Inky: { { 90,-1,-1,-1 }, }
obj_Clyde: { { 90,270,-1,-1 }, }
obj_Funky: { { 0,-1,-1,-1 }, }
obj_Spunky: { { 90,-1,-1,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Pinky: { { 180,-1,-1,-1 }, }
obj_Summer: { { 180,-1,-1,-1 }, }
obj_Sue: { { 270,-1,-1,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Inky: { { 90,-1,-1,-1 }, }
obj_Clyde: { { 270,-1,-1,-1 }, }
obj_Funky: { { 0,-1,-1,-1 }, }
obj_Spunky: { { 180,-1,-1,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Pinky: { { 180,-1,-1,-1 }, }
obj_Summer: { { 180,-1,-1,-1 }, }
obj_Sue: { { 270,-1,-1,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Inky: { { 90,-1,-1,-1 }, }
obj_Clyde: { { 270,-1,-1,-1 }, }
obj_Funky: { { 0,-1,-1,-1 }, }
obj_Spunky: { { 180,-1,-1,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Pinky: { { 180,-1,-1,-1 }, }
obj_Summer: { { 180,-1,-1,-1 }, }
obj_Sue: { { 270,-1,-1,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Inky: { { 0,180,-1,-1 }, }
obj_Clyde: { { 0,180,-1,-1 }, }
obj_Funky: { { 90,-1,-1,-1 }, }
obj_Spunky: { { 180,-1,-1,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Pinky: { { 180,-1,-1,-1 }, }
obj_Summer: { { 180,-1,-1,-1 }, }
obj_Sue: { { 0,180,270,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Inky: { { 180,-1,-1,-1 }, }
obj_Clyde: { { 0,-1,-1,-1 }, }
obj_Funky: { { 90,-1,-1,-1 }, }
obj_Spunky: { { 180,-1,-1,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Pinky: { { 180,-1,-1,-1 }, }
obj_Summer: { { 180,-1,-1,-1 }, }
obj_Sue: { { 270,-1,-1,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Inky: { { 180,-1,-1,-1 }, }
obj_Clyde: { { 0,-1,-1,-1 }, }
obj_Funky: { { 90,-1,-1,-1 }, }
obj_Spunky: { { 180,-1,-1,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Pinky: { { 180,-1,-1,-1 }, }
obj_Summer: { { 90,270,-1,-1 }, }
obj_Sue: { { 270,-1,-1,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Inky: { { 90,180,270,-1 }, }
obj_Clyde: { { 270,-1,-1,-1 }, }
obj_Funky: { { 0,180,-1,-1 }, }
obj_Spunky: { { 180,-1,-1,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Pinky: { { 180,-1,-1,-1 }, }
obj_Summer: { { 270,-1,-1,-1 }, }
obj_Sue: { { 0,270,-1,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Inky: { { 180,-1,-1,-1 }, }
obj_Clyde: { { 270,-1,-1,-1 }, }
obj_Funky: { { 0,-1,-1,-1 }, }
obj_Spunky: { { 180,270,-1,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Pinky: { { 90,270,-1,-1 }, }
obj_Summer: { { 270,-1,-1,-1 }, }
obj_Sue: { { 0,-1,-1,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Inky: { { 180,-1,-1,-1 }, }
obj_Clyde: { { 270,-1,-1,-1 }, }
obj_Funky: { { 0,-1,-1,-1 }, }
obj_Spunky: { { 270,-1,-1,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Pinky: { { 270,-1,-1,-1 }, }
obj_Summer: { { 0,180,-1,-1 }, }
obj_Sue: { { 0,-1,-1,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Inky: { { 180,-1,-1,-1 }, }
obj_Clyde: { { 0,180,-1,-1 }, }
obj_Funky: { { 0,90,270,-1 }, }
obj_Spunky: { { 270,-1,-1,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Pinky: { { 270,-1,-1,-1 }, }
obj_Summer: { { 0,-1,-1,-1 }, }
obj_Sue: { { 0,-1,-1,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
Attempting to set gamepadcount to 0
Not shutting down steam as it is not initialised
X://windows/Runner.exe DONE (0)
Igor complete.
elapsed time 00:01:13.6917221s for command "C:\ProgramData/GameMakerStudio2/Cache/runtimes\runtime-2.2.5.378/bin/Igor.exe" -j=8 -options="C:\Users\deona\AppData\Local\GameMakerStudio2\GMS2TEMP\build.bff" -v -- Windows Run started at 12/30/2019 04:41:38
"cmd" /c subst Z: /d
elapsed time 00:00:00.7804880s for command "cmd" /c subst Z: /d started at 12/30/2019 04:42:51
"cmd" /c subst Y: /d
elapsed time 00:00:00.1997524s for command "cmd" /c subst Y: /d started at 12/30/2019 04:42:52
"cmd" /c subst X: /d
elapsed time 00:00:00.1242376s for command "cmd" /c subst X: /d started at 12/30/2019 04:42:52
SUCCESS: Run Program Complete

Good news the code works again, I think it might've been the way I put the code in the first time.
 
Last edited:

TheouAegis

Member
That readout is interesting...

obj_Inky: { { 90,270,-1,-1 }, }
obj_Inky: { { 90,-1,-1,-1 }, }
obj_Inky: { { 90,-1,-1,-1 }, }
obj_Inky: { { 0,-1,-1,-1 }, }
obj_Inky: { { 0,-1,-1,-1 }, }
obj_Inky: { { 0,-1,-1,-1 }, }
obj_Inky: { { 0,90,-1,-1 }, }
obj_Inky: { { 90,-1,-1,-1 }, }
obj_Inky: { { 90,-1,-1,-1 }, }
obj_Inky: { { 180,-1,-1,-1 }, }
obj_Inky: { { 180,-1,-1,-1 }, }
obj_Inky: { { 180,-1,-1,-1 }, }
obj_Inky: { { 90,-1,-1,-1 }, }
obj_Inky: { { 90,-1,-1,-1 }, }
obj_Inky: { { 90,-1,-1,-1 }, }
obj_Inky: { { 0,180,-1,-1 }, }
obj_Inky: { { 180,-1,-1,-1 }, }
obj_Inky: { { 180,-1,-1,-1 }, }
obj_Inky: { { 90,180,270,-1 }, }
obj_Inky: { { 180,-1,-1,-1 }, }
obj_Inky: { { 180,-1,-1,-1 }, }
obj_Inky: { { 180,-1,-1,-1 }, }
We can see here that Inky is indeed following the maze. He goes left 1 cell to a t-junction, goes up 3 cells to a right turn, goes right 3 cells to another t-junction, goes up 3 cells to a left turn, goes left three cells to an upward turn, goes up three cells to another t-junction, goes left three cells to four-way, keeps going left three more cells.

All of the other ghosts appear to be fine, except for Blinky, who appears to be moving right until he gets to a t-junction going up, which he ignores. Immediately after that is a junction moving down. Because 90 is missing on the next line, he clearly took the branch and is moving down, but then the next junction is a four-way which he gets stuck in...Or he moved outside of the grid.
obj_Blinky: { { 0,90,-1,-1 }, }
obj_Blinky: { { 0,270,-1,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }

By the way, try putting the move_wrap() at the top of the event. Because I use exit in a couple spots, that prevents move_wrap() from being called sometimes.
 
That readout is interesting...

obj_Inky: { { 90,270,-1,-1 }, }
obj_Inky: { { 90,-1,-1,-1 }, }
obj_Inky: { { 90,-1,-1,-1 }, }
obj_Inky: { { 0,-1,-1,-1 }, }
obj_Inky: { { 0,-1,-1,-1 }, }
obj_Inky: { { 0,-1,-1,-1 }, }
obj_Inky: { { 0,90,-1,-1 }, }
obj_Inky: { { 90,-1,-1,-1 }, }
obj_Inky: { { 90,-1,-1,-1 }, }
obj_Inky: { { 180,-1,-1,-1 }, }
obj_Inky: { { 180,-1,-1,-1 }, }
obj_Inky: { { 180,-1,-1,-1 }, }
obj_Inky: { { 90,-1,-1,-1 }, }
obj_Inky: { { 90,-1,-1,-1 }, }
obj_Inky: { { 90,-1,-1,-1 }, }
obj_Inky: { { 0,180,-1,-1 }, }
obj_Inky: { { 180,-1,-1,-1 }, }
obj_Inky: { { 180,-1,-1,-1 }, }
obj_Inky: { { 90,180,270,-1 }, }
obj_Inky: { { 180,-1,-1,-1 }, }
obj_Inky: { { 180,-1,-1,-1 }, }
obj_Inky: { { 180,-1,-1,-1 }, }
We can see here that Inky is indeed following the maze. He goes left 1 cell to a t-junction, goes up 3 cells to a right turn, goes right 3 cells to another t-junction, goes up 3 cells to a left turn, goes left three cells to an upward turn, goes up three cells to another t-junction, goes left three cells to four-way, keeps going left three more cells.

All of the other ghosts appear to be fine, except for Blinky, who appears to be moving right until he gets to a t-junction going up, which he ignores. Immediately after that is a junction moving down. Because 90 is missing on the next line, he clearly took the branch and is moving down, but then the next junction is a four-way which he gets stuck in...Or he moved outside of the grid.
obj_Blinky: { { 0,90,-1,-1 }, }
obj_Blinky: { { 0,270,-1,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }
obj_Blinky: { { 0,180,270,-1 }, }

By the way, try putting the move_wrap() at the top of the event. Because I use exit in a couple spots, that prevents move_wrap() from being called sometimes.
What do you mean he's missing a 90 on the next line, does it has something to do with the code?
 

TheouAegis

Member
No, I just mean it's showing he took the downward path; 90's not an available option because he can't move backwards.

All that matters is that readout shows all the ghosts should be working fine -- they're detecting paths and supposedly taking them. It also shows Blinky getting stuck somewhere for some reason.

If you want, upload a .YYZ of your project to some file hosting site and I can take a look at it, because everything's working fine on my end.
 
Top