This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.
  • Index
  •  » Show and tell
  •  » My Pacman clone - development stage one - plz post comments!!

#1 2010-07-10 23:12:12

Locomule
Scratcher
Registered: 2009-08-24
Posts: 500+

My Pacman clone - development stage one - plz post comments!!

download here

Far from finished, this clone goes as far as to include hand drawn-to-scale copies of the original graphics, a tile-based mapping system that will eventually be used to emulate the ai or behavioral characteristics of the original ghosts.

**IMPORTANT**
The first run or first time you press the green flag, you must wait while the list TileData is generated. Afterwords, hide the list from your screen so it will run faster.

btw, you use the arrow keys to move around, of course  smile
I started this after other people mentioned Pacman and the ghost AI in other forum posts. I found an excellent page on the internet...
The Pac-Man Dossier
... that goes into amazing detail on the workings and history of the original game. I had no idea what a piece of genius this was from the guts out.. till now!

edited: right after I uploaded this, I thought of how to make it auto toggle the tile list not to reload after the first run. I also added a warp feature to the tunnels.

Last edited by Locomule (2010-07-10 23:50:52)


aka Pain from DragonSpires, Delrith Online, BotBattle, Urban Dead etc etc lol

Offline

 

#2 2010-07-11 02:25:42

Jonathanpb
Scratcher
Registered: 2008-07-25
Posts: 1000+

Re: My Pacman clone - development stage one - plz post comments!!

It's brilliant!  big_smile

I expect your version of Pacman to be the best. Keep working on it!  smile


"Human beings... must have action; and they will make it if they cannot find it.
-Charlotte Brontë

Offline

 

#3 2010-07-11 11:49:25

Locomule
Scratcher
Registered: 2009-08-24
Posts: 500+

Re: My Pacman clone - development stage one - plz post comments!!

Thanks a lot for commenting! I'm still undecided on whether or not I can squeeze all the AI into a Scratch project that still runs fast enough to work. But I am learning a lot about optimizing code structure on this project for sure which is great cause I tend to be slightly sloppy. It's looking like I will have to break each sprite's AI into broadcast-called for subroutines. Otherwise I have so many nested blocks that it takes 5 minutes just to edit a single script block's data field.


aka Pain from DragonSpires, Delrith Online, BotBattle, Urban Dead etc etc lol

Offline

 

#4 2010-07-11 12:03:30

coolstuff
Community Moderator
Registered: 2008-03-06
Posts: 1000+

Re: My Pacman clone - development stage one - plz post comments!!

That's spectacular! I'm a little bit curious as to how you plan on doing the AI, though...

Offline

 

#5 2010-07-11 12:04:44

archmage
Scratcher
Registered: 2007-05-18
Posts: 1000+

Re: My Pacman clone - development stage one - plz post comments!!

This should be doable in scratch, the arcade machine at the time was also not very powerful.

Here is what I think you should work on and in what order. Really, I think the ghosts are the only hard part of making this.

-Making the game without ghosts as close to the real thing as possible
-The game is made up of tiles, so you must force pacman and the ghosts to identify what tiles they are in
-Begin making the ghosts with a blinky type chase behavior since it is easiest. Blinky will always target pacman's tile if he is in chase mode.
-Work on the other modes for the blinky type ghosts, scatter, and frightened
-When blinky's AI is perfected, work on the AI for the other ghosts


Hi, I am Archmage coder extraordinaire. I do Scratch,pascal,java,php,html, AS2 and AS3. Leave me a message if you want coding advice. Also check out my personal website, lots of good stuff about web development, Flash, and Scratch (v1 and v2) !

Offline

 

#6 2010-07-11 12:12:22

archmage
Scratcher
Registered: 2007-05-18
Posts: 1000+

Re: My Pacman clone - development stage one - plz post comments!!

coolstuff wrote:

That's spectacular! I'm a little bit curious as to how you plan on doing the AI, though...

The link in the first post is interesting, it outline the precise behavior of the ghosts. It was probably made by pacman pros to teach people how to manipulate the ghosts. If one copies the exact behaviors as outlined in that article, it should come out fine.


Hi, I am Archmage coder extraordinaire. I do Scratch,pascal,java,php,html, AS2 and AS3. Leave me a message if you want coding advice. Also check out my personal website, lots of good stuff about web development, Flash, and Scratch (v1 and v2) !

Offline

 

#7 2010-07-11 12:33:32

Cnor
Scratcher
Registered: 2010-01-29
Posts: 1000+

Re: My Pacman clone - development stage one - plz post comments!!

Cool, I hope you finish and don't give up as it looks like it will turn into a very very good game.


See that post up there ^^^
That post was done by me  wink

Offline

 

#8 2010-07-11 12:46:22

Locomule
Scratcher
Registered: 2009-08-24
Posts: 500+

Re: My Pacman clone - development stage one - plz post comments!!

Thanks everyone and good call Archmage ("the Psychic"), I was up till 4:30 am last night/ this morning working on Blinky's Scatter script. (just uploaded new version btw) He finally ran into his corner and I crashed. I had already hit that "up too late - stupid phase" where you go back later and fix huge blocks by inverting a "greater than" into a "less than" lol.


I was programing each mode in a nested if/else block. Then each mode must be broken into another nested if/else block based on which of 4 directions the ghost is currently moving. That is ghost AI in a nutshell, you can get it working and then go back and tweak the logic to make it right. Most of the nfo is at the Pacman Dossier but naturally, the more you code the more you end up improvising. Like exactly which corner tile Blinky's target sprite goes to in Scatter, which way he turns when going down and left if in chase mode and the target tile is farther away on the X axis than the Y, etc, etc.
Of course the end result is a Scratch that is already lagging so badly while editing, I am having to pull blocks apart and even then it kinda sucks.

