Ive not actually done any programming with pygame, i did recently finish a online course 'An Introduction to Interactive Programming in Python' where the final project was a asteroid like game.It uses codeskultper which runs python in the browser, i think the coding is probably quite similar to pygame so you could have a look how they got us to organize the code, maybe it will give ideas on pygame codeing, it runs best in the chrome browser.All the globals are just how got codeskulpter to deal with events, i wouldn't want to use them normally.http://www.codeskulptor.org/#user16_bgepvzsoDW_26.py

This part is prolly just me, as i have dual monitors, but whenever someone uses this it splits it in the center half on one monitor and half on the other monitor, somtimes resulting in trouble finding it to be honest.

Drake's Handler and Pages are essentially the same thing as my Control class and States. The handler/controller has a dictionary of pages/states that it updates via polymorph. When you want a new phase to your game, you add a new page/state. Anyway, I am kinda on the side of doing something a little more original. I don't think a PVZ clone would take very long though so go ahead (I think you guys will finish the code fairly quickly and find you have endless art requirements left though). I do tend to think that Drake and I would clash a bit on the underlying core of the program however, so I am leaning towards sitting this one out and seeing what you guys come up with.

Drake's Handler and Pages are essentially the same thing as my Control class and States.

As i am looking at it i am starting to see that. But Drake's seems more of a complicated process (no offense Drake), especially to a pygame beginner like me

I do tend to think that Drake and I would clash a bit on the underlying core of the program however, so I am leaning towards sitting this one out and seeing what you guys come up with.

See that what i thought originally. But my interest in working with other programmers intrigues me, enough to wheel and deal the core of the program. If Drake insists on his core style, i am OK with it, although I would prefer Mekire's. So this is where the clash is that i am not sure what to do when you have multiple programmers.

Anyway, I am kinda on the side of doing something a little more original

Well i just managed to get a white circle to appear in probably completely the wrong way, so i dont think there's much chance of me completing anything quickly and i have no idea of pygames underlying core that you guys are bouncing of the walls at each other..... goes off to make the circle move a bit

Well i just managed to get a white circle to appear in probably completely the wrong way, so i dont think there's much chance of me completing anything quickly and i have no idea of pygames underlying core that you guys are bouncing of the walls at each other..... goes off to make the circle move a bit

This part is prolly just me, as i have dual monitors, but whenever someone uses this it splits it in the center half on one monitor and half on the other monitor, somtimes resulting in trouble finding it to be honest.

Hey now. I not going to be the guy that breaks the camels back.I was just making a suggestion. At least it got people talking.I will have to learn how to do it in your frame work. or let you handle it.since 1 vote is not enough.

His method is identical to mine save for what I see as a little C(++) influence. I believe this is the explanation for the psuedoprivate members as well as the naming convention inconsistencies. I also don't find writing getters for things I can already get useful (IE why write a getter Handler.get_rect that just calls Surface.get_rect()). I do think that you guys should pep8 everything before you start so you are on the same page (at least in terms of naming conventions; I think 80 character line limits are a bit archaic and silly)

On the os.environ['SDL_VIDEO_CENTERED'] = '1' I agree your case of dual monitors is an exception but I think using it is better than the alternative of the window appearing randomly. I believe there is another setting to specifically say the screen offset of the window which would probably work better in your case but I would have to research.

Couple trivial notes. You need to call set_caption (and set_icon) before you call set_mode for the display. Also I think you need to make your handler tell the next state what the previous state was in the control methods. This is for cases when a state can be accessed from different portions of the game.

-Mek

Edit:This is fairly typical for what my control classes look like. The below was a three state game. I tend to custom tailor them to each game rather than use it as a static framework:

DrakeMagi wrote:but i do questions your use __init__() ?Do you really need to re init a class.What happens when variables are pass to the class.

The piece I posted just happens to be from a game where no information needed retaining between state changes (as I said I tend to modify them for projects as needed). In more general cases, I give my State classes a function called cleanup which is called during the state flipping. I overload it in the specific states as necessary but might have its default behavior in the base State class call __init__.

As for pep8 my naming conventions follow the standard guidelines. I don't follow every little thing (like as I said 80 character max line width) and I don't always capitalize certain class names like rects or surfaces (I do however always capitalize my own classes and instances of such). CamelCase in the python community is strongly attached to only classes and instances of classes. Using camel case for standard variable names or even capitalizing them is just asking for trouble.

I should also mention that I organize my projects as packages so as to maintain a nice tidy top level directory. The only file I have in my top level directory usually looks like this:

I should also mention that I organize my projects as packages so as to maintain a nice tidy top level directory. The only file I have in my top level directory usually looks like this:

This i find the best solution as to when you download a pygame game and there is no structure like this. You end up looking through a ton of modules looking for main.py or a module named the name of the game. It just makes it simple stupid of which module is the start up script.

If everyones goal is to practice programming and learn to work in a team then you're better off making a clone or the concept or the game in my opinion. In my experience working on original projects, a lot of time is spent on conjecture about artistic aspects, plot/ideology and making it all concise. If it's the latter that you want to improve on, then do that, otherwise working on a clone mean the structure and artistic aspects have already been worked through for you allowing you to concentrate on making it work.