[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] Pygame Problem Solving 1



Lamonte(Scheols/Demonic) wrote:
                elif event.type == pygame.MOUSEBUTTONDOWN:
                    ...
                    mouse = pygame.mouse.get_pos()

It's better to get the mouse position from the event,
seeing as you've got one, than to use mouse.get_pos().
Then you can be sure it's the position relating to
that particular event.

                    if rng in range(0,25):

A much more efficient way to do that is

                      if 0 <= rng < 25:

otherwise you're creating a list containing the numbers
from 0 to 24 (expensive) and then searching it sequentially
for the number you're testing (also expensive).

--
Greg Ewing, Computer Science Dept, +--------------------------------------+
University of Canterbury,	   | Carpe post meridiem!          	  |
Christchurch, New Zealand	   | (I'm not a morning person.)          |
greg.ewing@xxxxxxxxxxxxxxxx	   +--------------------------------------+