From 2d37dd487f0571ce94a0e4e966931dd6697d685f Mon Sep 17 00:00:00 2001 From: Aaron Perley Date: Tue, 11 Oct 2016 02:03:49 -0400 Subject: Add event passing between webapp and show --- fish_show.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'fish_show.py') diff --git a/fish_show.py b/fish_show.py index 51693e4..d42e520 100644 --- a/fish_show.py +++ b/fish_show.py @@ -52,7 +52,7 @@ class Fish(object): if self.x < -self.width: self.x = constants.BRIDGE_WIDTH - print(self.x, self.y) + #print(self.x, self.y) def fix_direction(self): min_theta = -0.32 @@ -145,12 +145,17 @@ class FishShow(Show): self.lights = [Light(x, y, self.bridge.get_light(x, y)) for y in xrange(self.bridge.HEIGHT) for x in xrange(self.bridge.WIDTH)] - random_hue = random.random() - fish_color = color.HSV(random_hue, 1, 20/100).to_RGB() - self.fishes = [Fish(0, 0.5, 23, 1.5, fish_color, 1), Fish(100, 0.5, 23, 1.5, fish_color, 1)] + self.fishes = [] + self.send_event('new creature', {'name': 'test fishy'}) def update(self): + event = self.recv_event() + if event and event[0] == 'spawn': + random_hue = random.random() + fish_color = color.HSV(random_hue, 1, 20/100).to_RGB() + self.fishes.append(Fish(0, 0.5, 23, 1.5, fish_color, 1)) + for fish in self.fishes: fish.update() for light in self.lights: -- cgit v1.3.1