summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorViljami Ilola <+@hix.fi>2024-04-27 23:38:48 +0300
committerViljami Ilola <+@hix.fi>2024-04-27 23:38:48 +0300
commit33e7e0e233b2f0cba9f5b58c8b317efbb2cb786d (patch)
tree164427c03a9111a2e813a2a833f22d351d6b0c87
parent418e9144d5059212693c3f848ecf095dbb0f690a (diff)
Fix error where lose_life takes subsurface out of bounds
-rw-r--r--src/sliceitoff/player/life.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/sliceitoff/player/life.py b/src/sliceitoff/player/life.py
index 16ba052..9e9b6b8 100644
--- a/src/sliceitoff/player/life.py
+++ b/src/sliceitoff/player/life.py
@@ -34,7 +34,8 @@ class Life(pygame.sprite.Group):
int(Scaling.factor * 72_500 + Scaling.left),
int(Scaling.factor * 20_000 + Scaling.top))
srfc = get_letter_surface(("8x8", 200_000, 4), 0x03)
- for x in range(0, font_width, block_width):
- for y in range(0, font_width, block_width):
+ block_width = srfc.get_rect().w // 24
+ for x in range(0, block_width * 24, block_width):
+ for y in range(0, block_width * 24, block_width):
image = srfc.subsurface((x, y, block_width, block_width))
- self.add(PieceOfHearth(image,(x + offset[0], y + offset[1])))
+ self.add(PieceOfHearth(image, (x + offset[0], y + offset[1])))