Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

2D All the way! / Pacman 2D tut

Author
Message
GameMaker Jason
21
Years of Service
User Offline
Joined: 22nd Nov 2003
Location: UK
Posted: 14th Mar 2004 13:46
I would love it if someone could give me a step by step tut on how to make a pacman game using arrays and tiles i would be very happy if some could give me a tut and not abandon half way through like my one in the newcomers corner.

thanx to anyone who helps.

Tapewormz
22
Years of Service
User Offline
Joined: 15th Sep 2002
Location: Winnipeg, Mantoba, Canada
Posted: 14th Mar 2004 22:28
There was a 20 line pacman game I believe. Look at that. Also, try to experiment for yourself. If you can't figure out the whole game, start with elements of the game. Work on your tile system. It's as simple as reading and plotting some data statements using a 2 for next loops. You can then step up from reading and plotting data statements to opening a text file and parsing the data. Then, work on moving your sprites with key/joystick controls. Then figure out the collision routine (very simple because it's basically bounding boxes).
CloseToPerfect
22
Years of Service
User Offline
Joined: 20th Dec 2002
Location: United States
Posted: 15th Mar 2004 04:10
heres a start for you to look at,
no media needed.




RGT may be gone but the best DBP forum is still alive and kicking, check it out.
http://www.dannywartnaby.co.uk/rgt/
GameMaker Jason
21
Years of Service
User Offline
Joined: 22nd Nov 2003
Location: UK
Posted: 16th Mar 2004 18:36
how do i make him move?

Tapewormz
22
Years of Service
User Offline
Joined: 15th Sep 2002
Location: Winnipeg, Mantoba, Canada
Posted: 16th Mar 2004 23:45
My guess from looking at his code is... READ YOUR FRIGGEN MANUAL! Okay, okay...You'll have to write a small scancode (or whatever you perfer) routine using if statements. It's only 4 directions to consider (up, down, left, right). Not very hard at all. Then you check the array to see if the space you're moving into is occupied by a wall or a 1 according to his data statements. If there's an obstruction then your movement is haulted otherwise it increases in the direction that he was moving. Traditionally, pacman would hit a wall and the game would check to see if there was an open path in 3 directions and it would choose that path and continue without stopping.

Break the game down into elements. It's easier to work on it in parts. This is an incredibly simple game to program. The ai for the game isn't very hard at all.
GameMaker Jason
21
Years of Service
User Offline
Joined: 22nd Nov 2003
Location: UK
Posted: 17th Mar 2004 00:00
try not to be so sarcastic I know how to use scancodes but i don't know how to check to see if there is an obstruction and update the array when he moves.

Tapewormz
22
Years of Service
User Offline
Joined: 15th Sep 2002
Location: Winnipeg, Mantoba, Canada
Posted: 17th Mar 2004 00:53 Edited at: 17th Mar 2004 01:35
It's hard not to be sarcastic when ALL of your posts basically beg for code. You never post what you've tried or examples of your code so that we can see where you're stuck. I'm not trying to be a snarky jerkoff, but it is frustrating seeing these kinds of things posted.

Anyways, you don't update the array. He's not moving in the array. You only use the array to check for collisions. Unless he's using the 2's for pellets in which case you have to update the array and change the 2 to a 0 after pacman has moved into that location. pacman himself isn't in that array, or atleast he shouldn't be. Because you don't want him moving in chunky segments, you want him moving smoothly. Also, don't try to scan your array to see how many pellets are left as a method of checking to see if you've completed the level. Use a counter and subtract from the counter everytime he eats a pellet and you update your array.

If you need pacman as a reference, you can get MAME32 by searching google. You can also get the pacman rom by searching irc, or the internet. The copyrights on that particular rom have run out and you're allowed to play it. You can play it and compare your graphics, gameplay or whatever to the original.


For future reference, post what you have using CODE /CODE so we can see where you're stuck and try to be as specific as you can about the problem. Otherwise, you come across as a code begger that doesn't appear as if he wants to learn anything for himself.

BTW: Nice little snipit CloseToPerfect. I never thought of using the built in box and circle commands in my previous example for another user requesting the same thing.
GameMaker Jason
21
Years of Service
User Offline
Joined: 22nd Nov 2003
Location: UK
Posted: 17th Mar 2004 10:06


I know this code i very simaler to the above code but once i can get this to work i will edit it soit looks different.

Pincho Paxton
22
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 17th Mar 2004 11:25 Edited at: 17th Mar 2004 11:25
Pacman does move in chunky segments, but he follows a 2 pixel animation that continues until he reaches 32 pixels. That's if you use an 800*600 screen res.

GameMaker Jason
21
Years of Service
User Offline
Joined: 22nd Nov 2003
Location: UK
Posted: 17th Mar 2004 18:41
how do i accutally move him and delete the pills as he moves?

Pincho Paxton
22
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 17th Mar 2004 20:09
Someone's doing a tutorial, why don't you wait for that? Anyway, you paste a black square over them usually, and you change your array to a zero.

comando 300
21
Years of Service
User Offline
Joined: 23rd Nov 2003
Location:
Posted: 17th Mar 2004 20:11
I'm making one

I delete the pills by doing this

for hidepills=1 to numberofpills
if(pac,hidepills)>0 then hide sprite hidepills
next hidepills

CURRENT PROJECT: RETRO PAC-MAN
GameMaker Jason
21
Years of Service
User Offline
Joined: 22nd Nov 2003
Location: UK
Posted: 17th Mar 2004 20:44
Thanx commando 300 but i am using images for my level


i just need to know how to change a number in an arraywhen pacman move 16 pixels?

also how would i include array collision in my code?

Pincho Paxton
22
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 18th Mar 2004 00:48
Make Pacman move 16 pixels, but 2 pixels at a time...like..

if rightkey()=1
If map(x+1,y) <> 1 .........Look for a wall in the way.
For Pacx = 2 to 16 step 2..move 2 pixels at a time
Sprite 1,pacx,pacy,1

Rem.....In here you need to check for more keystrokes!!!

Next Pacx
inc X .............Here is where the map is updated
Endif
Endif

GameMaker Jason
21
Years of Service
User Offline
Joined: 22nd Nov 2003
Location: UK
Posted: 18th Mar 2004 10:05
This makes my pacman jump to the left of my screen why is this?

Pincho Paxton
22
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 18th Mar 2004 10:27 Edited at: 18th Mar 2004 10:55
Oh sorry it shouldn't be inside a loop like that. It needs to reach your sync, and also update your ghosts. So it should be turned on with a flag.
If WalkUp<>1 or WalkDown<>1 or Walkright<>1.....he can still flip left
if rightkey()=1
If map(x+1,y) <> 1 .........Look for a wall in the way.
WalkRight = 1 .....This turns it on.
Distance = Distance + 16 .....This remembers how far he has walked so far.
Rem It also works if he is walking left, because it adds 16 to whatever he had walked so far.
endif
endif
Endif
If Walkright = 1
Pacx = pacx + 2
Sprite 1,pacx,pacy,1.....You could put this by your sync instead.
Distance = Distance - 2 ....Now the distance is less.
If Distance = 0
walkright = 0...Turn off walking at end.
inc X ....and update the map
Endif
Endif

Oh well, mistakes teach you things. Now you know why some things are in a loop, and others aren't. Also, deleting my comments forces you to read them, so I'm not using REM's.

GameMaker Jason
21
Years of Service
User Offline
Joined: 22nd Nov 2003
Location: UK
Posted: 18th Mar 2004 19:09


This is my code so far could you explain how i would get my sprite to collide with the white boxes?

Pincho Paxton
22
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 18th Mar 2004 23:56
I have already mentioned it in my example. I want you to read what I have put.

Tapewormz
22
Years of Service
User Offline
Joined: 15th Sep 2002
Location: Winnipeg, Mantoba, Canada
Posted: 19th Mar 2004 00:11 Edited at: 19th Mar 2004 00:11
You're wasting your breath Pincho, he doesn't want help... He wants someone to write the source for him so that he can stamp his name on someone else's work. Looking at his past posts, you'll realise this.

But I commend you for trying to help him.
Pincho Paxton
22
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 19th Mar 2004 00:21
Oh well...This part of the code stops him from walking into a wall.

If map(x+1,y) <> 1 .........Look for a wall in the way.

GameMaker Jason
21
Years of Service
User Offline
Joined: 22nd Nov 2003
Location: UK
Posted: 19th Mar 2004 00:36
tapewormz i dont just want source code I wanted the collision bit explained abit more coz i didn't know what it exacly did. btw if i was just code other peoples soucre how come the code i posted wasn't on the forums before that so that mean i wrote the code not samone else.

soapyfish
21
Years of Service
User Offline
Joined: 24th Oct 2003
Location: Yorkshire, England
Posted: 19th Mar 2004 01:10
Maybe its not exactly the same but your still gettin everyone to do your coding then changing small bits to make it look original. Look mate I know it seems like I'm being un-fair and stuff but just look at you questions
Quote: "how do i make him move?"
To everyone else this just looks like you can't be bothered. Just try and word your questions a bit less loosly like "What would be the rough syntax for moving him left" you can then work out how to move him in other directions yourself.

HEY WHY NOT VISIT OUR TEAM SITE!!!
Pincho Paxton
22
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 19th Mar 2004 01:39
You must understand that if I write a tutorial for every line of code, then I could have written ten games in the same amount of time. I was just helping you a bit, but I shall break this line down, and then you must try to start working out the other lines.

If map(x+1,y) <> 1

You know that .... Map is a block of numbers that you have stored.
x is the horizontal line of numbers.
y is the vertical line of numbers.

You are walking to the right so x goes up. If you walk to the left then x goes down. x+1 is to the right. x-1 is to the left. Pacman is looking where he is going! Y+1 is down, y-1 is up.

<> .......this means not equal to.
= ........ Equal to
< ....... Less than
> ......... greater than
<=.........Less than, or equal to
>=.........Greater than, or equal to

If map(x+1,y) <> 1

so..Pacman looks in front of himself, if it's not equal to a wall he can walk right. <> 1

1 is a wall.

Pincho.

Tapewormz
22
Years of Service
User Offline
Joined: 15th Sep 2002
Location: Winnipeg, Mantoba, Canada
Posted: 19th Mar 2004 02:03
I think that's the third time you had to post the answer Pincho. You've a man with children obviously...I don't have that kind of patience myself.
Tapewormz
22
Years of Service
User Offline
Joined: 15th Sep 2002
Location: Winnipeg, Mantoba, Canada
Posted: 19th Mar 2004 02:06
GameMaker Jason, this is good advice...I'm not going to be irritable in this post.

I really suggest that you get some software that will help you design flow charts. Flow charts are something that every programmer should be familiar with. It's a map of your program. It's a visual and logical aid.

You can get programs that will help you design flow charts. You should get a book that will teach you to make them. Then you can break up a program into routines and conquer your game 1 routine at a time. Much easier than trying to tackle the whole thing in 1 sitting.
Pincho Paxton
22
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 19th Mar 2004 09:53
It's been about 15 years since I wrote Pacman. That inc X at the end should probably be at the beginning, I can see it causing a bug.

GameMaker Jason
21
Years of Service
User Offline
Joined: 22nd Nov 2003
Location: UK
Posted: 19th Mar 2004 10:02
I see how it works know and i will be mre specific with my question so it doen't look like im asking for source

Pincho Paxton
22
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 19th Mar 2004 11:27
It needs a WalkLeft = 0 in there as well. Coding without the DB Editor is hard. I am having to imagine what is happening.

GameMaker Jason
21
Years of Service
User Offline
Joined: 22nd Nov 2003
Location: UK
Posted: 19th Mar 2004 19:07


Here i have add your tecnique plus a few extra variable to make it work how would it chnage the passable variable back to 1 when i press the up(down,left,right) keys and the block is passable? ive tried a few thing but also when he walks right he goes strait throught the wall but not when he goes left this bit is confusing. thanx for the help so far.

Pincho Paxton
22
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 19th Mar 2004 19:46
That's not really how my code works. I suggest you keep trying to get my code to work. You code is looking in all 4 directions, and then saying that if one of them is not a wall it is allowed to walk anywhere it wants.

if map(pacmapx,pacmapy+1)<>1 then passable=1 else passable=0
if map(pacmapx,pacmapy-1)<>1 then passable=1 else passable=0
if map(pacmapx+1,pacmapy)<>1 then passable=1 else passable=0
if map(pacmapx-1,pacmapy)<>1 then passable=1 else passable=0

GameMaker Jason
21
Years of Service
User Offline
Joined: 22nd Nov 2003
Location: UK
Posted: 19th Mar 2004 21:48
that doean't solve my prob i know i set it to stop at walls which is what i wanted but it doesn't move afer it has hit a wall could tell me how this could be done (source not required). thanx your a great help

Pincho Paxton
22
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 19th Mar 2004 22:05
Maybe you should follow the Pacman Tutorial instead. You are not really getting anywhere. It's a bit too difficult for you.

GameMaker Jason
21
Years of Service
User Offline
Joined: 22nd Nov 2003
Location: UK
Posted: 20th Mar 2004 00:31 Edited at: 20th Mar 2004 00:32
what do you suggest i try?

Pincho Paxton
22
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 20th Mar 2004 00:40
The Pacman tutorial by Commando 300.

Tapewormz
22
Years of Service
User Offline
Joined: 15th Sep 2002
Location: Winnipeg, Mantoba, Canada
Posted: 23rd Mar 2004 03:35 Edited at: 23rd Mar 2004 03:36
GM Jason,

Check this program out. It's got a free trial. Flowcharts really help you develop programs. You plot out your routines before you even start typing code. It creates a map of what your code is doing, and what decisions it makes and where. This will help you alot by making the processes visual.

http://www.smartdraw.com/index.htm
Tapewormz
22
Years of Service
User Offline
Joined: 15th Sep 2002
Location: Winnipeg, Mantoba, Canada
Posted: 26th Mar 2004 12:31 Edited at: 27th Mar 2004 02:25
Oh, and by the way don't get discouraged if it doesn't work the first time you run it.

Here's a fact about the original Pac-Man game.

Quote: "It took eight people 15 months to complete the original Pac-Man arcade title. Four worked on the hardware, four worked on the software."


Here's another interesting fact.

Quote: "In July of 1999, Florida resident and die-hard Pac-Man fan Billy Mitchell achieved the first perfect score in Pac-Man (3,333,360) after playing for six hours straight. He beat all 256 screens eating every dot, fruit, and ghost (all four ghosts were eaten with each power pellet) - using only one Pac-Man!"


All I can say is...Holy smokes...I couldn't make it to the 3nd round with a perfect score...

Another interesting fact is only the data for 1/2 of the maps were created. They just mirror the map to create the other half. They saved alot of bytes, and in the old days that ment something.

Another way they saved space is by optimising their data. Sort of...

Here's an example:

map output:
------
|....|
|.++.|
|.++.|
|....|
------

unoptimised data:
data"-||||....--.++.--.++.--....--||||-"

optimised data:
data "-||||--4--1++1-"

now that was from the example that I read on someone who analysed the rom for the original pacman arcade.

you could take this further by parsing even more:
data "-4|--4..++.-"

so your routine would read that there is a - and then see that there is a numeric value 4 followed by a | so it would draw -|||| followed by a -- another numerica value of 4 followed by a . so it would draw .... and so on.

They saved alot of bytes this way. Especially considering they have 256 levels on a machine that had maybe 20k of ram.

Quote: " Timesoft - Your wife is death. How? NO idea.
But it is murder. REVENGE!!!!!!!!!"

Hands down the funniest synopsis for a game ever. All your base are belong to us!
Tapewormz
22
Years of Service
User Offline
Joined: 15th Sep 2002
Location: Winnipeg, Mantoba, Canada
Posted: 1st Apr 2004 04:58
Just checking up on you Jason... How's your Pac Man game going? I've found out more information on things about Pac Man that you may not know. There are variable speeds for Pac Man, and the ghosts when they travel over pellets, and empty spaces and through the tunnels. The red ghost in particular travels faster than the other ghosts. I've got variables for all of these.

Quote: " Timesoft - Your wife is death. How? NO idea.
But it is murder. REVENGE!!!!!!!!!"

Hands down the funniest synopsis for a game ever. All your base are belong to us!

Login to post a reply

Server time is: 2025-05-14 13:38:03
Your offset time is: 2025-05-14 13:38:03