duminică, 3 martie 2013

5 simple rules help you to programming in pygame.

Some rules when you want to use pygame:

1. Use hardware rendering :

>>> import pygame 
>>> show=pygame.display.set_mode((400,400), pygame.HWSURFACE | pygame.DOUBLEBUF)

2. Use function convert and load bmp file.

>>> im=pygame.image.load("9.bmp").convert()

... also you got error:

>>> im2=pygame.image.load("9.png")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
pygame.error: File is not a Windows BMP file

3. Don't use reserved words in your variables, like display, time ...

4. Be advice about low performance. For example: simple 2D game no need to use threads. Also bad configuration of game , wrong sprites , group classes used or using unoptimized images heavily and you will have a low performance.

5. Use profiler to test how much time your game spend on event handling, computing and drawing. Don't guess what is wrong?