-
Notifications
You must be signed in to change notification settings - Fork 0
/
principal.py
72 lines (59 loc) · 1.74 KB
/
principal.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# coding: utf-8
# Autor: Daniel Rodrigues Coura
# Matrícula: 117111915
from damas import *
import pygame, sys
from pygame.locals import *
pygame.init()
larg = 800
alt = 600
screen = pygame.display.set_mode((larg, alt))
lado_casa = alt / 8.0
tab = pygame.image.load('img/tabuleiro.png')
back = pygame.image.load('img/back.jpg')
peca1 = pygame.image.load('img/peca1.png')
peca2 = pygame.image.load('img/peca2.png')
def desenha_tabuleiro():
for i in range(len(tabuleiro)):
for j in range(len(tabuleiro[i])):
if tabuleiro[i][j] == -1:
screen.blit(peca2, (j * 75, i * 75))
elif tabuleiro[i][j] == 1:
screen.blit(peca1, (j * 75, i * 75))
tabuleiro = []
inicializa_tabuleiro(tabuleiro)
possib = []
vez = -1
while True:
screen.blit(tab, (0,0))
screen.blit(back, (600,0))
desenha_tabuleiro()
for i in possib:
retang = pygame.Rect(i[1] * 75, i[0] * 75 , lado_casa, lado_casa)
pygame.draw.rect(screen, (255, 214, 20), retang)
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
sys.exit()
elif event.type == pygame.MOUSEBUTTONDOWN and pygame.mouse.get_pressed()[0]:
y = pygame.mouse.get_pos()[0] // 75
x = pygame.mouse.get_pos()[1] // 75
print pygame.mouse.get_pos()[0], pygame.mouse.get_pos()[1]
print x,y
if [x, y] in possib:
print possib, '- possib'
######
if procura_capturas(tabuleiro, vez):
print peca, possib[-1], '- captura'
print captura(tabuleiro, [peca[0], peca[1]], possib[0])
possib.pop(0)
tabuleiro[x][y] = vez
tabuleiro[peca[0]][peca[1]] = None
if not procura_capturas(tabuleiro, vez):
vez *= -1
possib = []
else:
peca = [x, y]
for i in possibilidades(tabuleiro, (x, y), vez):
possib = i
pygame.display.update()