Changeset 53:f20dd3dcb118


Ignore:
Timestamp:
Aug 31, 2009, 5:47:10 PM (11 years ago)
Author:
Adrianna Pińska <adrianna.pinska@…>
Branch:
default
Convert:
svn:b4e93282-eac8-4b8b-b765-0f5d36de2b68@54
Message:

foxes don't run backwards

Location:
gamelib
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • gamelib/animal.py

    r47 r53  
    88    """Base class for animals"""
    99
    10     def __init__(self, image, pos):
     10    def __init__(self, image_left, image_right, pos):
    1111        # Create the animal somewhere far off screen
    12         Sprite.__init__(self, image, (-1000, -1000))
     12        Sprite.__init__(self, image_left, (-1000, -1000))
     13        self.image_left = image_left
     14        self.image_right = image_right
    1315        self.pos = pos
    1416
     
    2729
    2830    def __init__(self, pos):
    29         image = imagecache.load_image('sprites/chkn.png')
    30         Animal.__init__(self, image, pos)
     31        image_left = imagecache.load_image('sprites/chkn.png')
     32        image_right = imagecache.load_image('sprites/chkn.png', ("right_facing",))
     33        Animal.__init__(self, image_left, image_right, pos)
    3134
    3235    def move(self, gameboard):
     
    3942    def __init__(self, pos):
    4043        image = imagecache.load_image('sprites/egg.png')
    41         Animal.__init__(self, image, pos)
     44        Animal.__init__(self, image, image, pos)
    4245
    4346    # Eggs don't move
     
    4750
    4851    def __init__(self, pos):
    49         image = imagecache.load_image('sprites/fox.png')
     52        image_left = imagecache.load_image('sprites/fox.png')
     53        image_right = imagecache.load_image('sprites/fox.png', ("right_facing",))
    5054        self.full = False
    51         Animal.__init__(self, image, pos)
     55        Animal.__init__(self, image_left, image_right, pos)
    5256
    5357    def move(self, gameboard):
     
    7074        if min_vec[0] < 0:
    7175            xpos -= 1
     76            self.setimage(self.image_left)
    7277        elif min_vec[0] > 0:
    7378            xpos += 1
     79            self.setimage(self.image_right)
    7480        if min_vec[1] < 0:
    7581            ypos -= 1
  • gamelib/imagecache.py

    r41 r53  
    6666    return night_image
    6767
     68def convert_to_right_facing(image):
     69    right_facing_image = image.copy()
     70    right_facing_image = pygame.transform.flip(right_facing_image, 1, 0)
     71    return right_facing_image
     72
    6873# globals
    6974
    7075cache = ImageCache()
    7176cache.register_modifier("night", convert_to_night)
     77cache.register_modifier("right_facing", convert_to_right_facing)
    7278load_image = cache.load_image
Note: See TracChangeset for help on using the changeset viewer.