diff options
| -rw-r--r-- | fish_show.py | 101 | ||||
| -rw-r--r-- | webapp/app/templates/index.html | 24 |
2 files changed, 64 insertions, 61 deletions
diff --git a/fish_show.py b/fish_show.py index a94a422..7af4c0b 100644 --- a/fish_show.py +++ b/fish_show.py @@ -127,63 +127,64 @@ class FishShow(Show): def update(self): event = self.recv_event() - if event and event[0] == 'spawn': - new_fish = Fish.by_type(event[1]['type']) - if new_fish: - self.fishes.add(new_fish) + if self.depth <= self.MAX_DEPTH: + if event and event[0] == 'spawn': + new_fish = Fish.by_type(event[1]['type']) + if new_fish: + self.fishes.add(new_fish) - for col in self.lights: - for light in col: - light.update_base(self.depth) + for col in self.lights: + for light in col: + light.update_base(self.depth) - for fish in list(self.fishes): - if not fish.update(): - self.fishes.remove(fish) + for fish in list(self.fishes): + if not fish.update(): + self.fishes.remove(fish) - for x in xrange(int(fish.x), int(fish.x+fish.width+1)): - if x < len(self.lights): - for light in self.lights[x]: - light.update_fish(fish) + for x in xrange(int(fish.x), int(fish.x+fish.width+1)): + if x < len(self.lights): + for light in self.lights[x]: + light.update_fish(fish) - for col in self.lights: - for light in col: - light.blit() + for col in self.lights: + for light in col: + light.blit() - self.tick_count += 1 - if self.tick_count % self.TICKS_PER_DEPTH == 0: - self.depth += 1 - print("DEPTH: ", self.depth) - if self.depth == 1: - """boat, dolphin""" - self.send_event('enable image', {'name': 'boat'}) - self.send_event('enable image', {'name': 'dolphin'}) - elif self.depth == 2: - """dolphin, jellyfish""" - self.send_event('disable image', {'name': 'boat'}) - self.send_event('enable image', {'name': 'jellyfish'}) - elif self.depth == 3: - """jellyfish, nemo, dory, whale""" - self.send_event('disable image', {'name': 'dolphin'}) - self.send_event('enable image', {'name': 'nemo'}) - self.send_event('enable image', {'name': 'dory'}) - self.send_event('enable image', {'name': 'whale'}) - elif self.depth == 4: - """nemo, dory, whale, shark""" - self.send_event('disable image', {'name': 'jellyfish'}) - self.send_event('enable image', {'name': 'shark'}) - elif self.depth == 5: - """whale, shark, stingray""" - self.send_event('disable image', {'name': 'nemo'}) - self.send_event('disable image', {'name': 'dory'}) - self.send_event('enable image', {'name': 'stingray'}) - elif self.depth == 6: - """stingray, eel""" - self.send_event('disable image', {'name': 'whale'}) - self.send_event('disable image', {'name': 'shark'}) - self.send_event('enable image', {'name': 'eel'}) + self.tick_count += 1 + if self.tick_count % self.TICKS_PER_DEPTH == 0: + self.depth += 1 + print("DEPTH: ", self.depth) + if self.depth == 1: + """boat, dolphin""" + self.send_event('enable image', {'name': 'boat'}) + self.send_event('enable image', {'name': 'dolphin'}) + elif self.depth == 2: + """dolphin, jellyfish""" + self.send_event('disable image', {'name': 'boat'}) + self.send_event('enable image', {'name': 'jellyfish'}) + elif self.depth == 3: + """jellyfish, nemo, dory, whale""" + self.send_event('disable image', {'name': 'dolphin'}) + self.send_event('enable image', {'name': 'nemo'}) + self.send_event('enable image', {'name': 'dory'}) + self.send_event('enable image', {'name': 'whale'}) + elif self.depth == 4: + """nemo, dory, whale, shark""" + self.send_event('disable image', {'name': 'jellyfish'}) + self.send_event('enable image', {'name': 'shark'}) + elif self.depth == 5: + """whale, shark, stingray""" + self.send_event('disable image', {'name': 'nemo'}) + self.send_event('disable image', {'name': 'dory'}) + self.send_event('enable image', {'name': 'stingray'}) + elif self.depth == 6: + """stingray, eel""" + self.send_event('disable image', {'name': 'whale'}) + self.send_event('disable image', {'name': 'shark'}) + self.send_event('enable image', {'name': 'eel'}) - if self.depth > self.MAX_DEPTH: + else: self.send_event('disable image', {'name': 'stingray'}) self.send_event('disable image', {'name': 'eel'}) diff --git a/webapp/app/templates/index.html b/webapp/app/templates/index.html index a61b59f..7c09f50 100644 --- a/webapp/app/templates/index.html +++ b/webapp/app/templates/index.html @@ -43,37 +43,37 @@ <!-- Three columns of text below the carousel --> <div class="row"> <div class="col-lg-4"> - <img id="jellyfish" onClick="clickImg(this)" class="img-circle" src="http://i.imgur.com/wZl8BhW.jpg" alt="Generic placeholder image" width="140" height="140"> + <img id="jellyfish" onClick="clickImg(this)" class="img-disable img-circle" src="http://i.imgur.com/wZl8BhW.jpg" alt="Generic placeholder image" width="140" height="140"> </div><!-- /.col-lg-4 --> <div class="col-lg-4"> - <img id="dolphin" onClick="clickImg(this)" class="img-circle" src="http://i.imgur.com/MLP3x37.jpg" alt="Generic placeholder image" width="140" height="140"> + <img id="dolphin" onClick="clickImg(this)" class="img-disable img-circle" src="http://i.imgur.com/MLP3x37.jpg" alt="Generic placeholder image" width="140" height="140"> </div><!-- /.col-lg-4 --> <div class="col-lg-4"> - <img id="boat" onClick="clickImg(this)" class="img-circle" src="http://i.imgur.com/ZU8sA8Z.jpg" alt="Generic placeholder image" width="140" height="140"> + <img id="boat" onClick="clickImg(this)" class="img-disable img-circle" src="http://i.imgur.com/ZU8sA8Z.jpg" alt="Generic placeholder image" width="140" height="140"> </div><!-- /.col-lg-4 --> </div><!-- /.row --> <br> <div class="row"> <div class="col-lg-4"> - <img id="dory" onClick="clickImg(this)" class="img-circle" src="http://i.imgur.com/Ky67jAq.jpg" alt="Generic placeholder image" width="150" height="150"> + <img id="dory" onClick="clickImg(this)" class="img-disable img-circle" src="http://i.imgur.com/Ky67jAq.jpg" alt="Generic placeholder image" width="150" height="150"> </div><!-- /.col-lg-4 --> <div class="col-lg-4"> - <img id="nemo" onClick="clickImg(this)" class="img-circle" src="http://i.imgur.com/XGxdSI0.jpg" alt="Generic placeholder image" width="140" height="140"> + <img id="nemo" onClick="clickImg(this)" class="img-disable img-circle" src="http://i.imgur.com/XGxdSI0.jpg" alt="Generic placeholder image" width="140" height="140"> </div><!-- /.col-lg-4 --> <div class="col-lg-4"> - <img id="whale" onClick="clickImg(this)" class="img-circle" src="http://i.imgur.com/s3J3Csx.jpg" alt="Generic placeholder image" width="140" height="140"> + <img id="whale" onClick="clickImg(this)" class="img-disable img-circle" src="http://i.imgur.com/s3J3Csx.jpg" alt="Generic placeholder image" width="140" height="140"> </div><!-- /.col-lg-4 --> </div><!-- /.row --> <br> <div class="row"> <div class="col-lg-4"> - <img id="stingray" onClick="clickImg(this)" class="img-circle" src="http://i.imgur.com/RuOqhqh.jpg" alt="Generic placeholder image" width="140" height="140"> + <img id="stingray" onClick="clickImg(this)" class="img-disable img-circle" src="http://i.imgur.com/RuOqhqh.jpg" alt="Generic placeholder image" width="140" height="140"> </div><!-- /.col-lg-4 --> <div class="col-lg-4"> - <img id="eel" onClick="clickImg(this)" class="img-circle" src="http://i.imgur.com/RmK7wJv.jpg" alt="Generic placeholder image" width="140" height="140"> + <img id="eel" onClick="clickImg(this)" class="img-disable img-circle" src="http://i.imgur.com/RmK7wJv.jpg" alt="Generic placeholder image" width="140" height="140"> </div><!-- /.col-lg-4 --> <div class="col-lg-4"> - <img id="shark" onClick="clickImg(this)" class="img-circle" src="http://i.imgur.com/6AuJ36F.jpg" alt="Generic placeholder image" width="140" height="140"> + <img id="shark" onClick="clickImg(this)" class="img-disable img-circle" src="http://i.imgur.com/6AuJ36F.jpg" alt="Generic placeholder image" width="140" height="140"> </div><!-- /.col-lg-4 --> </div><!-- /.row --> @@ -158,8 +158,10 @@ //myImgElement.addClass('img-disable'); // ----------------------------- - var c = new creature(element.id, socket); - c.click() + if( !$(element).hasClass('img-disable') ) { + var c = new creature(element.id, socket); + c.click(); + } } </script> |
