summaryrefslogtreecommitdiffstats
path: root/sunrise.py
diff options
context:
space:
mode:
authorAaron Perley <aaron.perley@gmail.com>2016-10-09 18:00:10 -0400
committerAaron Perley <aaron.perley@gmail.com>2016-10-09 18:00:10 -0400
commitf05ccbe166fd2501be3502f81f0562e73291fa04 (patch)
treecbc4eb9b8de594533e4f8b262385652b0dfd0309 /sunrise.py
parentf0cb39571e4ac16b6fab6b04c26e17897e61f9f5 (diff)
downloadbridge-f05ccbe166fd2501be3502f81f0562e73291fa04.tar.zst
Refactor bridge, fish show, and sunrise show code
Diffstat (limited to 'sunrise.py')
-rw-r--r--sunrise.py28
1 files changed, 13 insertions, 15 deletions
diff --git a/sunrise.py b/sunrise.py
index 68a423c..7e11ee3 100644
--- a/sunrise.py
+++ b/sunrise.py
@@ -5,8 +5,9 @@ import random
import constants
from constants import *
import math
+from show import Show
-class Fish(object):
+class Sun(object):
"""Object displayed on the bridge, probably a fish."""
def __init__(self, x, y, width, height, c, step):
"""Create fish with default parameters."""
@@ -33,7 +34,7 @@ class Fish(object):
#theta = random.random() * math.pi / 2 - math.pi / 4
#self.y += 0.01 * math.sin(theta)
#print(self.y)
- self.y += 0.000005
+ self.y += 0.005
if self.y >= 1:
self.y = 1
self.wait += 1
@@ -66,21 +67,18 @@ class Light(object):
)
-class Bridge(object):
- """Store objects on the bridge."""
- def __init__(self, lights, fish, rig):
- """Initialize with lights and fish."""
- self.lights = lights
- self.fish = fish
- self.rig = rig
+class SunriseShow(Show):
+ def init(self):
+ 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)]
+ self.sun = Sun(0, 0, 23, 1.5, color.black, 1)
+
def update(self):
- """Compute fish coverages and push lights to bridge."""
- for x, light_col in enumerate(self.lights):
- for y, light in enumerate(light_col):
- self.fish.update()
- light.update(self.fish)
- self.rig.updateOnce()
+ self.sun.update()
+ for light in self.lights:
+ light.update(self.sun)
def compute_coverage(fish, x, y):