So now I'm faced with backtracking and (I guess) splitting the nests into separate, broadcast-called and variable switched on/off script blocks. At least then I could get back to editing without all the insane lag. Either that or just continue by copying sections, working on them unattached and then sticking them back in.

And now I see why Archmage's "order" post is so vital!! Sorry, I'm old and been doing this kinda stuff forever but I'm still a newbie around here compared to you guys, obviously. Plus I'm on dial-up so all my scripts so far have been small for my own uploading convenience.  tongue  Another problem with continuing in the "copy and nest" thing I'm doing now is I still have a ton of things to go back and add, from messages to fruit, dot "eating", costume changes, blah, blah.

So thanks so much everyone for the posts, information, and encouragement. Keep the suggestions coming please!! Lol, in the meantime, I'm gonna modem-crawl/search through old forum posts about 'optimizing' type strategies.

Last edited by Locomule (2010-07-11 13:06:36)


aka Pain from DragonSpires, Delrith Online, BotBattle, Urban Dead etc etc lol

Offline

 

#9 2010-07-11 14:39:17

archmage
Scratcher
Registered: 2007-05-18
Posts: 1000+

Re: My Pacman clone - development stage one - plz post comments!!

I haven't been able to properly look through your code but it seems like you have way to much redundant code. Most of the stuff in the pacman sprite looks the same.

From just looking around, it seems that your biggest issue is working with tiles. Most of the huge pacman script seems to be checking for collisions and it looks very improvised.

What you really need to work on now is making pacman's collisions with tiles perfect, don't even bother with the ghosts yet. Unfortunately, scratch is not very well equipped to handle tiles, but it is possible.

There hasn't been a lot of discussion on the scratch site on how to deal with tiles which is unfortunate for you because that is exactly what you need.

Since tiles are essential for many classic games (most snes/nintendo games used tiles) there are quite a few tutorials on the web explaining how to make games with tiles. From what I found, most tutorials explain how to do things using flash, so you can try to figure out the flash code, which won't be difficult if you have other real programming experience.

http://www.tonypa.pri.ee/tbw/tut05.html
This link is useful because it explains how to have a character move though a tile map efficiently which is what you badly need.

What I recommend for now is trying to get a perfectly working tile system without ghosts. Like I said before, the first thing you need to do is get the game fully playable without the ghosts, which includes the dots, fruits, collisions, the tunnel and other small things.

Last edited by archmage (2010-07-11 14:40:00)


Hi, I am Archmage coder extraordinaire. I do Scratch,pascal,java,php,html, AS2 and AS3. Leave me a message if you want coding advice. Also check out my personal website, lots of good stuff about web development, Flash, and Scratch (v1 and v2) !

Offline

 

#10 2010-07-11 20:01:40

Locomule
Scratcher
Registered: 2009-08-24
Posts: 500+

Re: My Pacman clone - development stage one - plz post comments!!

Had a moment so here are some thoughts...

Part of my problem is my effort to stick as closely as possible to the original, maybe that is something I need to get over? Another is my personal copncept of 'redundancy' in programing. I say that because I always considered code redundant if it was run in multiple, unnecessary repetitions during the same game cycle. So I was never really worried before about the overall size of my code, or that a bigger chunk of script alone would lag my interpreter/compiler/ etc until now. In fact, I have had a habit of getting crazy with the cheese wiz with complex subroutines, often having nested routines that contain exact copies of large chunks of an earlier routines, done just to save wasting a game cycle to get back. Right now the only compromise I can see is things like adding a specific routine to get the states (blocked or not) of all Pacs surrounding tiles to use that data for all the if/elses. It won't actually save me overhead per cycle I don't think but it will drastically reduce the size of my script block.

One of the things I envisioned was recreating the same sort of thinking in my code as in the original with a vision of a finished game where everything appeared to work just like the original. Your comments make me wonder if it wouldn't be better if not just flat out necessary to refine different routines instead of copying the original routines so closely.

I already have Pacman running nicely with apparently one minor bauble. You mentioned collision detection. The original, being a tile-based game, doesn't use collision detection per say. Pacman and a ghost only hit when they occupy the same tile. And none of the sprites check for collisions, they simply follow the programed paths of walk or don't walk according to the way the map data is programmed (in my TileData list)

In my opinion, the ghost AI will be the hardest thing to do correctly. I guess the benefit of my bloated but otherwise working current method is that it works basically just like the original. So naturally the AI scripts produce great results as far as copying original ghost behaviors.

From the limited Scatter mode coding I've done for Blinky here is why my ghost code is so redundant...

Ghosts must have 3 sets of AI, one for each mode 1. Chase 2. Scatter 3. Frightened
For each set, the ghost must have separate instructions depending on which direction the target tile/sprite is at that moment (that is 4 sets) and then each of those sets must include instructions for how to choose a new path at an intersection.
That is the only way I could figure out to 'program' the AI so to speak. So I guess I need to do the same thing here as in Pac's script.

Anyway, I will work on Pac and pull Blinky out of the mix for now, then start on the other stuff like you said. May have to do more backtracking than I'd like but oh well.

ps. thanks for that awesome link!! I used to play/map/run some tile-based online rpg stuff...

uh oh, can't resist an obscure shoutout...

Pain says Dragonspires and Delrith Online to win 4ever!!!

Last edited by Locomule (2010-07-11 20:05:36)


aka Pain from DragonSpires, Delrith Online, BotBattle, Urban Dead etc etc lol

Offline

 
  • Index
  •  » Show and tell
  •  » My Pacman clone - development stage one - plz post comments!!

Board footer