diff options
Diffstat (limited to 'src/sliceitoff/field/field.py')
-rw-r--r-- | src/sliceitoff/field/field.py | 18 |
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): |