Hey there, everyone.

My friend and I are looking into writing a very simple game in Python. We're gonna use PyGame for it as well.

It's a top-down view 2D game where you play as a guy with an ax who kills zombies. There are not different levels; it's all on one level where the zombies continuously come until you die. It'll either score the player based on how many zombies he killed or how long he lasted, we don't know yet; but that's irrelevant for now.

What I needed to know is if anyone knew of any good places for me to start, or ant good tutorials for top-down games. I've looked on the PyGame site, but I haven't found anything good. I tried looking at the source of other top-down games from the PyGame site, but they don't have any that are close to what I'm trying to do.

I'm just not sure where to start. We're not worried about the graphics or sounds right now; all we're trying to do is get the skeleton and core engine down.

If anyone has any advice or previous experience with a project like this, all information is welcome and greatly appreciated!

Not really with top down games, but i have experience with pygame and would be willing to answer any questions you have. The top-down part makes it a bit easier, all you should need is a player sprite, and a zombie sprite, and since you don't want to make it into separate levels, it should be fairly easy to program. I'd start with something like this:

class Game(object):
    def __init__(self):
        #put anycode you want like player lives, score, etc here.
        pygame.init()
        global screen
        screen = pygame.display.set_mode((1082,860))
        pygame.mouse.set_visible(False)
        #There are a few more things needed, but they depend on how you want
        #Your graphics done. This just as it is would probably just crash.
    def menu_loop(self):
        #fill the loop parts in obviously...
        pass
    def play_loop(self):
        pass
    def spawn_enemy(self):
        pass

That's really skeleton-like, but something that basic should be enough to make the game work. Let me know how else I can help you.

Thank you for your response, Greeky.

That may be a skeleton, but it's definitely a good start for me. Planning things out like this really helps.

So, I just need to get a few things cleared up before I start, if you don't mind answering these.

Since this is such a simple game, will I need multiple script files, or will I be able to have all the code in one file?

Inside of the __init__() function, is that where I would set the display and little things like that? And for the controls, do I assign those outside of the Game() class or inside of a specific function?

Ok,
a) I'd definitely recommend putting it into multiple files, just so its easier to read.
b) You can set the display in the init function, or you can elsewhere, just do it before you render something to the screen.
c) And the controls, I'd do in your main loop using pygame's:

for event in pygame.event.get():
     if event.type == pygame.QUIT:
         sys.exit()
     elif event.type == pygame.KEYDOWN:
         if event.key == pygame.K_ESCAPE:
             sys.exit()

and fill in with your controls.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.