summaryrefslogtreecommitdiff
path: root/src/sliceitoff/player/player.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/sliceitoff/player/player.py')
-rw-r--r--src/sliceitoff/player/player.py23
1 files changed, 12 insertions, 11 deletions
diff --git a/src/sliceitoff/player/player.py b/src/sliceitoff/player/player.py
index 72c5b2f..82cc9a4 100644
--- a/src/sliceitoff/player/player.py
+++ b/src/sliceitoff/player/player.py
@@ -3,10 +3,19 @@ import os
import pygame
from display import Scaling
-from text import Fonts
+
+from .static import SLICER
DEBUG = os.getenv("DEBUG")
+def dataclass_to_surface(dc):
+ """ Converts dataclass to surface """
+ image = pygame.Surface(dc.DIMENSIONS, pygame.SRCALPHA)
+ for x in range(dc.DIMENSIONS[0]):
+ for y in range(dc.DIMENSIONS[1]):
+ image.set_at((x,y), dc.COLORS[dc.IMAGE[y*dc.DIMENSIONS[0]+x]])
+ return image
+
class PlayerSprite(pygame.sprite.Sprite):
""" The slicing tool. There is 2 of these. Horizontal and vertical """
def __init__(self, image):
@@ -27,16 +36,8 @@ class Player(pygame.sprite.Group):
self.position = (0,0)
self.direction = False
self.lazer = False
- image = pygame.Surface((8,26), pygame.SRCALPHA)
- for color, y, ch in (
- ("red",0,0x18),
- ("red",13,0x19),
- ("blue",6,0x09)):
- ch = Fonts.fonts['standard'].get(ch)
- ch.fill( color, special_flags = pygame.BLEND_RGBA_MULT)
- image.blit(ch,(0,y))
- image = pygame.transform.scale_by(image, 1_200 * Scaling.factor)
- image = pygame.transform.rotate(image, 90)
+ image = dataclass_to_surface(SLICER)
+ image = pygame.transform.scale_by(image, 1_000 * Scaling.factor)
self.add(PlayerSprite(image))
image = pygame.transform.rotate(image, 90)
self.add(PlayerSprite(image))