[pygame] Anybody think they can help me with my small problem?

2007-09-22 Thread Lamonte Harris
Well I was trying to get the current area of a Tic Tac Toe box:
http://uni-code.com/MADIMG/1/afdeUntitled-1.gif

The first 3 boxes worked and printed 1,2,3 then when I got to all the other
ones it just spazzed.

def check_mouse(self,mouse):
m1 = mouse[0]
m2 = mouse[1]
x = 1
while x  len(self.area) + 1:
if (m1 - self.area[x][0]) in range(0,100) and (m2 -
self.area[x][1])
in range(0,100):
print m1 - self.area[x][0],m2 - self.area[x][1]
print x
print
elif (m1 - self.area[x][0]) in range(100,200) and (m2 -
self.area[x][1]) in range(100,200):
print m1 - self.area[x][0],m2 - self.area[x][1]
print x
print
elif (m1 - self.area[x][0]) in range(200,300) and (m2 -
self.area[x][1]) in range(200,300):
print m1 - self.area[x][0],m2 - self.area[x][1]
print x
print
elif (m1 - self.area[x][0]) in range(0,100) and (m2 -
self.area[x][1])
in range(100,200):
print m1 - self.area[x][0],m2 - self.area[x][1]
print x
elif (m1 - self.area[x][0]) in range(200,300) and (m2 -
self.area[x][1]) in range(100,300):
print x
elif (m1 - self.area[x][0]) in range(300,400) and (m2 -
self.area[x][1]) in range(100,200):
print x
elif (m1 - self.area[x][0]) in range(0,100) and (m2 -
self.area[x][1])
in range(200,300):
print x
elif (m1 - self.area[x][0]) in range(100,200) and (m2 -
self.area[x][1]) in range(200,300):
print x
elif (m1 - self.area[x][0]) in range(200,300) and (m2 -
self.area[x][1]) in range(200,300):
print x
x += 1
It wasn't getting the correct box, it printed 2 nums out at the same time...
#CopyRighted Lamonte of CleanScript.com
import pygame,sys
from pygame.locals import *
class lines(object):
def __init__(self):
pygame.init()
pygame.display.set_mode((300,300))
self.window = pygame.display.get_surface()
self.window.fill((0,0,0))
self.columns = 100
self.cordnates = {
1 : [0,0] , 2 : [0,0] , 3 : [0,0],
4 : [0,0] , 5 : [0,0] , 6 : [0,0],
7 : [0,0] , 8 : [0,0] , 9 : [0,0]
}
self.area = {
1 : (0,0) , 2 : (100,0) , 3 : (200,0),
4 : (0,100), 5 : (100,100), 6 : (200,100),
5 : (0,200), 5 : (100,200), 7 : (200,200)
}
self.gameover = False
def check_mouse(self,mouse):
m1 = mouse[0]
m2 = mouse[1]
x = 1
while x  len(self.area) + 1:
if (m1 - self.area[x][0]) in range(0,100) and (m2 - 
self.area[x][1]) in range(0,100):
print m1 - self.area[x][0],m2 - self.area[x][1]
print x
print 
elif (m1 - self.area[x][0]) in range(100,200) and (m2 - 
self.area[x][1]) in range(100,200):
print m1 - self.area[x][0],m2 - self.area[x][1]
print x
print
elif (m1 - self.area[x][0]) in range(200,300) and (m2 - 
self.area[x][1]) in range(200,300):
print m1 - self.area[x][0],m2 - self.area[x][1]
print x
print
elif (m1 - self.area[x][0]) in range(0,100) and (m2 - 
self.area[x][1]) in range(100,200):
print m1 - self.area[x][0],m2 - self.area[x][1]
print x
elif (m1 - self.area[x][0]) in range(200,300) and (m2 - 
self.area[x][1]) in range(100,300):
print x
elif (m1 - self.area[x][0]) in range(300,400) and (m2 - 
self.area[x][1]) in range(100,200):
print x
elif (m1 - self.area[x][0]) in range(0,100) and (m2 - 
self.area[x][1]) in range(200,300):
print x
elif (m1 - self.area[x][0]) in range(100,200) and (m2 - 
self.area[x][1]) in range(200,300):
print x
elif (m1 - self.area[x][0]) in range(200,300) and (m2 - 
self.area[x][1]) in range(200,300):
print x
x += 1
def check_game(self):
if (self.cordnates[1][0] == 1 and self.cordnates[2][0] == 1 and 
self.cordnates[3][0] == 1) and ((self.cordnates[1][1] == 1 and 
self.cordnates[2][1] == 1 and self.cordnates[3][1] == 1) or 

Re: [pygame] Anybody think they can help me with my small problem?

2007-09-22 Thread R. Alan Monroe

 def check_mouse(self,mouse):
 m1 = mouse[0]
 m2 = mouse[1]

Can you just divide m1 and m2 by 100?

Alan



Re: [pygame] Anybody think they can help me with my small problem?

2007-09-22 Thread Lamonte Harris
I don't think thats the actual problem, its the part where I'm actually
trying to check what block im in.  I got a feeling my numbers are off.  It's
confused me for some big now.

On 9/22/07, R. Alan Monroe [EMAIL PROTECTED] wrote:


  def check_mouse(self,mouse):
  m1 = mouse[0]
  m2 = mouse[1]

 Can you just divide m1 and m2 by 100?

 Alan




Re: [pygame] Anybody think they can help me with my small problem?

2007-09-22 Thread R. Alan Monroe
 Okay I took your idea Alan and I finally got the outcome that I wanted.
 Thanks.

Not sure you got what I meant :)

If you divide the mouse coordinate by 100, you'll automatically either
get a 0, 1, or 2 as the result. No need for any kind of in
range(0,50) comparison at all.

Alan



Re: [pygame] Anybody think they can help me with my small problem?

2007-09-22 Thread Lamonte Harris
Yeah I did it another way, I divided by 2 instead, it was much clearer to me
then.

On 9/22/07, R. Alan Monroe [EMAIL PROTECTED] wrote:

  Okay I took your idea Alan and I finally got the outcome that I wanted.
  Thanks.

 Not sure you got what I meant :)

 If you divide the mouse coordinate by 100, you'll automatically either
 get a 0, 1, or 2 as the result. No need for any kind of in
 range(0,50) comparison at all.

 Alan