summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSpitfireX <timm.weber@me.com>2015-08-11 04:43:04 +0200
committerSpitfireX <timm.weber@me.com>2015-08-11 04:43:04 +0200
commitbb709bd6ae7245d681ad2d401ba72e7ba96281f6 (patch)
tree5faf68054e0618916d6614a1cc5a626342aac1a7
parent6b7c7479a3fb8afac15a506115b16b247b4c7680 (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)
-rw-r--r--README1
-rw-r--r--gui.py22
-rw-r--r--main.py3
3 files changed, 22 insertions, 4 deletions
diff --git a/README b/README
index 4f129d8..ffad25c 100644
--- a/README
+++ b/README
@@ -8,4 +8,5 @@ left click, space = split
right click, w = eject some mass
r = respawn
s = lock input
+b = lock bot input
esc = quit
diff --git a/gui.py b/gui.py
index 6e46e73..8e3fb84 100644
--- a/gui.py
+++ b/gui.py
@@ -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:
diff --git a/main.py b/main.py
index ba21071..15e438b 100644
--- a/main.py
+++ b/main.py
@@ -119,7 +119,8 @@ while True:
color = (0,255,0)
print("Nothing to do, heading to random targetination: " + str((rx, ry)))
- c.send_target(target[0], target[1])
+ if gui.bot_input:
+ c.send_target(target[0], target[1])
gui.draw_line(c.player.center, target, color)
gui.update()
stats.log_pos(c.player.center)