summaryrefslogtreecommitdiff
path: root/src/sliceitoff/field
diff options
context:
space:
mode:
Diffstat (limited to 'src/sliceitoff/field')
-rw-r--r--src/sliceitoff/field/field.py26
1 files changed, 13 insertions, 13 deletions
diff --git a/src/sliceitoff/field/field.py b/src/sliceitoff/field/field.py
index 95a2aeb..90498e5 100644
--- a/src/sliceitoff/field/field.py
+++ b/src/sliceitoff/field/field.py
@@ -4,16 +4,16 @@ from random import randrange, choice
import pygame
-from sliceitoff.display import Scaling, CGA_COLORS
+from sliceitoff.display import Scaling, CGA_COLORS, RAINBOW_COLORS
from sliceitoff.text import LetterSprite
DEBUG = os.getenv("DEBUG")
class FieldSprite(pygame.sprite.Sprite):
""" Playing area consist of these sprites """
- def __init__(self, area: tuple):
+ def __init__(self, area: tuple, color):
super().__init__()
- self.color = (0,255,0,255)
+ self.color = color
self.dead = False
self.area = area
self.rect = Scaling.area_to_rect(self.area)
@@ -23,9 +23,7 @@ class FieldSprite(pygame.sprite.Sprite):
class SliceSprite(FieldSprite):
""" Flashing rectangle like lazer """
def __init__(self, area: tuple ):
- super().__init__(area)
- self.color = (255,255,255,255)
- self.image.fill(self.color)
+ super().__init__(area, (255,255,255,255))
self.timeout = 300
self.dead = True
@@ -46,9 +44,10 @@ class Field(pygame.sprite.LayeredUpdates):
""" group that contains all pieces of field """
initial_area = (320_000, 220_000)
- def __init__(self, stats = None):
+ def __init__(self, stats = None, level = 0):
super().__init__()
- self.add(FieldSprite( (0, 0, *__class__.initial_area) ))
+ self.color = RAINBOW_COLORS[level % len(RAINBOW_COLORS)]
+ self.add(FieldSprite( (0, 0, *__class__.initial_area), self.color ))
self.area_full = __class__.initial_area[0] * __class__.initial_area[1]
self.stats = stats
@@ -62,7 +61,8 @@ class Field(pygame.sprite.LayeredUpdates):
def update_stats(self):
""" calculates remaining area and remaining percentage """
- self.stats.percent = 100 * self.calculate_current_area() / self.area_full
+ self.stats.percent = (
+ 100 * self.calculate_current_area() / self.area_full)
if DEBUG:
print(f"FIELD: {self.stats.percent}")
@@ -99,9 +99,9 @@ class Field(pygame.sprite.LayeredUpdates):
t3 = pos[0] + thickness
t4 = ax + aw
if t2 > ax:
- self.add(FieldSprite( (ax, ay, t2-ax, ah) ))
+ self.add(FieldSprite( (ax, ay, t2-ax, ah), self.color ))
if t4 > t3:
- self.add(FieldSprite( (t3, ay, t4-t3, ah) ))
+ self.add(FieldSprite( (t3, ay, t4-t3, ah), self.color ))
return (t2, ay, t3-t2, ah)
def horizontal_slicer(self, pos, area, thickness):
@@ -111,9 +111,9 @@ class Field(pygame.sprite.LayeredUpdates):
t3 = pos[1] + thickness
t4 = ay + ah
if t2 > ay:
- self.add(FieldSprite( (ax, ay, aw, t2-ay) ))
+ self.add(FieldSprite( (ax, ay, aw, t2-ay), self.color ))
if t4 > t3:
- self.add(FieldSprite( (ax, t3, aw, t4-t3) ))
+ self.add(FieldSprite( (ax, t3, aw, t4-t3), self.color ))
return (ax, t2, aw, t3-t2)