Added ability to place stones and mark intersections, and reduced number of image files needed.

This commit is contained in:
Anna Rose 2012-04-08 02:16:23 -04:00
parent 225f09c98f
commit 740f914bd1
13 changed files with 30 additions and 5 deletions

35
pygo.py
View File

@ -28,14 +28,22 @@ def load_png(name):
def build_img_res():
ret = {}
triangle = load_png('go_t.png')
ret['w'] = load_png('go_w.png')
ret['wT'] = load_png('go_wT.png')
ret['wT'] = load_png('go_w.png')
ret['wT'].blit(triangle, (0,0))
ret['b'] = load_png('go_b.png')
ret['bT'] = load_png('go_bT.png')
ret['bT'] = load_png('go_b.png')
ret['bT'].blit(triangle, (0,0))
circle = load_png('go_c.png')
for d in ('u', 'd', 'l', 'r', 'm', 'dl', 'dr', 'ul', 'ur', 'h'):
ret[d] = load_png('go_' + d + '.png')
ret[d + 'c'] = load_png('go_' + d + 'c.png')
ret[d + 'c'] = load_png('go_' + d + '.png')
ret[d + 'c'].blit(circle, (0,0))
return ret
@ -120,7 +128,10 @@ def main():
for j in range(19):
goban[i].append(GobanSquare((i+1, j+1)))
board = draw_board(goban, 800, img_res)
board_size = 800
board_inc = board_size / 19
board = draw_board(goban, board_size, img_res)
background.blit(board, (0,0))
screen.blit(background, (0, 0))
@ -131,9 +142,23 @@ def main():
if event.type == QUIT:
return
if event.type == MOUSEBUTTONDOWN:
if event.button == 1:
state = 'black'
if event.button == 2:
state = 'marked'
if event.button == 3:
state = 'white'
screen.blit(background, (0,0))
x, y = event.pos
goban[y / board_inc][x / board_inc].state = state
board = draw_board(goban, board_size, img_res)
background.blit(board, (0,0))
screen.blit(background, (0, 0))
pygame.display.flip()
if __name__ == '__main__': main()

BIN
res/go_c.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.9 KiB

BIN
res/go_t.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 39 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.7 KiB