Q
Qing Donnie Yoshi
Guest
Atm no I wanna at least have it functional first before a demo is made.how's this project going?
do you have any demo to have a play with?
Love PacMan
Atm no I wanna at least have it functional first before a demo is made.how's this project going?
do you have any demo to have a play with?
Love PacMan
The code didn't work so well. All it did was jumbled all the ghosts and Pac-Man together and pretty much ruined their movements.
with all {
if hspeed !=0 and position_meeting(xprevious,yprevious,other.id) and !position_meeting(x,y,other.id) {
x = other.myPair.x + hspeed;
y = other.myPair.y;
}
else
if vspeed != 0 && position_meeting(xprevious,yprevious,other.id) and !position_meeting(x,y,other.id) {
y = other.myPair.y + vspeed;
x = other.myPair.x;
}
}
OK getting better results,now back to the instance ID. Since there's 2 objects on each end of the tunnels shouldn't I put both of their Inst ID in as a ref for "myPair" in the create event?Woops! Yeah that was bad logic. I wrote that while walking. Try this one.
Code:with all { if hspeed !=0 and position_meeting(xprevious,yprevious,other.id) and !position_meeting(x,y,other.id) { x = other.myPair.x + hspeed; y = other.myPair.y; } else if vspeed != 0 && position_meeting(xprevious,yprevious,other.id) and !position_meeting(x,y,other.id) { y = other.myPair.y + vspeed; x = other.myPair.x; } }
No. Each one knows its own ID, so why would you need to add it? It only needs to know the ID of the other teleporter instance. That's what "myPair" is - the ID of the teleporter at the far end.OK getting better results,now back to the instance ID. Since there's 2 objects on each end of the tunnels shouldn't I put both of their Inst ID in as a ref for "myPair" in the create event?
Because just having the other instance ID alone causes Pac to get stuck...No. Each one knows its own ID, so why would you need to add it? It only needs to know the ID of the other teleporter instance. That's what "myPair" is - the ID of the teleporter at the far end.
It's not the instance ID that's wrong. I suspect that the place where you're moving Pac to is on top of the other teleporter, and he's just moving back and forth. You'll probably have to offset the destination x or y based on the bounding box of the teleporter, unless your hspeed and vspeed are at least the size of Pac himself.Because just having the other instance ID alone causes Pac to get stuck...
It might be the code because the one Pac kept getting stuck in I went straight to it first and it just get completely stick while the other one that's basically the first instance is working fine since Pac approaches it and instantly goes to the second instance.It's not the instance ID that's wrong. I suspect that the place where you're moving Pac to is on top of the other teleporter, and he's just moving back and forth. You'll probably have to offset the destination x or y based on the bounding box of the teleporter, unless your hspeed and vspeed are at least the size of Pac himself.
with all if place_meeting(x,y,other.id) {
if median(x,maze_left,maze_right) != x
x += maze_width * sign(hspeed);
else
if median(y,maze_top,maze_bottom) != y
y += maze_height * sign(vspeed);
}
with all if place_meeting(x,y,other.id) {
if median(x,maze_left,maze_right) != x {
x = other.myPair.x + hspeed;
y = other.myPair.y;
}
else
if median(y,maze_top,maze_bottom) != y {
x = other.myPair.x;
y = other.myPair.y + hspeed;
}
}
OK and what do I put to define Maze_top, Maze_Bottom, Maze_left, and Maze_right? it does look like I have to define those, do I put the maze name?OK, no more typing crap up on my phone. The logic error was essentially the same as last time. So now i'm just going to stick with the maze dimensions. I got distracted by the teleporter object. So use this in the teleporter object instead:
What it will do is check if any instance is colliding with the teleporter but halfway outside the maze. It will then just teleport the instance to the other side of the maze. This is your basic Pac-man layout. Since it's just based on the maze dimensions, you don't need myPair anymore.Code:with all if place_meeting(x,y,other.id) { if median(x,maze_left,maze_right) != x x += maze_width * sign(hspeed); else if median(y,maze_top,maze_bottom) != y y += maze_height * sign(vspeed); }
If you want the teleporter to send Pac-man or the ghosts somewhere other than just on the opposite side of the maze, then you'd use something like
Code:with all if place_meeting(x,y,other.id) { if median(x,maze_left,maze_right) != x { x = other.myPair.x + hspeed; y = other.myPair.y; } else if median(y,maze_top,maze_bottom) != y { x = other.myPair.x; y = other.myPair.y + hspeed; } }
maze_left = 256;
maze_right = 1344;
maze_top = 32;
maze_bottom = 1216;
maze_width = 896;
maze_height =992;
ima assume they didn't notify you yetI know, those are the coordinates of the very edges of the maze.
OK so I changed the boarders from Objects to Tiles and ran the program for a test and I got the same result from before except it's with Pac as you can seeYeah, what Nido said. What's obj_Boarder? lol Probably hast to do with the "with all"...but that means obj_Boarder, whatever it is, is actually overlapping obj_Warp_Tunnel. The sprite for obj_Warp_Tunnel should be just the right size so it fits inside the tunnel without touching anything so that only Pac-Man and the ghosts can ever touch it.
with all if place_meeting(x,y,other.id) {
if median(x,maze_left,maze_right) != x
x += maze_width * sign(hspeed);
else
if median(y,maze_top,maze_bottom) != y
y += maze_height * sign(vspeed);
}
maze_left = 256;
maze_right = 1344;
maze_top = 32;
maze_bottom = 1216;
maze_width = 896;
maze_height =992;
now these errors are occurring. I tried to fix it by putting in what it was asking for but it's still not workingMake maze_left through maze_height macros. It should be a simple change (don't use any punctuation):
#macro maze_left = 256
#macro maze_right = 1344
#macro maze_top = 32
#macro maze_bottom = 1216
#macro maze_width = 896
#macro maze_height = 992
Since those numbers will be "hard-coded", there is no point making them be variables. By declaring them as macros like this, the game will replace all references of maze_left with 256, maze_right with 1344, and so on.
End Stepshow your code
with all if place_meeting(x,y,other.id) {
if median(x,maze_left,maze_right) != x
x += maze_width * sign(hspeed);
else
if median(y,maze_top,maze_bottom) != y
y += maze_height * sign(vspeed);
}
#macro maze_left = 256
#macro maze_right = 1344
#macro maze_top = 32
#macro maze_bottom = 1216
#macro maze_width = 896
#macro maze_height = 992
You're absolutely right, I should've remembered that.You don't use = in macro definitions. Check the help file.
Yeah, Tried to make the coordinates for the edge of the maze smaller, that didn't work.I tried to swap all the coordinates around with Left's being Right's and Top's being Bottom's and so on, that didn't work. I moved the Warps closer to the tunnel end as well as the coordinates, that didn't work. I don't exactly know what to do because all the Warp Tunnel is doing is send Pac and the ghosts right outside the screen.OK now it's working but the end step code still needs tweaking, all it's doing is shooting Pac and the ghosts to the far edge of the room instead of to the other warp tunnel.
with all if place_meeting(x,y,other.id) {
if median(x,maze_left,maze_right) != x
x += maze_width * sign(hspeed);
else
if median(y,maze_top,maze_bottom) != y
y += maze_height * sign(vspeed);
}
#macro maze_left 256
#macro maze_right 1344
#macro maze_top 32
#macro maze_bottom 1216
#macro maze_width 896
#macro maze_height 992
OK so I figured out the solution... I just had to add a - to the Maze_width... why is it always the minus sign??The only variable that would make it do that is maze_width, which should be the distance from where your pink arrow is to just left of where your X is in that picture.
if audio_play_sound(Pac_Man_Eat_1,10,0)
else
if audio_play_sound(Pac_Man_Eat_2,10,0)
if instance_destroy() audio_play_sound(Pac_Man_Eat_1,10,0)
else if instance_destroy() audio_play_sound(Pac_Man_Eat_2,10,0)
So with that out of the way I wanna try to tackle the idea of Pacs as or Bots. you mentioned that they can pretty much have the same line of code as the ghosts right? All i have to do is add a code that would have them avoid the ghost until a power pellet is active and can start chasing them?The only variable that would make it do that is maze_width, which should be the distance from where your pink arrow is to just left of where your X is in that picture.
Yes, if you want the AI to actually chase the ghost. (You could make an AI that aims for ghosts when it has the power pellet and make a different AI that treats pellets as just an invincibility token and uses that time to just continue getting normal pills instead of aiming for points).So with that out of the way I wanna try to tackle the idea of Pacs as or Bots. you mentioned that they can pretty much have the same line of code as the ghosts right? All i have to do is add a code that would have them avoid the ghost until a power pellet is active and can start chasing them?
So I just realized that if I'd want the AI thing to work we need the ghosts to turn blue and we don't have that done yet. I think I wanna get that done first as well as other functions for the ghost before moving on to the Pac AIs. so where do I begin with the Power Pellet effect?Yes, if you want the AI to actually chase the ghost. (You could make an AI that aims for ghosts when it has the power pellet and make a different AI that treats pellets as just an invincibility token and uses that time to just continue getting normal pills instead of aiming for points).
You'll want multiple AI goals for handling Pacman AI movement. For example, you probably wouldn't want him running to a power pellet right away, so if his current route puts him on a collision course with a power pellet, you'd want him to look for an alternate route. Since Pac-man can change direction at any time, unlike ghosts, you might want some form of motion planning. For example, maybe calculate a path for 8 or 16 cells and save the direction he plans to go in each of those cells to an array, then attempt to loop through the array as long as no ghosts are coming for him. If Pac-man AI detects a ghost coming for him, clear the array and calculate a new path.
Ghosts have very simple AI. Since Pac-man's AI would want to simulate human movement, it's much more difficult to program. So yes, the coding methods will be about the same as with the ghosts, but it will take a lot more planning.
Hey sorry to bother but I was just wondering if you're still gonna help me out with the coding?Yes, if you want the AI to actually chase the ghost. (You could make an AI that aims for ghosts when it has the power pellet and make a different AI that treats pellets as just an invincibility token and uses that time to just continue getting normal pills instead of aiming for points).
You'll want multiple AI goals for handling Pacman AI movement. For example, you probably wouldn't want him running to a power pellet right away, so if his current route puts him on a collision course with a power pellet, you'd want him to look for an alternate route. Since Pac-man can change direction at any time, unlike ghosts, you might want some form of motion planning. For example, maybe calculate a path for 8 or 16 cells and save the direction he plans to go in each of those cells to an array, then attempt to loop through the array as long as no ghosts are coming for him. If Pac-man AI detects a ghost coming for him, clear the array and calculate a new path.
Ghosts have very simple AI. Since Pac-man's AI would want to simulate human movement, it's much more difficult to program. So yes, the coding methods will be about the same as with the ghosts, but it will take a lot more planning.
I understand. Thank you for all the help you provided me through the thread. And if anything I hope you're interested in the progress once i post some.Figuring out the AI is the job of the programmer. We have been giving you the basics for the AI for a ghost. Anything beyond that is up to you. This thread is as long as it is because, as far as most of the people that have been following it with us can tell, I've been practically writing your entire program for you. And maybe a couple other people near the beginning. Mama bird has to push the chick out of the nest at some point.