I often find it easier to rewrite the code myself, then to modify someone else's. I also assumed that yellow_block is a single yellow block of color. I think it would be faster to draw a rectangle of a single color than to load a image of one.
On 7/28/07, Ethan Glasser-Camp <[EMAIL PROTECTED]> wrote: > > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > Eric Hunter wrote: > > if event.type == pygame.MOUSEBUTTONDOWN: > > mouseX1, mouseY1 = pygame.mouse.get_pos () > > print "Mouse 1", mouseX1, mouseY1 > > clear = pygame.event.clear() > > while not pygame.MOUSEBUTTONDOWN: > > mouseX2, mouseY2 = pygame.mouse.get_pos() > > print "Mouse 2", mouseX2, mouseY2 > > box_resize = ((mouseX2 - mouseX1) + 1), ((mouseY2 - > > mouseY1) + 1) > > yellow_block = pygame.transform.scale(yellow_block, > > box_resize) > > background.blit(yellow_block, (mouseX1, mouseY1)) > > screen.blit(background, (0, 0)) > > pygame.display.update(yellow_block) > > In case it wasn't clear, Ian's opinion is that it is easier to rewrite > this script than fix it. The problem is that your while loop, "while > not pygame.MOUSEBUTTONDOWN" doesn't do what you want it to do -- check > events until one of them is pygame.MOUSEBUTTONDOWN. Instead it > computes the value of "not pygame.MOUSEBUTTONDOWN" > (pygame.MOUSEBUTTONDOWN happens to be 5, so the "not" of that is > False) and breaks out immediately. Even if you wrote your while loop > to actually check events (and keep checking them), it wouldn't be a > good idea, because your "main loop" probably does other things that > you don't want your little while loop to duplicate. (For example, > checking for pygame.QUIT.) Instead, you should structure your main > loop to check for clicks and act accordingly, like Ian did. > > Hope this helps! > > Ethan > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v1.4.6 (GNU/Linux) > Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org > > iD8DBQFGrBZNhRlgoLPrRPwRAhykAJ9HkSp8F7AJ05MG4z1NjBOO4VWp8ACdGHbQ > +6GOK/pQ68H2YQC4EGn684w= > =mErs > -----END PGP SIGNATURE----- >