Skip to content

Commit

Permalink
Fixed frame update issue
Browse files Browse the repository at this point in the history
  • Loading branch information
jinglemansweep committed Dec 1, 2023
1 parent ca6087b commit 50ef75e
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions wideboy/sprites/tile_grid/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ class TileGrid(pygame.sprite.DirtySprite):
state: Dict
columns: List
tile_surface_cache: Dict[str, pygame.Surface] = dict()
update_frames: int = 0

def __init__(self, scene: BaseScene, cells: List[List[Type[TileGridCell]]]):
super().__init__()
Expand Down Expand Up @@ -175,8 +176,8 @@ def update(self, frame, clock, delta, events):
animating = any([column.animating for column in self.columns])
if animating:
dirty = True
if not dirty:
return
if dirty:
self.update_frames = 2
self.image = pygame.Surface((width, height), pygame.SRCALPHA)
self.image.fill(pygame.Color(0, 0, 0, 0))
for column in self.columns:
Expand All @@ -199,7 +200,8 @@ def update(self, frame, clock, delta, events):
column.draw(self.image)
self.rect.width = cx
self.rect.height = cy
self.dirty = 1
self.dirty = 1 if self.update_frames > 0 else 0
self.update_frames -= 1

def calculate_size(self):
width = 0
Expand Down

0 comments on commit 50ef75e

Please sign in to comment.