This is an overdue post about how to make a PacMan project in Scratch. It is intended purely for educational purposes, as are most of my projects. You can find my unfinished but working PacMan project here... pacman002 but please download it and run it in turbo mode for best usage.
I recreated the original game screen to scale.
Each tile is 8x8 pixels. The entire screen is 28 tiles wide by 36 tiles tall. That is a total of 1008 tiles. But keep in mind, that includes the black areas 'outside' the map as well. That also makes the entire screen 224 x 288 pixels.
You MUST check out the following page if you are serious about understanding/recreating the original gameplay.
http://home.comcast.net/~jpittman2/pacman/pacmandossier.html
Well, you could do a great job of faking it in Scratch using typical Scratch methods, no doubt. But in my opinion, in the long run, if your goal is to clone the original, it will actually be harder to do if you don't use a tile system.
The original game's ghost AI is governed entirely by targeting tiles around PacMan when in Chase mode. The behavior of each ghost is based on how closely each one is allowed to target PacMan. As I mentioned before, collisions occur when 2 sprites occupy the same tile. Each map tile is recorded into memory as either 1) blocks movement or 2) allows movement.
So as you can see, the tile system governs all aspects of game play. There are additional aspects that are not so readily visible. For example, the PacMan uses a special movement feature called "cornering" that allows him to move diagonally around corners. It happens so fast, most people never notice it. This is an important element of gameplay because it gives the player an edge over the ghosts by taking many turns instead of traveling in straight lines.
I watched a video of the original PacMan to see for myself and sure enough, it happens. Another thing I noticed is that even in the original game, Pacman does NOT have 'perfect' movement through the maze. By that, I mean that he is not sized to fit exactly through the maze paths, instead having some pixels worth of distance between him and the maze walls. By imperfect I mean that if you enter and stop moving in the same maze corner from two different directions, he will stop at different places.
But a big part of the game-play is the fast movement and non-stop action so the player stays so busy, they don't notice these things. Working on this project really blew my mind and now I have a ton of respect for the genius of its creator as well as his elegantly simple methods of making it all work. That page I mentioned goes into his history, the development of the game, and all this other stuff in great detail. It is worth reading even if you never intend to make your own PacMan, inspiring stuff!
As for my version, try it (download it) and you can see that I have some of these features implemented. I planned to "cheat" on the dot-eating by stamping over the dots which are drawn onto the background map instead of using sprites. There are a lot of dots! I started on the red ghost's scatter AI but did not finish it and it is currently disabled. I did get PacMan running pretty well, including the cornering feature. However, I later realized that in the real game, PacMan can only anticipate corners from a short distance away whereas mine can currently anticipate them as soon as it makes the turn before it. By anticipate, I mean the player can be going one direction, press an arrow for the next turn and PacMan will continue going straight but will turn automatically when it gets to the next corner.
I also use a long list to store the tile blocks/doesn't block data. Since Scratch will remember saved list data, it is automatically stored in the current project. I also cheated by drawing the maze into the background rather than having the project assemble the screen from a small selection of graphic tiles, as had to be done in the original. Obviously, I have used Scratch's native capabilities in some ways while using the original PacMan game's features (the tile system) to make sure that the whole thing plays and feels correct.
One reason I have stopped working on this is because I have since been told that my scripting methods, specifically using Forever loops as opposed to broadcasting, are slowing down the project. It currently works best in Turbo mode but that messes up costume changes. If I were to continue this, I would re-write everything again using broadcasts to see if I could speed it up enough to run in Normal stepping mode instead of Turbo.
Hope this helps people out I always intended to make this post and recent Namco-related circumstances have lead me to believe that it is vital. Apparently, some people think that we just wanna play PacMan for free at Scratch. Which is ridiculous because you can download and play the original game with all it's features for free elsewhere. I personally have yet to see a Scratch version that comes close to fully emulating the original. Obviously, I support using this milestone in computer gaming as a method to teach new generations computer programing, which I believe is in line with the whole philosophy behind Scratch in the first place. And I am 39 years old so if Namco should decide to ban my version, I will not give up without a fight unless the Scratch Team itself recommends it which from what I have read so far, they do not. There is far more at stake here than what Namco seems to want us to believe. Peace.
Offline
Ooh, nice guide! Full of chunky text... but a lot of your posts are like that.
Offline
Yeah, sorry about that. My grammar is definitely sub-par. And I spent so much time writing that, I didn't go back and edit. But in hindsight, as a teen, I often woke up holding my guitar but never my English book, go figure.
Last edited by Locomule (2010-08-15 01:47:34)
Offline
We'll see! Lol, thanks. I'll be the first to admit, I have reservations about this whole deal. But to me it seems like Namco is taking a very skewed point of view to this whole deal. Scratch is NOT a gaming site. It is an educational site. And personally, I have felt for a long time now that companies seriously need to change their profit strategies and copy-wright stances to reflect the reality of a world in which data/information transfers are mundane and old-hat. Expecting people to ignore what is now a way of life demonstrates corporate ignorance and bullheadedness. It also hampers future successful business models and as we have recently discovered, the education of our youth. But I could always be wrong. If the Scratch team changes its' mind and decides this is bad business, I will drop it like it is hot.
Last edited by Locomule (2010-08-15 02:31:36)
Offline
I've heard about Prism's PacMan but have not checked into it. I did mine more or less on a whim after finding the PacMan Dossier site, before all the Namco silliness went down. But I do remember reading a post from someone in Prism mentioning that they had been working on their version for a while and had it almost complete before the letter from Namco hit Scratch.
I had moved on to other projects but I always intended to write a post like the one at the top. I would like to thank Namco for drawing my attention back to this project and necessitating making this post. I have found it working on my Scratch PacMan project while using the PacMan Dossier site to be incredibly inspirational, as well as educational to both my Scratch scripting and game programing knowledge in general. I hope our fellow Scratcher's will find it to be the same.
ps. no offense intended to anyone associated with Prism btw, I'm just stuck on dial-up and do very little surfing around
Last edited by Locomule (2010-08-15 03:14:08)
Offline
Very nice tutorial! I, if I stop being lazy, may follow it. I have always wanted to make a packman game.
Offline
Thanks. Even if you don't actually make or finish a PacMan game, the project is an excellent example of using a tile-based gaming system. In Scratch, collision detection is commonly handled fairly easily, as long as your sprites move slowly. But moving sprites one pixel at a time is simply too slow for most games. So people commonly end up with sprites that pass through each other before the detection occurs.
A tile system overcomes this problem. As Archmage pointed out elsewhere, Scratch uses "art-based" methods to check for collisions (if sprite touching, if color touching) instead of a method based on data. The tile system is in fact a data-based method although interestingly enough, even it is not foolproof.
As mentioned at the PacMan dossier site, there is a rare but real situation where PacMan can travel through a ghost without getting caught. I believe that you can fix this although it is so rare that most people probably never see it or know about it.
Offline
Yes I have, and I'm siding with the Scratch Team on this issue. Sorry, I thought that I made that clear but I know my posts are wayyy too long.
Offline
henley wrote:
Have you not heard about Namco's immature warning on Scratch? Follow the link in my signature.
Your speech is longer than the takedown notice....maybe that's saying something...
Offline