[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[pygame] more collidepoint problems
- To: pygame-users@xxxxxxxx
- Subject: [pygame] more collidepoint problems
- From: "Eric Hunter" <hunter.eric1@xxxxxxxxx>
- Date: Tue, 4 Sep 2007 00:02:30 -0400
- Delivered-to: archiver@xxxxxxxx
- Delivered-to: pygame-users-outgoing@xxxxxxxx
- Delivered-to: pygame-users@xxxxxxxx
- Delivery-date: Tue, 04 Sep 2007 00:02:40 -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=K6QVMvzBBUzdf0DRsfPhVOk88UdKeZefizgut03RG2kaQREIh3rSC5mBS8G+114Zl/mf9RZU2r2Y1COItxzq+lYbbWIe2eOnJ8ovmtla8KT+kwdOxqS1ymAZLAGOay/H2I1hDSvFfixJtQCg2Flt0oizUOH76bYCZlnIS7dBpVY=
- 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=Hk0NoWm1B0RHrMY41zbAgCk79sAbrVEzfHWnHB6AeQEPfxS846lo4T1ye17LNeYekFiJsKVPKBFMseQvNWfkUrA995+yF2rc0MhcUB1wt/xxITfiTH9okajlVDVclj+b4KaWogyK/+au5erCM0H4QeqgJxgm6tDHqT8/a4+V4bM=
- Reply-to: pygame-users@xxxxxxxx
- Sender: owner-pygame-users@xxxxxxxx
well at least I'm getting better
here's the error I'm getting now
Traceback (most recent call last):
File "G:\test2.py", line 40, in <module>
if box.collidepoint(mousexTEMP, mouseyTEMP):
AttributeError: 'tuple' object has no attribute 'collidepoint'
from this code:
import pygame
from pygame.locals import *
pygame.init()
surface = pygame.display.set_mode
((400, 300))
point_draw = 1
rect = []
rectRect = []
numRect = 0
while True:
surface.fill((255, 255, 255))
for event in pygame.event.get():
if
event.type == QUIT:
pygame.quit()
if event.type == pygame.MOUSEBUTTONDOWN:
if event.button == 1:
if point_draw == 1:
mouse1x, mouse1y = pygame.mouse.get_pos()
point_draw = 2
# print mouse1x, mouse1y
else:
mouse2x, mouse2y = pygame.mouse.get_pos()
pygame.draw.rect(surface, ((255, 255, 0)), (mouse1x, mouse1y, mouse2x - mouse1x, mouse2y - mouse1y), 1)
# print mouse2x, mouse2y
numRect += 1
newRect = mouse1x, mouse1y, mouse2x - mouse1x, mouse2y - mouse1y
rect.append(newRect)
if event.button == 3:
mousexTEMP, mouseyTEMP = pygame.mouse.get_pos()
for i in range(0, numRect):
box = rect[i]
if box.collidepoint(mousexTEMP, mouseyTEMP):
del rect[i]
numRect = numRect - 1
for i in range(0 , numRect):
#print i
pygame.draw.rect(surface, ((255, 255, 0)), rect[i], 1)
pygame.display.flip()