trying to get the box to disappear if you press the right mouse button
inside the box. thanks in advance.

import pygame
from pygame.locals import *

pygame.init()

surface = pygame.display.set_mode((500, 400))

allow = True

while True:
        surface.fill((255, 255, 255))

        mousex, mousey = pygame.mouse.get_pos()
        #if box.collidepoint(mousex, mousey):
                #print "Inside the box!"

        mpress = pygame.mouse.get_pressed()
        for event in pygame.event.get():
                if event.type == QUIT:
                        pygame.quit()
                elif event.type == MOUSEBUTTONDOWN and mpress[1]:
                        mousex, mousey = pygame.mouse.get_pos()

                        if box.collidepoint(mousex, mousey):
                                allow = False

        if allow == True:
                box = pygame.draw.rect(surface, (0, 0, 0), (10, 10, 30, 30),
1)
        pygame.display.flip()

Reply via email to