# HG changeset patch # User Stefano Rivera # Date 1316031248 -7200 # Node ID 3a652f048f57a971c8712848d6a173ba783bba0d # Parent 066198428ee90005ffc56e1ca7c628706439a47d Tssss, I smell rats diff -r 066198428ee9 -r 3a652f048f57 mamba/snake.py --- a/mamba/snake.py Wed Sep 14 22:12:01 2011 +0200 +++ b/mamba/snake.py Wed Sep 14 22:14:08 2011 +0200 @@ -1,5 +1,7 @@ """The player snake object.""" +import random + from pygame.sprite import Group, spritecollide from mamba.constants import TILE_SIZE, UP, DOWN, LEFT, RIGHT @@ -70,7 +72,7 @@ tile_state = self.head.get_tile_state() shifted, ds = self.head.shift_head(ds) if shifted: - self.head.mouth_close() + self.head.shifted_tile() else: break if self.pending_segments: @@ -187,6 +189,9 @@ self.set_tile_pos(tile_pos) self.orientation = orientation + def shifted_tile(self): + pass + def shift_pixels(self, distance): """Shift this segment a number of pixels.""" dx, dy = self.orientation @@ -226,6 +231,14 @@ self.make_images() self.update_image() + def shifted_tile(self): + if random.random() < 0.02: + self.mouth_open() + self.tongue_out() + else: + self.mouth_close() + self.tongue_in() + def shift_head(self, ds): """Shift the head a number of pixels in the direction of it orientation.