diff options
author | Viljami Ilola <+@hix.fi> | 2024-04-08 01:46:43 +0300 |
---|---|---|
committer | Viljami Ilola <+@hix.fi> | 2024-04-08 01:46:43 +0300 |
commit | 3bae12a5c5104e606c6958b8d52ca75c4cbcacba (patch) | |
tree | 48a89b38987db23f006bf602e4e6e3b65678af9f /src/sliceitoff/player/player.py | |
parent | 24c9a5fb88810c80c414ec0a932c9405d8d54abc (diff) |
new slicer image
Diffstat (limited to 'src/sliceitoff/player/player.py')
-rw-r--r-- | src/sliceitoff/player/player.py | 23 |
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)) |