diff options
author | Florian Jung <flo@windfisch.org> | 2015-08-18 00:50:13 +0200 |
---|---|---|
committer | Florian Jung <flo@windfisch.org> | 2015-08-18 00:50:13 +0200 |
commit | 48d6950cbbc2eec66d557861c5507b31bbf3c0e8 (patch) | |
tree | b2f767571c2f016067a23d3bc9ea19faa9329274 /gui.py | |
parent | fc3ed2e3a4748c3168fd621ca96f98cc568f315d (diff) | |
parent | 57609975e0ea98c7152859ffd4c965c0879608ad (diff) |
Merge branch 'master' into strategy-rework
Diffstat (limited to 'gui.py')
-rw-r--r-- | gui.py | 38 |
1 files changed, 28 insertions, 10 deletions
@@ -23,6 +23,9 @@ input = False bot_input = True clock = pygame.time.Clock() +marker = [(0,0),(0,0),(0,0)] +marker_updated = [True, True, True] + screensize=(1280, 800) screen=pygame.display.set_mode(screensize,HWSURFACE|DOUBLEBUF|RESIZABLE) @@ -49,6 +52,7 @@ def draw_box(rect, color, filled=False, global_coords=True): def draw_circle(pos, r, color, filled=False, global_coords=True): if global_coords: pos = world_to_win_pt(pos, c.player.center) + r = world_to_win_length(r) if filled: gfxdraw.filled_circle(screen, pos[0], pos[1], r, color) @@ -208,8 +212,22 @@ def clear_screen(): screen.fill((255,255,255)) +def draw_marker(pos, color, thick): + offset = 40 / math.sqrt(2.) + # offset = 15 + draw_line((pos[0]+offset, pos[1]+offset),(pos[0]-offset, pos[1]-offset), color) + draw_line((pos[0]-offset, pos[1]+offset),(pos[0]+offset, pos[1]-offset), color) + for r in [10,20,30,40]: + draw_circle(pos, r, color) + + +def draw_markers(): + colors=[(255,0,255),(255,255,0),(0,255,255)] + for i in [0, 1, 2]: + draw_marker(marker[i], colors[i], marker_updated[i]) + def draw_frame(): - global screen, movement, zoom, screensize, input, bot_input + global screen, movement, zoom, screensize, input, bot_input, marker, marker_updated pygame.event.pump() clock.tick() @@ -233,6 +251,9 @@ def draw_frame(): for cell in viruses: draw_cell(cell) + + draw_markers() + draw_leaderboard() total_mass = 0 @@ -258,9 +279,6 @@ def draw_frame(): elif not input and not bot_input: input = True bot_input = False - elif input and not bot_input: - input = True - bot_input = True else: input = False bot_input = True @@ -268,16 +286,16 @@ def draw_frame(): pygame.quit() if event.key == K_r: c.send_respawn() - if input: + if event.type == MOUSEBUTTONDOWN: + if event.button in [1,2,3]: + marker[event.button-1] = win_to_world_pt(event.pos, c.player.center) + marker_updated[event.button-1] = True + print("set marker "+str(event.button-1)+" to "+str(event.pos)) + if input: if event.type == KEYDOWN: if event.key == K_w: c.send_shoot() if event.key == K_SPACE: c.send_split() - if event.type == MOUSEBUTTONDOWN: - if event.button == 1: - c.send_split() - if event.button == 3: - c.send_shoot() if event.type == MOUSEMOTION: c.send_target(*win_to_world_pt(event.pos, c.player.center)) |