Changeset 408:02a6de5629d6


Ignore:
Timestamp:
Nov 21, 2009, 9:40:29 AM (11 years ago)
Author:
Neil Muller <drnlmuller@…>
Branch:
default
Convert:
svn:b4e93282-eac8-4b8b-b765-0f5d36de2b68/trunk/rinkhals@413
Message:

Levels can include starting equipment

Files:
4 edited

Legend:

Unmodified
Added
Removed
  • docs/Level_structure

    r387 r408  
    44two layers of pgu's tilemap - the tile layer, for the objects of interest,
    55and the code layer, which indicates the starting chicken positions.
     6
     7Different codes mean chickens ahve different levels of equipment.
     8
     901 - chicken with no equipment
     1002 - chicken with helmet
     1103 - chicken with kevlar
     1204 - chicken with knife
     1305 - chicken with rifle
     1406 - chicken with kevlar & helmet
     1507 - chicken with helmet & knife
     1608 - chicken with kevlar & knife
     1709 - chicken with kevlar, helmet & knife
     1810 - chicken with helmet & rifle
     1911 - chicken with kevlar & rifle
     2012 - chicken with kevlar, helmet & rifle
    621
    722The level.conf file allows the default game constants to be customised.
  • gamelib/equipment.py

    r380 r408  
    197197    except TypeError:
    198198        pass
     199
     200
     201EQUIP_MAP = { # Map chicken level codes to equipment
     202        1  : [],
     203        2  : [Helmet],
     204        3  : [Kevlar],
     205        4  : [Knife],
     206        5  : [Rifle],
     207        6  : [Kevlar, Helmet],
     208        7  : [Helmet, Knife],
     209        8  : [Kevlar, Knife],
     210        9  : [Kevlar, Helmet, Knife],
     211        10 : [Helmet, Rifle],
     212        11 : [Kevlar, Rifle],
     213        12 : [Kevlar, Helmet, Rifle],
     214        }
  • gamelib/gameboard.py

    r405 r408  
    303303        self.fix_buildings()
    304304
    305         cdata = {
    306                 1 : (self.add_start_chickens, None),
    307                 }
     305        cdata = {}
     306        for tn in equipment.EQUIP_MAP:
     307            cdata[tn]  = (self.add_start_chickens, tn)
    308308
    309309        self.tv.run_codes(cdata, (0,0,width,height))
     
    938938        self.toolbar.update_cash_counter(self.cash)
    939939
    940     def add_start_chickens(self, _map, tile, _value):
     940    def add_start_chickens(self, _map, tile, value):
    941941        """Add chickens as specified by the code layer"""
    942942        chick = animal.Chicken((tile.tx, tile.ty))
     943        for equip_cls in equipment.EQUIP_MAP[value]:
     944            item = equip_cls()
     945            chick.equip(item)
    943946        self.add_chicken(chick)
    944947
  • regenerate_level_data.py

    r386 r408  
    66from pygame.locals import SWSURFACE, SRCALPHA
    77
    8 from gamelib import tiles, buildings
     8from gamelib import tiles, buildings, equipment
    99import regenerate_pngs
    1010
     
    4141def get_code_mappings():
    4242    code_map = {}
    43     # this list needs to manually kept in sync. This should be fixed
    44     for tn, sprite_name in [(1, 'chkn')]:
    45         image = generate_image(sprite_name, regenerate_pngs.SPRITE_PATH)
     43    # Needs better handling of wings
     44    for tn, sprites in equipment.EQUIP_MAP.iteritems():
     45        image = generate_image('chkn', regenerate_pngs.SPRITE_PATH)
     46        need_wing = False
     47        for equip in sprites:
     48            sub_image = generate_image(equip.CHICKEN_IMAGE_FILE,
     49                    regenerate_pngs.SPRITE_PATH)
     50            image.blit(sub_image, (0, 0))
     51            if equip.UNDER_LIMB:
     52                need_wing = True
     53        if need_wing:
     54            sub_image = generate_image('wing', regenerate_pngs.SPRITE_PATH)
     55            image.blit(sub_image, (0, 0))
    4656        if image:
    4757            code_map[tn] = image
Note: See TracChangeset for help on using the changeset viewer.