summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Jung <flo@windfisch.org>2015-08-18 00:50:13 +0200
committerFlorian Jung <flo@windfisch.org>2015-08-18 00:50:13 +0200
commit48d6950cbbc2eec66d557861c5507b31bbf3c0e8 (patch)
treeb2f767571c2f016067a23d3bc9ea19faa9329274
parentfc3ed2e3a4748c3168fd621ca96f98cc568f315d (diff)
parent57609975e0ea98c7152859ffd4c965c0879608ad (diff)
Merge branch 'master' into strategy-rework
-rw-r--r--gui.py38
-rw-r--r--installing.txt15
-rw-r--r--strategy.py2
3 files changed, 45 insertions, 10 deletions
diff --git a/gui.py b/gui.py
index 75e087e..92b1982 100644
--- a/gui.py
+++ b/gui.py
@@ -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))
diff --git a/installing.txt b/installing.txt
new file mode 100644
index 0000000..1c8e604
--- /dev/null
+++ b/installing.txt
@@ -0,0 +1,15 @@
+debian wheezy instructions:
+
+ apt-get install python3
+ apt-get install python3-pip
+ cd repo/
+ ln -s agarnet/agarnet fuckthisshit
+ in main.py, change "from agarnet.agarnet import [...]" to
+ "from fuckthisshit import [...]"
+ pip-3.2 install websocket-client
+ there will be an error message about invalid syntax in
+ sock.send(u"<garbage here>"). Ignore it.
+ follow https://wiki.ubuntuusers.de/Pygame
+ do NOT use pip for installing pygame
+
+
diff --git a/strategy.py b/strategy.py
index d8efe4e..da50f9a 100644
--- a/strategy.py
+++ b/strategy.py
@@ -150,4 +150,6 @@ class Strategy:
gui.draw_text(self.target, str(round(zipped[0][1], 2)), (0,0,0), draw_centered = True)
+ gui.draw_text(self.target, str(round(zipped[0][1], 2)), (0,0,0), draw_centered = True)
+
return self.target