diff options
author | SpitfireX <timm.weber@me.com> | 2015-08-11 04:43:04 +0200 |
---|---|---|
committer | SpitfireX <timm.weber@me.com> | 2015-08-11 04:43:04 +0200 |
commit | bb709bd6ae7245d681ad2d401ba72e7ba96281f6 (patch) | |
tree | 5faf68054e0618916d6614a1cc5a626342aac1a7 /gui.py | |
parent | 6b7c7479a3fb8afac15a506115b16b247b4c7680 (diff) |
Fixed render order and added bot input locking
- the render order is now strictly food < cells(small -> big) ->
viruses(small -> big)
- added the option to lock the bot input (b key)
Diffstat (limited to 'gui.py')
-rw-r--r-- | gui.py | 22 |
1 files changed, 19 insertions, 3 deletions
@@ -20,6 +20,7 @@ else: logging = False input = False +bot_input = True clock = pygame.time.Clock() screensize=(1280, 800) @@ -190,7 +191,7 @@ def set_client(cl): c=cl def draw_frame(): - global screen, movement, zoom, screensize, input + global screen, movement, zoom, screensize, input, bot_input pygame.event.pump() clock.tick() @@ -198,16 +199,29 @@ def draw_frame(): screen.fill((255,255,255)) draw_world_borders() - for cell in c.world.cells.values(): + food = list(filter(lambda x: x.is_food, c.world.cells.values())) + + cells = list(filter(lambda x: not x.is_food and not x.is_virus, c.world.cells.values())) + cells = sorted(cells, key = lambda x: x.mass) + + viruses = list(filter(lambda x: x.is_virus, c.world.cells.values())) + viruses = sorted(cells, key = lambda x: x.mass) + + for cell in food: draw_cell(cell) + for cell in cells: + draw_cell(cell) + + for cell in viruses: + draw_cell(cell) draw_leaderboard() total_mass = 0 for cell in c.player.own_cells: total_mass += cell.mass - pygame.display.set_caption("Agar.io: " + str(c.player.nick) + " - " + str(int(total_mass)) + " Total Mass - " + str(int(clock.get_fps())) + (" FPS - INPUT LOCKED" if not input else " FPS")) + pygame.display.set_caption("Agar.io: " + str(c.player.nick) + " - " + str(int(total_mass)) + " Total Mass - " + str(int(clock.get_fps())) + (" FPS - INPUT LOCKED" if not input else " FPS") + (" - BOT INPUT LOCKED" if not bot_input else "")) events = pygame.event.get() for event in events: @@ -221,6 +235,8 @@ def draw_frame(): if event.type == KEYDOWN: if event.key == K_s: input = not input + if event.key == K_b: + bot_input = not bot_input if event.key == K_ESCAPE: pygame.quit() if event.key == K_r: |