summaryrefslogtreecommitdiff
path: root/src/sliceitoff/field/field.py
diff options
context:
space:
mode:
authorViljami Ilola <+@hix.fi>2024-03-30 16:46:29 +0200
committerViljami Ilola <+@hix.fi>2024-03-30 16:46:29 +0200
commitaf17f92e0beda893fb91ff757b76f2499e500666 (patch)
tree180ddcc4fac223e057d76db71f6ae4ddbe67721a /src/sliceitoff/field/field.py
parent1def24341ce4f3ab1c1de4a9dde27bf0b5fab179 (diff)
lint
Diffstat (limited to 'src/sliceitoff/field/field.py')
-rw-r--r--src/sliceitoff/field/field.py18
1 files changed, 11 insertions, 7 deletions
diff --git a/src/sliceitoff/field/field.py b/src/sliceitoff/field/field.py
index abcc615..58464de 100644
--- a/src/sliceitoff/field/field.py
+++ b/src/sliceitoff/field/field.py
@@ -1,13 +1,16 @@
+""" field.field - The playing area or slices, lazer of explosions of it """
import os
+from random import randrange, choice
+
import pygame
-from random import randrange
-from display import Scaling, INTERNAL_WIDTH, INTERNAL_HEIGHT
+from display import Scaling, CGA_COLORS
from text import LetterSprite
DEBUG = os.getenv("DEBUG")
class FieldSprite(pygame.sprite.Sprite):
+ """ Playing area consist of these sprites """
def __init__(self, area: tuple):
super().__init__()
self.color = (0,255,0,255)
@@ -18,6 +21,7 @@ class FieldSprite(pygame.sprite.Sprite):
self.image.fill(self.color)
class SliceSprite(FieldSprite):
+ """ Flashing rectangle like lazer """
def __init__(self, area: tuple ):
super().__init__(area)
self.color = (255,255,255,255)
@@ -26,13 +30,12 @@ class SliceSprite(FieldSprite):
self.dead = True
def update(self, dt = 0, **kwargs):
+ """ Just pick a randon color every update from cga palette """
+ # pylint: disable = unused-argument
+ # explosion arg is given, but no use in SliceSprite
if dt:
self.timeout -= dt
- self.color = (
- (randrange(0,300) < self.timeout) * 255,
- (randrange(0,300) < self.timeout) * 255,
- (randrange(0,300) < self.timeout) * 255,
- 255)
+ self.color = choice(CGA_COLORS)
if self.timeout <= 0:
self.kill()
else:
@@ -54,6 +57,7 @@ class Field(pygame.sprite.LayeredUpdates):
return sum( s.area[2]*s.area[3] for s in self.active_sprites() )
def update(self, **kwargs):
+ """ just force explosion on """
super().update(explode = True, **kwargs)
def update_stats(self):