Pygame stuff

Install Python 2.7 and Pygame 1.9. Make sure you get the right versions. Mac? Windows? 64-bit? 32-bit? etc

Basic tasks to start with

  • Get the Pygame screen to appear.
  • Get a small image to appear.
  • Make it move.
  • Make it responds to mouse clicks.

Only now can you begin to think about games.

A basic game loop:

HighLevelGameLoopArchitecture_1149081_11

  • Processing user input will use the pygame.event module.
  • Updating the game world will almost certainly be a nested loop to run through each sprite to get them to react to the current game state. Pygame allows you to group similar sprites and call their update() methods. If you don’t use a pygame.sprite.Group then you will almost certainly keep multiple sprites of the same type in a list and run through the list:
     for enemy in enemiesList:
         enemy.update()
  • Rendering the game world will involve making calls to the Pygame objects’ draw() methods.

Other obvious functions you might program are:

  • gameOver(): Checks to see if a game over state has been reached and returns true if it has, false otherwise.
  • changeScore(): Keeps the score up-to-date.

Leave a comment