summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Jung <flo@windfisch.org>2015-08-24 18:52:36 +0200
committerFlorian Jung <flo@windfisch.org>2015-08-24 18:52:36 +0200
commit8a44a7c1f11211d56d54c185dc8fdc90e35f221b (patch)
tree072eaa27b648377bdadd308ab7774ee27ad6ddeb
parentc2e13a67d969f1208a8b8c127c94a9841c7048d9 (diff)
draw the direction where ejected mass would fly
-rw-r--r--gui.py15
-rw-r--r--subscriber.py10
2 files changed, 22 insertions, 3 deletions
diff --git a/gui.py b/gui.py
index 440e0ef..02e4a42 100644
--- a/gui.py
+++ b/gui.py
@@ -6,6 +6,7 @@ from pygame.locals import *
import sys
import math
import time
+from agarnet.agarnet.vec import Vec
font_fallback = False
try:
@@ -143,10 +144,17 @@ def generate_virus(spikes, spike_length, radius, global_coords):
def draw_cell(cell):
cx,cy = world_to_win_pt(cell.pos,c.player.center)
try:
- cx2,cy2 = world_to_win_pt(cell.poslog[-2],c.player.center)
- except:
+ mov_ang = cell.movement.angle()
+ p2 = cell.pos + Vec( math.cos(mov_ang + 10*math.pi/180), math.sin(mov_ang + 10*math.pi/180) ) * (cell.size+700)
+ p3 = cell.pos + Vec( math.cos(mov_ang - 10*math.pi/180), math.sin(mov_ang - 10*math.pi/180) ) * (cell.size+700)
+
+ cx2,cy2 = world_to_win_pt(p2,c.player.center)
+ cx3,cy3 = world_to_win_pt(p3,c.player.center)
+ except AttributeError:
print("wtf, no poslog available?!")
cx2,cy2=cx,cy
+ cx3,cy3=cx,cy
+
radius = world_to_win_length(cell.size)
if cell.is_virus:
@@ -164,9 +172,10 @@ def draw_cell(cell):
else:
color=(int(cell.color[0]*255), int(cell.color[1]*255), int(cell.color[2]*255))
- gfxdraw.filled_circle(screen, cx2, cy2, radius, (127,127,127))
if not (cell.is_ejected_mass or cell.is_food):
+ gfxdraw.aapolygon(screen, [(cx,cy),(cx2,cy2),(cx3,cy3),(cx,cy)] ,(255,127,127))
+
gfxdraw.filled_circle(screen, cx, cy, radius, color)
gfxdraw.aacircle(screen, cx, cy, radius, (0,0,0))
diff --git a/subscriber.py b/subscriber.py
index 1dcccc6..feddf04 100644
--- a/subscriber.py
+++ b/subscriber.py
@@ -95,4 +95,14 @@ class EnhancingSubscriber(DummySubscriber):
self.history[cid].stale = False
self.history = {k: v for k, v in self.history.items() if v.stale == False}
+
+ for cid in self.c.world.cells:
+ cell = self.c.world.cells[cid]
+ try:
+ oldpos = cell.poslog[-3-1]
+ cell.movement = (cell.pos - oldpos)/3
+ except (AttributeError, IndexError):
+ # no oldpos available
+ cell.movement = None
+ pass