summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorViljami Ilola <+@hix.fi>2024-04-08 01:46:43 +0300
committerViljami Ilola <+@hix.fi>2024-04-08 01:46:43 +0300
commit3bae12a5c5104e606c6958b8d52ca75c4cbcacba (patch)
tree48a89b38987db23f006bf602e4e6e3b65678af9f
parent24c9a5fb88810c80c414ec0a932c9405d8d54abc (diff)
new slicer image
-rw-r--r--pyproject.toml3
-rw-r--r--src/sliceitoff/assets/fonts.lst1
-rw-r--r--src/sliceitoff/player/player.py23
-rw-r--r--src/sliceitoff/player/static.py35
4 files changed, 47 insertions, 15 deletions
diff --git a/pyproject.toml b/pyproject.toml
index 7d8cf50..2109569 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -35,9 +35,6 @@ recursive = true
source-roots = ["src/sliceitoff"]
extension-pkg-whitelist = ["pygame"]
-[tool.pylint."messages control"]
-disable = [ "too-few-public-methods" ] # pygame sprites and groups
-
# From given .pylintrc
[tool.pylint.design]
max-args = 7
diff --git a/src/sliceitoff/assets/fonts.lst b/src/sliceitoff/assets/fonts.lst
index a782a86..268081b 100644
--- a/src/sliceitoff/assets/fonts.lst
+++ b/src/sliceitoff/assets/fonts.lst
@@ -1,4 +1,3 @@
lcd assets gnufonts UTIL GNUFONTS LCD.FNT
8x8 assets gnufonts UTIL GNUFONTS 8X8.FNT
computer assets gnufonts UTIL GNUFONTS COMPUTER.FNT
-standard assets gnufonts UTIL GNUFONTS STANDARD.FNT
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))
diff --git a/src/sliceitoff/player/static.py b/src/sliceitoff/player/static.py
new file mode 100644
index 0000000..415f1cd
--- /dev/null
+++ b/src/sliceitoff/player/static.py
@@ -0,0 +1,35 @@
+""" player.static - static data related to player - now just slicer """
+from dataclasses import dataclass
+from display import CGA_COLORS
+
+@dataclass
+class SLICER:
+ """ Slicer tool """
+ DIMENSIONS = (32, 8)
+ COLORS = [
+ CGA_COLORS[0],
+ CGA_COLORS[15],
+ CGA_COLORS[9],
+ CGA_COLORS[14],
+ CGA_COLORS[12],
+ CGA_COLORS[4],
+ (0,0,0,0)
+ ]
+ IMAGE = [
+ 0,0,0,6,6,6,6,6,6,6,6,6,6,6,0,0,
+ 0,0,6,6,6,6,6,6,6,6,6,6,6,0,0,0,
+ 6,6,0,0,0,0,0,6,6,6,6,6,6,0,0,1,
+ 1,0,0,6,6,6,6,6,6,0,0,0,0,0,6,6,
+ 6,6,5,5,4,4,0,0,0,0,0,0,0,0,1,1,
+ 1,1,0,0,0,0,0,0,0,0,4,4,5,5,6,6,
+ 6,6,5,5,4,4,4,3,4,3,3,2,0,1,1,0,
+ 0,1,1,0,2,3,3,3,4,3,4,4,5,5,6,6,
+ 6,6,5,5,4,4,3,4,3,3,3,2,0,1,1,0,
+ 0,1,1,0,2,3,3,4,3,4,4,4,5,5,6,6,
+ 6,6,5,5,4,4,0,0,0,0,0,0,0,0,1,1,
+ 1,1,0,0,0,0,0,0,0,0,4,4,5,5,6,6,
+ 6,6,0,0,0,0,0,6,6,6,6,6,6,0,0,1,
+ 1,0,0,6,6,6,6,6,6,0,0,0,0,0,6,6,
+ 0,0,0,6,6,6,6,6,6,6,6,6,6,6,0,0,
+ 0,0,6,6,6,6,6,6,6,6,6,6,6,0,0,0
+ ]