[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] My first game; the design of pacman



Hi Kai
See inside...

Am 20.03.2006 um 16:55 schrieb Kai Kuehne:

Hello everyone.

I'm planning to make a remake of the game pacman
in python and pygame. It exists very often,
sure, but it's just fun.

This is my first game so I have several
design problems.

First of all, i have map files.
A map looks something like this:

####################
#                           #
#                            #
#   P                       #
#                           #
#               G             #
####################

Where 'P' is the Pacman... and so on.
Now I go and read the mapfile into my program
and replace the specific characters with real
objects ("Pacman" in this case). Now I wanted
to add to every object (like Ghost, or whatever)
update and draw methods so that they can draw
"themselves" onto the screen. Or would it be better
to get all the objects and blitting them onto the
screen, after I have moved them?
=> What you probably want to say is that you would like to work in the pure OO way, like in Java or C/C++. Python is highly dynamic and easy to use. You don't need to care about creating new instances of the same object like you do in the mentioned OO languages, Python references to the newly created objects (ghosts), you don't need to create an expl
If you want to make it more complicated, check the class Thread. ;) The Ghosts are all of the same type of object, they only differ in their coordinates. So why making it more complicated?



I'm a bit confused whether there should be a "Master class" which controls everything or if every object should take care only about itself.
=> First of all you will anyway have master class (loop) for checking the input from the gamer. There is also a master class in any other language, up to you what yo call from it or right away do in it.


I decline to use the second version... is this "the right way" or what would you make *different*?
=> There is no right and wrong way, its all up to you and how much work you want to spend into it to finish it. Some ways needs of course more time than others.

Second question: When all the objects ("Wall", "Nothing", "Pacman" and so on) are all in my list... what's when Pacman hits a Ghost? I know, I should use a second list. And in this "background" list, there should lie all the objects, that *don't* move. Right?
=> You always know the positions of the ghosts and also of the Pacman (f.e. in a list) . The only thing you have to do is to use collision detection or to ask if the coordinates of the Pacman is close or equal to any other existing ghost. This can be done very easily in Python.


My english is not very good, so, if you didn't understand something.. please ask for it.
=> Good luck on working it. Sure there would be easier games as for the first project but people need challenges. ;) And its also interesting to walk into to the steps of minds who created such games 20 or 30 years ago. ;)


Thanks in advance

Kai
=> Just my 2 cents, hope it helps
Regards
Tyger