diff options
-rw-r--r-- | gui.py | 4 | ||||
-rw-r--r-- | main.py | 15 |
2 files changed, 16 insertions, 3 deletions
@@ -74,7 +74,7 @@ def draw_arc(pos, r, bounds, color, global_coords=True): if global_coords: pos = world_to_win_pt(pos, c.player.center) - gfxdraw.arc(screen, pos[0], pos[1], r, bounds[0], bounds[1], color) + gfxdraw.arc(screen, pos[0], pos[1], r, int(bounds[0]*180/math.pi), int(bounds[1]*180/math.pi), color) def update(): pygame.display.update() @@ -239,4 +239,4 @@ def draw_frame(): if event.type == MOUSEMOTION: c.send_target(*win_to_world_pt(event.pos, c.player.center)) - pygame.display.update()
\ No newline at end of file + pygame.display.update() @@ -45,21 +45,34 @@ while True: runaway=False my_smallest = min(map(lambda cell : cell.mass, c.player.own_cells)) + my_largest = max(map(lambda cell : cell.mass, c.player.own_cells)) forbidden_intervals = [] for cell in c.world.cells.values(): relpos = ((cell.pos[0]-c.player.center[0]),(cell.pos[1]-c.player.center[1])) dist = math.sqrt(relpos[0]**2+relpos[1]**2) - if dist < cell.size*4 and cell.mass > 1.25 * my_smallest: + if (not cell.is_virus and dist < 300+2*cell.size and cell.mass > 1.1 * my_smallest) or (cell.is_virus and dist < cell.size and cell.mass < my_largest): angle = math.atan2(relpos[1],relpos[0]) corridor_width = 2 * math.asin(cell.size / dist) forbidden_intervals += canonicalize_angle_interval((angle-corridor_width, angle+corridor_width)) runaway=True + if c.player.center[0] < c.world.top_left[1]+c.player.total_size: + forbidden_intervals += [(0.5*pi, 1.5*pi)] + if c.player.center[0] > c.world.bottom_right[1]-c.player.total_size: + forbidden_intervals += [(0,0.5*pi), (1.5*pi, 2*pi)] + if c.player.center[1] < c.world.top_left[0]+c.player.total_size: + forbidden_intervals += [(0, pi)] + if c.player.center[1] > c.world.bottom_right[0]-c.player.total_size: + forbidden_intervals += [(pi, 2*pi)] if (runaway): forbidden_intervals = merge_intervals(forbidden_intervals) + + for i in forbidden_intervals: + gui.draw_arc(c.player.center, c.player.total_size+10, i, (255,0,255)) + allowed_intervals = invert_angle_intervals(forbidden_intervals) (a,b) = find_largest_angle_interval(allowed_intervals) |