diff options
Diffstat (limited to 'fish_types.py')
| -rw-r--r-- | fish_types.py | 56 |
1 files changed, 32 insertions, 24 deletions
diff --git a/fish_types.py b/fish_types.py index 61cd36a..6d24675 100644 --- a/fish_types.py +++ b/fish_types.py @@ -11,6 +11,9 @@ class Fish(object): Must override color (or color_at), drag, width, height, tailThreshold, tailDuration, tailAccelMag """ + + is_diamond = True + def __init__(self, x=None, y=None): """Create fish with default parameters.""" if x is not None: @@ -23,6 +26,7 @@ class Fish(object): self.y = 0.5 self.speed = C.Vector(0, 0) self.tailAcceleration = C.Vector(self.tailAccelMag, 0) + self.tailThresholdCurrent = self.tailThreshold self.tailMoving = False self.tailMoveCount = 0 if not hasattr(self, 'theta_scale'): @@ -55,9 +59,11 @@ class Fish(object): return False self.speed += self.drag * self.speed - if abs(self.speed) < self.tailThreshold: + if abs(self.speed) < self.tailThresholdCurrent: self.tailMoving = True - self.tailThreshold = rand_in_range(0.5, 1.4) + self.tailThresholdCurrent = max(rand_in_range( + self.tailThreshold - 0.1, self.tailThreshold + 0.1 + ), 0.0001) self.fix_direction() if self.tailMoveCount > self.tailDuration: self.tailMoveCount = 0 @@ -97,22 +103,22 @@ class Fish(object): class Jellyfish(Fish): color = C.HSV(298/360, 89/100, 53/100).to_RGB() - drag = -0.01 + drag = -0.1 width = 15 height = 1.5 - tailThreshold = 0.001 - tailDuration = 4 - tailAccelMag = 0.001 + tailThreshold = 0.2 + tailDuration = 6 + tailAccelMag = 0.25 class Dolphin(Fish): - color = C.HSV(18/360, 0/100, 40/100).to_RGB() + color = C.HSV(18/360, 0/100, 10/100).to_RGB() drag = -0.09 width = 35 height = 1.5 tailThreshold = 0.7 tailDuration = 2 - tailAccelMag = 0.8 + tailAccelMag = 0.4 gravity = C.Vector(0, -0.01) direction_fixed = False @@ -156,7 +162,7 @@ class Boat(Fish): class Dory(Fish): # Need to try this on the bridge - color = C.HSV(235/360, 100/100, 88/100).to_RGB() + color = C.HSV(235/360, 100/100, 100/100).to_RGB() drag = -0.1 width = 23 height = 1.5 @@ -166,7 +172,7 @@ class Dory(Fish): class Nemo(Fish): - color = C.HSV(31/360, 100/100, 50/100).to_RGB() + color = C.HSV(40/360, 100/100, 10/100).to_RGB() drag = -0.09 width = 23 height = 1.5 @@ -177,7 +183,7 @@ class Nemo(Fish): class Whale(Fish): drag = -0.2 - width = 50 + width = 80 height = 2 tailThreshold = 0.7 tailDuration = 3 @@ -186,10 +192,10 @@ class Whale(Fish): y = 0 - white_x_min = 30 - white_x_width = 8 - white_y_min = 1 - white_y_height = 1 + white_x_min = 58 + white_x_width = 6 + white_y_min = 1.45 + white_y_height = 0.5 def color_at(self, x, y): """Mostly copied from compute_coverage. @@ -209,7 +215,7 @@ class Whale(Fish): class Stingray(Fish): - color = C.HSV(0/360, 0/100, 50/100).to_RGB() + color = C.HSV(0/360, 0/100, 10/100).to_RGB() drag = -0.09 width = 15 height = 2 @@ -219,27 +225,29 @@ class Stingray(Fish): class Eel(Fish): - color = C.HSV(109/360, 83/100, 35/100).to_RGB() + color = C.HSV(109/360, 83/100, 0/100).to_RGB() drag = -0.09 - width = 50 + width = 30 height = 2 tailThreshold = 0.7 tailDuration = 2 - tailAccelMag = 0.1 + tailAccelMag = 0.2 front_offset = 0 y = 0 + is_diamond = False def alpha_at(self, x, y): rel_x = x - self.x - rel_y = y - self.y eel_height = math.sin( 2 * math.pi * (rel_x + self.front_offset) / self.width ) / 2 + 0.5 - y_blend = abs(rel_y - eel_height) - if y_blend > 0.5: + y_blend = abs(y - eel_height) + if y_blend > 0.75: return 0 - return (1 - y_blend) + if y_blend < 0.25: + return 1 + return 1 - y_blend def update(self): self.front_offset += abs(self.speed) @@ -252,7 +260,7 @@ class Eel(Fish): class Shark(Fish): - color = C.HSV(0/360, 0/100, 50/100).to_RGB() + color = C.HSV(0/360, 0/100, 10/100).to_RGB() drag = -0.2 width = 50 height = 2 |
