From 3650968ecf576fceae841f0ccd72cd8459b4aa01 Mon Sep 17 00:00:00 2001 From: SpitfireX Date: Wed, 12 Aug 2015 05:24:58 +0200 Subject: Made gui surface update explicit + some angle stuff --- gui.py | 2 -- interval_utils.py | 8 +++++++- main.py | 1 + strategy.py | 1 - 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/gui.py b/gui.py index 55000da..688c095 100644 --- a/gui.py +++ b/gui.py @@ -269,5 +269,3 @@ def draw_frame(): c.send_shoot() if event.type == MOUSEMOTION: c.send_target(*win_to_world_pt(event.pos, c.player.center)) - - pygame.display.update() diff --git a/interval_utils.py b/interval_utils.py index 4c3f8e2..e95445a 100644 --- a/interval_utils.py +++ b/interval_utils.py @@ -45,4 +45,10 @@ def find_largest_angle_interval(intervals): intervals_ = intervals return max(intervals_, key=lambda p:p[1]-p[0]) - + +def get_point_angle(origin, p): + dx = p[0] - origin[0] + dy = p[1] - origin[1] + rads = atan2(-dy,dx) + rads %= 2*pi + return rads diff --git a/main.py b/main.py index 60fb8ad..d747869 100644 --- a/main.py +++ b/main.py @@ -53,3 +53,4 @@ while True: stats.log_pos(c.player.center) stats.log_mass(c.player.total_mass) + gui.update() \ No newline at end of file diff --git a/strategy.py b/strategy.py index 92e0ad2..1f1995f 100644 --- a/strategy.py +++ b/strategy.py @@ -98,6 +98,5 @@ class Strategy: # more debugging gui.draw_line(c.player.center, self.target, self.color) - gui.update() return self.target -- cgit v1.2.1