[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[pygame] collidepoint
- To: pygame-users@xxxxxxxx
- Subject: [pygame] collidepoint
- From: "Eric Hunter" <hunter.eric1@xxxxxxxxx>
- Date: Mon, 3 Sep 2007 11:15:11 -0400
- Delivered-to: archiver@xxxxxxxx
- Delivered-to: pygame-users-outgoing@xxxxxxxx
- Delivered-to: pygame-users@xxxxxxxx
- Delivery-date: Mon, 03 Sep 2007 11:15:20 -0400
- Dkim-signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:mime-version:content-type; b=bug6CBdGhbmMBn0AKn54Qo6PfkvwWDilsf3IfF1Sa74kuydL7ROBXStS8uF/M5D6OmK4NVnMixAsRsYUwK1JQZYgwKprw6esb0E13mDTqt+m8wx2pSzzpt11Y+b+c9NgluRT2W5ncsMe7as/6N8euA2LocztYMQZAbNG15B2HME=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:mime-version:content-type; b=WOv3Jl/LqkeGYA2ADXrr1cNB5OnyrLskgkoX8jviJ6+Sy6qWIWHa/gK3jMVT/yXpllhjOWgBbhn0QgKaNFrOpbtLNhTcVBe3TWCPKIrI2pyNzmNr3vtDS4BWY1L98YALkytIjOdiyVK6RSql1Ia1kDEZbMK/zIV9GP6JWHAPEZA=
- Reply-to: pygame-users@xxxxxxxx
- Sender: owner-pygame-users@xxxxxxxx
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()