Added ability to place stones and mark intersections, and reduced number of image files needed.
This commit is contained in:
parent
225f09c98f
commit
740f914bd1
35
pygo.py
35
pygo.py
|
@ -27,15 +27,23 @@ 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'
|
||||
|
||||
x, y = event.pos
|
||||
goban[y / board_inc][x / board_inc].state = state
|
||||
|
||||
screen.blit(background, (0,0))
|
||||
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
BIN
res/go_c.png
Normal file
Binary file not shown.
After ![]() (image error) Size: 7.7 KiB |
BIN
res/go_dc.png
BIN
res/go_dc.png
Binary file not shown.
Before ![]() (image error) Size: 3.8 KiB |
BIN
res/go_dlc.png
BIN
res/go_dlc.png
Binary file not shown.
Before ![]() (image error) Size: 3.9 KiB |
BIN
res/go_drc.png
BIN
res/go_drc.png
Binary file not shown.
Before ![]() (image error) Size: 3.8 KiB |
BIN
res/go_hc.png
BIN
res/go_hc.png
Binary file not shown.
Before ![]() (image error) Size: 4.0 KiB |
BIN
res/go_lc.png
BIN
res/go_lc.png
Binary file not shown.
Before ![]() (image error) Size: 3.9 KiB |
BIN
res/go_mc.png
BIN
res/go_mc.png
Binary file not shown.
Before ![]() (image error) Size: 3.9 KiB |
BIN
res/go_rc.png
BIN
res/go_rc.png
Binary file not shown.
Before ![]() (image error) Size: 3.9 KiB |
BIN
res/go_t.png
Normal file
BIN
res/go_t.png
Normal file
Binary file not shown.
After ![]() (image error) Size: 39 KiB |
BIN
res/go_uc.png
BIN
res/go_uc.png
Binary file not shown.
Before ![]() (image error) Size: 3.7 KiB |
BIN
res/go_ulc.png
BIN
res/go_ulc.png
Binary file not shown.
Before ![]() (image error) Size: 3.7 KiB |
BIN
res/go_urc.png
BIN
res/go_urc.png
Binary file not shown.
Before ![]() (image error) Size: 3.7 KiB |
Loading…
Reference in New Issue
Block a user