You can now move off bar

This commit is contained in:
Alexander Munch-Hansen 2018-04-14 23:31:33 +02:00
parent 7d29fc02f2
commit f59fe27e5f

View File

@ -135,13 +135,23 @@ class Board_painter:
def find_pin(self, pos): def find_pin(self, pos):
SPACING = self.SPACING SPACING = self.SPACING
x,y = pos x,y = pos
x -= 50 if x > 550 else 0
if y < 175:
pin = (13 + int(x / SPACING)) if 500 < x < 550:
idx = 1+int(x / SPACING) if y > 225:
elif y > 225: pin = 0
pin = (12 - int(x / SPACING)) idx = 0
idx = 13+ int(x / SPACING) else:
pin = 25
idx = 25
else:
x -= 50 if x > 550 else 0
if y < 175:
pin = (13 + int(x / SPACING))
idx = 1+int(x / SPACING)
elif y > 225:
pin = (12 - int(x / SPACING))
idx = 13+ int(x / SPACING)
return pin, idx return pin, idx
# Find the y position based on the chosen pin # Find the y position based on the chosen pin
@ -254,6 +264,8 @@ class Board_painter:
if buckets[idx][0] == 0: if buckets[idx][0] == 0:
buckets[idx][1] = 0 buckets[idx][1] = 0
print("Location for mouse_down:", self.from_board)
offsets[is_true][0] = rectangles[is_true].x - mouse_x offsets[is_true][0] = rectangles[is_true].x - mouse_x
offsets[is_true][1] = rectangles[is_true].y - mouse_y offsets[is_true][1] = rectangles[is_true].y - mouse_y
@ -309,7 +321,7 @@ class Board_painter:
# print(move_legal(from_board, buckets, [1,2])) # print(move_legal(from_board, buckets, [1,2]))
print("from board:",self.from_board)
# if self.move_legal(self.from_board, buckets, self.roll): # if self.move_legal(self.from_board, buckets, self.roll):
pot_board = self.gen_board_from_buckets(buckets) pot_board = self.gen_board_from_buckets(buckets)
sets = self.calc_move_sets(self.from_board, self.roll, player) sets = self.calc_move_sets(self.from_board, self.roll, player)
@ -404,47 +416,12 @@ class Board_painter:
def test(self): def test(self):
while True: while True:
self.paint_board() self.paint_board()
pygame.quit()
b = Board_painter() b = Board_painter()
b.test() b.test()
# class myThread (threading.Thread):
# def __init__(self, threadID, name, counter):
# threading.Thread.__init__(self)
# self.threadID = threadID
# self.name = name
# self.counter = counter
# def run(self, function):
# print ("Starting " + self.name)
# function()
# print ("Exiting " + self.name)
# def change_player():
# while True:
# time.sleep(5)
# b.switch_player([1,2])
# def keep_painting():
# while True:
# b.paint_board()
# # Create new threads
# thread2 = myThread( keep_painting() )
# thread1 = myThread( change_player() )
# # Start new Threads
# thread1.start()
# thread2.start()
# thread1.join()
# thread2.join()
# print ("Exiting Main Thread")
# # - end -
# pygame.quit()