Skip to content

Commit

Permalink
fix palettes on new sprites (Die4Ever#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
Die4Ever committed Jul 26, 2022
1 parent 3ece57d commit 3247dff
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
17 changes: 10 additions & 7 deletions BuildLibs/buildmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ def ReadHeaders(self, data):

def CreateSpritePacker(self):
self.spritePacker = FancyPacker('<', OrderedDict(
pos='iii', cstat='h', picnum='h', gfxstuff='bBB', filler='B',
texcoords='BBbb', sectnum='h', statnum='h', angle='h',
pos='iii', cstat='h', picnum='h', shade='b', palette='B', clipdist='B',
filler='B', texcoords='BBbb', sectnum='h', statnum='h', angle='h',
owner='h', velocity='hhh', lowtag='h', hightag='h', extra='h')
)

Expand Down Expand Up @@ -240,9 +240,12 @@ def DupeSprite(self, rng: random.Random, sprite:Sprite, spacing: float, possible
if rng.random() < replacementChance:
replace = rng.choice((*possibleReplacements.keys(), sprite.picnum))
if replace != sprite.picnum:
sprite.lowtag = possibleReplacements[replace].get('lowtag', sprite.lowtag)
xrepeat = possibleReplacements[replace].get('xrepeat', sprite.texcoords[0])
yrepeat = possibleReplacements[replace].get('yrepeat', sprite.texcoords[1])
r = possibleReplacements[replace]
sprite.lowtag = r.get('lowtag', sprite.lowtag)
xrepeat = r.get('xrepeat', sprite.texcoords[0])
yrepeat = r.get('yrepeat', sprite.texcoords[1])
palettes = r.get('palettes', [0])
sprite.palette = rng.choice(palettes)
sprite.texcoords = [xrepeat, yrepeat, 0, 0]
sprite.picnum = replace
for i in range(20):
Expand Down Expand Up @@ -446,8 +449,8 @@ def ReadHeaders(self, data):

def CreateSpritePacker(self):
self.spritePacker = FancyPacker('<', OrderedDict(
pos='iii', cstat='h', gfxstuff='bBB', texcoords='BBbb',
picnum='h', angle='h', velocity='hhh', owner='h',
pos='iii', cstat='h', shade='b', palette='B', clipdist='B',
texcoords='BBbb', picnum='h', angle='h', velocity='hhh', owner='h',
sectnum='h', statnum='h', lowtag='h', hightag='h', extra='h')
)

Expand Down
4 changes: 3 additions & 1 deletion BuildLibs/games.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,15 @@ def GetGameConSettings(game: GameInfo) -> GameConSettings:
g:GameConSettings = gamesConSettings.get(game.type, GameConSettings())
return g.copy()

def SpriteInfo(name:str, category:str='', lowtag:int=0, xrepeat:int=0, yrepeat:int=0) -> dict:
def SpriteInfo(name:str, category:str='', lowtag:int=0, xrepeat:int=0, yrepeat:int=0, palettes=None) -> dict:
d = dict(name=name, category=category)
if lowtag:
d['lowtag'] = lowtag
if xrepeat:
d['xrepeat'] = xrepeat
d['yrepeat'] = yrepeat
if palettes:
d['palettes'] = palettes
return d

def SpriteRange(min:int, max:int, value:dict):
Expand Down

0 comments on commit 3247dff

Please sign in to comment.