Mercurial > mamba
changeset 221:3a652f048f57
Tssss, I smell rats
author | Stefano Rivera <stefano@rivera.za.net> |
---|---|
date | Wed, 14 Sep 2011 22:14:08 +0200 |
parents | 066198428ee9 |
children | 321f2eef40e3 |
files | mamba/snake.py |
diffstat | 1 files changed, 14 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- 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.