code structure

Hello, while I have experience programming I have never created a game and I am not sure how to structure my code. After looking at some projects I am still not 100% sure what I am doing.

I would appreciate if some one could show me how to arrange a character class, game(world) class, and a weapons class.

In my opinion (I’m not an expert), I would HIGHLY suggest reading books on game programming, especially in python. They run you through the steps, and show you how to use your code to make games.

I for one used that method(along with my lecturer, who taught us very very very basic programming), and I THINK it worked out quite well.

Maybe check your nearby library?

Thank you for your response. Do you know any book titles that I should look at?

plenty of free ones on the internet.

Just google

Python tutorials

You can take a look at the project Epoch.
It is a full game, and it is well structured.

you can find the thread where to download the source
discourse.panda3d.org/viewtopic … ight=epoch

I think it is a bit complex for a beginner, but it is very interesting to view a complete game.

If you need to learn python programming structure you can go here.

I found it after googling awhile and it’s very neat for basic.

python.org/doc/essays/ppt/sd … sld004.htm

I know the basics of python, I was wondering if there is a standard of sorts. For example I have seen code with something like

If name==__main__:

Wow, nobody has mentioned PEP-0008 yet?

That’s the definitive coding style document for Python.

Update: Slight caveat, that should be name, not just name. name is a built-in magic variable. It will be “main” if the module is being run itself, otherwise it will contain the module name where it is being imported from.

Update2: Er, Thomas beat me to it. :slight_smile:

hobbit: that line is part of pythons standard magic, if you have a py file and do python yourpyfile.py it will execute the following code, if you import yourpyfile as a module it will not. this is sometimes usefull to make modules which provide stand-alone functionality

thank you both for the replies. I’m finding the PEP-0008 to be really helpful, I never knew some of the information in there.

To answer your original question, i found a very well structured and also functional finished exampled here: discourse.panda3d.org/viewtopic.php?t=6688

have fun.