def __init__(self): self._cache = [] self._deathanims = [] self._debugging = False if '-aabbdebug' in sys.argv: self._debugging = True self._startmap = 'ow8-8.map' if '-startm' in sys.argv: self._startmap = sys.argv[sys.argv.index('-startm')+1] self._starthearts = 3 if '-hearts' in sys.argv: self._starthearts = int(sys.argv[sys.argv.index('-hearts')+1]) random.seed() self._SCREENW=256 self._SCREENH=240 self._MAPW=256 self._MAPH=176 self._OFFSET=self._SCREENH-self._MAPH self._UBOUND = pygame.Rect(0, 0, self._MAPW, 8) self._RBOUND = pygame.Rect(self._MAPW, 0, 8, self._MAPH) self._BBOUND = pygame.Rect(0, self._MAPH, self._MAPW, 8) self._LBOUND = pygame.Rect(-8, 0, 8, self._MAPH) self._TEXTSPEED=4 self._sword = None self._haabb = pygame.Rect(0, Tile.HALF, Tile.SIZE, Tile.HALF) self._vaabb = pygame.Rect(2, Tile.HALF, Tile.SIZE-4, Tile.HALF) self._spelunking = 0 self._zoning = None self._zoom = 2 pygame.init() size = width, height = self._SCREENW*self._zoom, self._SCREENH*self._zoom self._screen = pygame.display.set_mode(size) linkpalette = (((0,0,0),(0,0,0)),((128,128,128),(200,76,12)),((192,192,192),(128,208,16)),((255,255,255),(252,152,56))) wss = Spritesheet(bmpres('weapons.bmp')) self._swordsprite = colorReplace(wss.image_at((0,0,8,16), colorkey=(0,0,0)), linkpalette) ssprite = self._swordsprite lssprite = pygame.transform.rotate(ssprite,90) self._swordsprites = {x:y for x,y in zip(DIRECTIONS, (ssprite, pygame.transform.flip(ssprite,False,True), lssprite, pygame.transform.flip(lssprite,True,False)))} self._lifetxt = Text.get('-LIFE-', (216,40,0)) self._btxt = Text.get('Z')[0] self._atxt = Text.get('X')[0] iss = Spritesheet(bmpres('icons.bmp')) heart = iss.image_at((0,0,8,8), colorkey=(0,0,0)) self._fullheart = colorReplace(heart, (((128,128,128), (216,40,0)),)) self._halfheart = colorReplace(iss.image_at((8,0,8,8), colorkey=(0,0,0)), (((128,128,128),(216,40,0)),((255,255,255),(255,227,171)))) self._emptyheart = colorReplace(heart, (((128,128,128),(255,227,171)),)) self._uibox = {} self._uibox['ul'] = colorReplace(iss.image_at((0,8,8,8), colorkey=(0,0,0)), (((128,128,128),(0,89,250)),)) self._uibox['v'] = colorReplace(iss.image_at((8,8,8,8), colorkey=(0,0,0)), (((128,128,128),(0,89,250)),)) self._uibox['h'] = pygame.transform.rotate(self._uibox['v'], 90) self._uibox['ur'] = pygame.transform.flip(self._uibox['ul'], True, False) self._uibox['br'] = pygame.transform.flip(self._uibox['ur'], False, True) self._uibox['bl'] = pygame.transform.flip(self._uibox['ul'], False, True) self._uirupee, self._uikey, self._uibomb = iss.images_at(((0,16,8,8), (8,16,8,8), (16,16,8,8)), colorkey=(0,0,0)) self._uirupee = colorReplace(self._uirupee, (((128,128,128),(255,161,68)),((255,255,255),(255,227,171)))) self._uikey = colorReplace(self._uikey, (((128,128,128),(255,161,68)),)) self._uibomb = colorReplace(self._uibomb, (((192,192,192),(0,89,250)),)) ss = Spritesheet(bmpres('link.bmp')) s = {} s[Direction.UP] = [colorReplace(sp, (((0,0,0),(0,0,0)),((128,128,128),(200,76,12)),((192,192,192),(128,208,16)),((255,255,255),(252,152,56)))) for sp in ss.images_at(((16,0,16,16),(16,16,16,16)), colorkey=(0,0,0))] s[Direction.DOWN] = [colorReplace(sp, (((0,0,0),(0,0,0)),((128,128,128),(200,76,12)),((192,192,192),(128,208,16)),((255,255,255),(252,152,56)))) for sp in ss.images_at(((0,0,16,16),(0,16,16,16)), colorkey=(0,0,0))] s[Direction.LEFT] = [colorReplace(sp, (((0,0,0),(0,0,0)),((128,128,128),(200,76,12)),((192,192,192),(128,208,16)),((255,255,255),(252,152,56)))) for sp in ss.images_at(((32,0,16,16),(32,16,16,16)), colorkey=(0,0,0))] atks = {} atks[Direction.UP] = colorReplace(ss.image_at((16,32,16,16), colorkey=(0,0,0)), linkpalette) atks[Direction.DOWN] = colorReplace(ss.image_at((0,32,16,16), colorkey=(0,0,0)), linkpalette) atks[Direction.LEFT] = colorReplace(ss.image_at((32,32,16,16), colorkey=(0,0,0)), linkpalette) self._pc = Actor(15*8,11*8,2,self._starthearts*16,8,self._vaabb,True,s,atksprites=atks) self._pc.sethitaabb(pygame.Rect(0,0,16,16)) self._pc.addtriumphs((colorReplace(ss.image_at((48,0,16,16), colorkey=(0,0,0)), linkpalette),colorReplace(ss.image_at((48,16,16,16), colorkey=(0,0,0)), linkpalette))) self._pcweapons = [] self._temps = [] self._startport = Portal(self._startmap, 15*8, 10*8, PortalType.Magic) self._start()