Mercurial > mamba
changeset 425:37b7b045166a
Fix snake initial orientation. (Hint: it is not always UP.)
author | Jeremy Thurgood <firxen@gmail.com> |
---|---|
date | Sat, 17 Sep 2011 18:16:11 +0200 |
parents | ba6faea9929f |
children | 291fa745a840 |
files | mamba/level.py mamba/snake.py |
diffstat | 2 files changed, 11 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/mamba/level.py Sat Sep 17 17:56:56 2011 +0200 +++ b/mamba/level.py Sat Sep 17 18:16:11 2011 +0200 @@ -287,6 +287,7 @@ for x in range(sx) for y in range(sy)] def get_entry(self): + print self.entry.tile_pos, self.entry.direction return (self.entry.tile_pos, self.entry.direction) def draw(self, surface):
--- a/mamba/snake.py Sat Sep 17 17:56:56 2011 +0200 +++ b/mamba/snake.py Sat Sep 17 18:16:11 2011 +0200 @@ -23,7 +23,7 @@ self.pending_segments = [] # segments waiting to be added self.segment_group = Group() self.segment_group.add(*reversed(self.segments)) - self.orientation = orientation + self.set_orientation(orientation) self.speed = 120.0 # pixel / s self.frac_ds = 0.0 self.mutation = None @@ -34,11 +34,9 @@ tail = property(fget=lambda self: self.segments[-1]) def create_segments(self, tile_pos, orientation): - tx, ty = tile_pos - dx, dy = orientation segments = [] for cls in [Head] + [Body] * INITIAL_SEGMENT_COUNT + [Tail]: - segments.append(cls((tx, ty))) + segments.append(cls(tile_pos, orientation)) return segments def add_segment(self, segment=None): @@ -176,11 +174,11 @@ is_head = False - def __init__(self, image_name, tile_pos): + def __init__(self, image_name, tile_pos, orientation): super(Segment, self).__init__() self.set_base_image(image_name) self.colour = self.GREEN - self.orientation = UP + self.orientation = orientation self.make_images() self.update_image() @@ -297,9 +295,9 @@ is_head = True - def __init__(self, tile_pos): + def __init__(self, tile_pos, orientation): self._detail_mutators = (self.EYE,) - super(Head, self).__init__(self.CLOSED, tile_pos) + super(Head, self).__init__(self.CLOSED, tile_pos, orientation) def mouth_open(self): self.set_base_image(self.OPEN) @@ -331,8 +329,8 @@ class Body(Segment): - def __init__(self, tile_pos): - super(Body, self).__init__("snake-body", tile_pos) + def __init__(self, tile_pos, orientation): + super(Body, self).__init__("snake-body", tile_pos, orientation) class Tail(Segment): @@ -341,8 +339,8 @@ "amphibious": mutators.Overlay("snake/snake-tail-puddle-r"), } - def __init__(self, tile_pos): - super(Tail, self).__init__("snake-tail-r", tile_pos) + def __init__(self, tile_pos, orientation): + super(Tail, self).__init__("snake-tail-r", tile_pos, orientation) def show_mutation(self, mutation): self._detail_mutators = (self.INDICATORS[mutation],)