Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Help with makng PACMAN!
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
w00t




PostPosted: Mon Jan 10, 2005 8:20 am   Post subject: Help with makng PACMAN!

Hey Everyone,

This is my third time posting this because mine were deleted by accident or whatever, but back on topic.

I have made the basics of pacman:

movement;
collision detection;
walls and ;
pac dots.

now im having an issue with the ghosts that are suppose to follow pacman and so far all i can think of is to try and get the ghosts to match the x,y coordinates of the pacman, but how do i do this with randomness and not the harder part, colision detection. By randomness i mean when you go up in a corner and its more logical to move straight up into you, they will go past you left, and the go up the next availible space and then turn right which would be straight into the pacman if you left him there. If that isn't to clear thats okay ignore it. but how do i get the x,y coordinate thing to work.

code:
loop
var dx, dy : int
var x, y : int
x := x + dx
y := y + dy


thats what i have seen in another post that was from 2003 or early 2004, so can anyone help me figure out how to do this, or how to use this sample code?

Thanks Ahead,
Arrow w00t w00t
Sponsor
Sponsor
Sponsor
sponsor
Delos




PostPosted: Mon Jan 10, 2005 9:47 am   Post subject: (No subject)

Well, first off as you can see, the code you posted is buggy. Declaring vars in a loop is always a bad idea (even though that renders them local to the loop), in most other langs this is not allowed.
Also, none of them are instantiated, so they won't work...

As for the movement...perhaps you could have some sort of beacon at each junction on your map. When a ghost reaches a beacon, a random draw decides which direction to take. You could always narrow your choice of numbers to be drawn depending on where PacMan is (eg. you reach a 4-way intersection, travelling up. You may go left (1), up(2), or right (3). PacMan is directly above you. So, to make things interesting, you narrow your options to 1 and 3).

AI movement can get complex...and there's many ways to do it...tinker a bit and see.
w00t




PostPosted: Tue Jan 11, 2005 10:38 am   Post subject: (No subject)

Okay well thanks for reading,

but if anyone can actually help me by showing code, not to be rude to you delos, but i dont understand completly. I understand the varible "dealio" but i am confused. HELP SOMEONE !!!

thnx
w00t w00t
Tony




PostPosted: Tue Jan 11, 2005 12:52 pm   Post subject: (No subject)

in the original pacman - each ghost has a personality. The red one, I think, for example finds the shortest path to you and follows that (using a maze search algorithm of choice). Another one does the similar, but targeting a point tawards which pacman is moving tawards. I imagine it being the next intersection. 3rd one just sweeps the maze line after line. 4th moves around randomly.

You should search for that on google, or ask Martin - I belive he was the one to post this originally.
w00t




PostPosted: Thu Jan 13, 2005 8:14 am   Post subject: (No subject)

Alright thanks alot,

I've got the ghosts personalities figured out Very Happy and now for the "agressor" Bat how do you do the maze algorithm, maybe i already know how, but I've never heard it called that. And i was thinking, maybe i should do my levels in tiles, can anyone help me with that aswell.

Thanks Ahead, Wink

Arrow w00t w00t
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 5 Posts ]
Jump to:   


Style:  
Search: