PacFish
by Gary Preston · in Torque Game Builder · 04/05/2005 (11:41 am) · 16 replies
Having played around with the particle editor and tile map editor for a short while, I decided to make a small game to get used to things. I thought a pacman clone would go down well for a tile based game. Since its a nice small game and pretty simple gameplay, I could concentrate on learning t2d whilst making it :)
It's not really finished in that its using my "programmer art" which a 2 year old could probably do a better job of :P Plus a host of other features, not to mention its only got 2 levels that loop..... Theres also a slight bug in the movement code that I really could do with fixing. However, since I've thought of a better way to code that in the future and this was really just made through playing with the tile editor, I doubt I'll get round to it.
This is a private release for t2d peeps only, mainly because it needs a lot more work before I'd consider a public release (especially the graphics :P).
Anyhow, enjoy.
Download PacFish.rar - windows only, sorry.. I don't have linux installed at the moment to compile the exe on.
It's not really finished in that its using my "programmer art" which a 2 year old could probably do a better job of :P Plus a host of other features, not to mention its only got 2 levels that loop..... Theres also a slight bug in the movement code that I really could do with fixing. However, since I've thought of a better way to code that in the future and this was really just made through playing with the tile editor, I doubt I'll get round to it.
This is a private release for t2d peeps only, mainly because it needs a lot more work before I'd consider a public release (especially the graphics :P).
Anyhow, enjoy.
Download PacFish.rar - windows only, sorry.. I don't have linux installed at the moment to compile the exe on.
#2
I've been starting on a pacman clone myself, to learn T2D basics. However, I'm not sure how to go about with pathfinding AI. It's going to be challenging. Pacman had different pathfinding for each ghost. I wonder how many of those T2D is capable of reproducing. (I'm also doing this to learn about pathfinding, as I'd never done it before.)
04/06/2005 (2:07 am)
Hahah I liked the music you put in it. Also, was it just me, or did winning a level make the window itself shake? Pretty cool stuff. I'd also like to know how you got everything into a DAT file.I've been starting on a pacman clone myself, to learn T2D basics. However, I'm not sure how to go about with pathfinding AI. It's going to be challenging. Pacman had different pathfinding for each ghost. I wonder how many of those T2D is capable of reproducing. (I'm also doing this to learn about pathfinding, as I'd never done it before.)
#3
As for pathfinding, it wasn't really the main goal of this demo, so I more or less wimped out on it. The entire "ghost" movement is semi random. If they hit a wall they pick a new direction to move, with a percentage chance that they will change axis. If they're travelling along a wall and a gap is approaching, there is a small chance they'll move into it.
04/06/2005 (3:34 am)
The dat files are really just .zip files renamed (just needs 2 lines changing in the engine to load .dat instead of .zip). I got the idea from someone else who posted on here :P For some reason the tile map and particle effects wouldn't load from within the zip file though. As for pathfinding, it wasn't really the main goal of this demo, so I more or less wimped out on it. The entire "ghost" movement is semi random. If they hit a wall they pick a new direction to move, with a percentage chance that they will change axis. If they're travelling along a wall and a gap is approaching, there is a small chance they'll move into it.
#4
I haven't coded a game since I was 12 (I'm 25 now). I've mainly focused on art. So pathfinding is a real mystery to me. I'm sure I can find even pacman specific pathfinding resources. But I'm not sure if it's possible to reproduce using T2D without touching anything but script.
04/06/2005 (11:29 am)
Yeah, it looked random to me. But that's still much further than I've gotten with pathfinding :).I haven't coded a game since I was 12 (I'm 25 now). I've mainly focused on art. So pathfinding is a real mystery to me. I'm sure I can find even pacman specific pathfinding resources. But I'm not sure if it's possible to reproduce using T2D without touching anything but script.
#5
BTW, the gfx are still better than what I seem to come up with.
04/09/2005 (2:08 pm)
Well, the original Pacman only had ONE level layout(multiple levels weren't implemented until Ms. PacMan). I also believe it didn't use true pathfinding, instead the ghosts all had a pattern they'd move to. You're not as far off from the real game as you might think :) BTW, the gfx are still better than what I seem to come up with.
#6
One thing that might be nice would be to reset the player's direction after death as the original PacMan did. I noticed that when I respawned, I was going the same direction as when I died which could be interesting or unexpected depending on how well the round is going :^)
I liked the effects, especially the power-pellet effect.
Looks inspiring to us n00b T2D people!!
Mike
04/10/2005 (9:51 am)
The music is catchy!One thing that might be nice would be to reset the player's direction after death as the original PacMan did. I noticed that when I respawned, I was going the same direction as when I died which could be interesting or unexpected depending on how well the round is going :^)
I liked the effects, especially the power-pellet effect.
Looks inspiring to us n00b T2D people!!
Mike
#7
I think later versions may have added some sort of convergance code that got smarter each level. It may have just been that the higher level designs offered fewer escape paths for the player. I just remember being able to play the original forever, but having no luck with Ms. Pacman and the rest of the clones.
04/10/2005 (1:11 pm)
The original Pacman didn't have any form of pathfinding code at all. When a ghost reached a wall, it would pick a random direction, excluding the direction it came from. The only difference in the ghosts was their speed. I think later versions may have added some sort of convergance code that got smarter each level. It may have just been that the higher level designs offered fewer escape paths for the player. I just remember being able to play the original forever, but having no luck with Ms. Pacman and the rest of the clones.
#8
04/11/2005 (9:50 am)
The best pac-style game-play I had in a long while!:) Very nice!:)
#9
The game is pretty fun, nice work!
04/11/2005 (9:51 pm)
@ terry IIRC the enemies in the original pacman had 4 different "personalities", although I can't remember what they were it was some simple rules, like one would pick a random direction, another would go towards the player, etc... I think I read it on gamasutra somewhere although don't quote me on that.The game is pretty fun, nice work!
#10
On another note, I installed linux the other day and now have pacfish running under that as well :) I'll upload a tgz file later.
I'm really tempted to expand the game a little more and work on better graphics, but at the same time I'd like to move onto to making a more original game now. So I doubt they'll be any updates to this, but then again you never know. It was afterall just a quick game made to test some T2D concepts :)
04/12/2005 (4:03 am)
Details on the original pacman can be found on the wikipedia Makes intresting reading, especially the $100,000 dollar prize that finished in 2000.On another note, I installed linux the other day and now have pacfish running under that as well :) I'll upload a tgz file later.
I'm really tempted to expand the game a little more and work on better graphics, but at the same time I'd like to move onto to making a more original game now. So I doubt they'll be any updates to this, but then again you never know. It was afterall just a quick game made to test some T2D concepts :)
#11
@Alex: Yup, looks like my memory is even worse now than I thought it was :-)
I did a couple of ports/optimizations for Atari (computer side, not console) while I was in college in the early 80's. Pacman wasn't one of them, but for some reason I remember having a printout of the 6502 machine code that was dumped from the cartridge. I probably altered it to slow the ghosts down, which would explain why I could play it well :-)
I did the port of Q*Bert to the Atari, but it never made it to market. Damn shame too, 'cause it took me weeks to get a halfway decent version of the PLONK sound he made when he died. In the arcade version, it was an actuator popping the wooden side of the console. All I had was an 8 bit sound chip and 2 inch speaker :-)
04/12/2005 (5:36 am)
@Gary: Great link!@Alex: Yup, looks like my memory is even worse now than I thought it was :-)
I did a couple of ports/optimizations for Atari (computer side, not console) while I was in college in the early 80's. Pacman wasn't one of them, but for some reason I remember having a printout of the 6502 machine code that was dumped from the cartridge. I probably altered it to slow the ghosts down, which would explain why I could play it well :-)
I did the port of Q*Bert to the Atari, but it never made it to market. Damn shame too, 'cause it took me weeks to get a halfway decent version of the PLONK sound he made when he died. In the arcade version, it was an actuator popping the wooden side of the console. All I had was an 8 bit sound chip and 2 inch speaker :-)
#12
04/12/2005 (6:36 am)
@gary: Thanks, thats what I was thinking of :) I can't believe someone offered $100000 to finish pacman!
#13
Hah! I didn't know that plonk sound was a physical object hitting another. And about Pacman... it's crazy they published a prototype. I hope they had SOMEONE optimize it.
@Gary
I'm making a game that has some pacman elements. For movement, I restricted the character's position by making the character's collision box the exact size of the gap. It's not working well at all. However, playing your game, I'm quite sure you didn't do that. It looks like you set the character to go from point A to point B. Is this right?
04/12/2005 (8:33 am)
@TerryHah! I didn't know that plonk sound was a physical object hitting another. And about Pacman... it's crazy they published a prototype. I hope they had SOMEONE optimize it.
@Gary
I'm making a game that has some pacman elements. For movement, I restricted the character's position by making the character's collision box the exact size of the gap. It's not working well at all. However, playing your game, I'm quite sure you didn't do that. It looks like you set the character to go from point A to point B. Is this right?
#14
@David: The way I did movement feels like a bit of a hack to be honest. The map is made up of a set of tiles. Each wall element fills an entire tile even though the image only fills 3/4 of the tile.
I set the pacmans collision box to be 0.95 so that it was just a little bit smaller than a full tile, which allows it to fit through gaps. However, if you change axis from horizontal to vertical, it can only fit through a gap if the pacman is exactly in the center of the current tile. Otherwise there is a good chance one side of the pacman will collide with the wall.
So if the player is currently moving left and presses/holds the up key, I set a moveDir to up.
In the fxUpdateScene I check if curDir != movedir (which it now won't as current dir may be left, where as movedir is now up. indicating the player is trying to change direction)
I then check whether the tile above the players current tile is walkable (that is, its not a wall). Where the current tile is defined as the tile within which the players center resides, just in case we're overlapping tiles. If it isn't walkable we do nothing and the player continues moving left. The moment we enter a tile that has a walkable tile above it though, we'll pass the check.
At this point we still can't just set the linearvelocityX to 0 and Y to our new speed, since the pacman won't fit through the gap. So I cheat a little. I mount the player on the center of the current tile.
Now the player will move smoothly to the exact center of the tile, (there is probably a much nicer way to do this though by using a moveto function that takes into account the current speed and the distance you want to move.) We now just keep checking to see whether the player has reached the center of the tile. I check each frame whether the players current position is within 0.2 of the tiles center and if so, I just set the players position to the tile center. This snap isn't noticable to the player and avoids the final deceleration that the move to mount uses. We now just unmount the player and apply the correct x/y velocities.
The above sounds a lot more complicated than it really is. However its not really an ideal solution. You could probably avoid mounts by doing the checks each frame and snapping once the player is as close as they're going to get to the center. So long as you take into account the players speed to make sure you don't go one frame too many and overshoot the target. Or you might be able to do some sort of tweening of the players movement to allow a moveTo function to be used, this would be the ideal solution.
So thats how I hacked my way around fitting the pacman into a gap :) It was only a problem when travelling horizontal and trying the move up into a gap. If the pacman had first hit a wall going left, he would have had his position set to the tile center anyway, so changing to a vertical movement would then have been trivial.
Hope that helps.
04/12/2005 (12:58 pm)
@alex it amazed me as well. I guess they were pretty certain that nobody would manage to complete the split screen level :)@David: The way I did movement feels like a bit of a hack to be honest. The map is made up of a set of tiles. Each wall element fills an entire tile even though the image only fills 3/4 of the tile.
I set the pacmans collision box to be 0.95 so that it was just a little bit smaller than a full tile, which allows it to fit through gaps. However, if you change axis from horizontal to vertical, it can only fit through a gap if the pacman is exactly in the center of the current tile. Otherwise there is a good chance one side of the pacman will collide with the wall.
So if the player is currently moving left and presses/holds the up key, I set a moveDir to up.
In the fxUpdateScene I check if curDir != movedir (which it now won't as current dir may be left, where as movedir is now up. indicating the player is trying to change direction)
I then check whether the tile above the players current tile is walkable (that is, its not a wall). Where the current tile is defined as the tile within which the players center resides, just in case we're overlapping tiles. If it isn't walkable we do nothing and the player continues moving left. The moment we enter a tile that has a walkable tile above it though, we'll pass the check.
At this point we still can't just set the linearvelocityX to 0 and Y to our new speed, since the pacman won't fit through the gap. So I cheat a little. I mount the player on the center of the current tile.
Now the player will move smoothly to the exact center of the tile, (there is probably a much nicer way to do this though by using a moveto function that takes into account the current speed and the distance you want to move.) We now just keep checking to see whether the player has reached the center of the tile. I check each frame whether the players current position is within 0.2 of the tiles center and if so, I just set the players position to the tile center. This snap isn't noticable to the player and avoids the final deceleration that the move to mount uses. We now just unmount the player and apply the correct x/y velocities.
The above sounds a lot more complicated than it really is. However its not really an ideal solution. You could probably avoid mounts by doing the checks each frame and snapping once the player is as close as they're going to get to the center. So long as you take into account the players speed to make sure you don't go one frame too many and overshoot the target. Or you might be able to do some sort of tweening of the players movement to allow a moveTo function to be used, this would be the ideal solution.
So thats how I hacked my way around fitting the pacman into a gap :) It was only a problem when travelling horizontal and trying the move up into a gap. If the pacman had first hit a wall going left, he would have had his position set to the tile center anyway, so changing to a vertical movement would then have been trivial.
Hope that helps.
#15
04/12/2005 (4:44 pm)
@gary: Thanks, thats what I was thinking of :) I can't believe someone offered $100000 to finish pacman!
#16
He prob. won a ton from the competition, promotions, etc. that $100,000 was pocket change.
04/12/2005 (11:10 pm)
I can, it was the world champion at Pacman that offered and he was simply proving he was the best there was. No one could get as high as he did (which was up to the Split Screen Level) and beat it, therefore he wins. :)He prob. won a ton from the competition, promotions, etc. that $100,000 was pocket change.
Torque Owner Chris Newman
Cool game too.