diff options
author | Viljami Ilola <+@hix.fi> | 2024-04-26 22:49:31 +0300 |
---|---|---|
committer | Viljami Ilola <+@hix.fi> | 2024-04-26 22:49:31 +0300 |
commit | e6a958b6c9d5f6c77918e11f3f862156d563ba14 (patch) | |
tree | 3981a140d5808d6aa0f62806a11bd37c2619b080 | |
parent | fde888991eb8f8be560da6e606abe58d95f9cf64 (diff) |
levels with different colors
-rw-r--r-- | CHANGELOG.txt | 4 | ||||
-rw-r--r-- | pyproject.toml | 2 | ||||
-rw-r--r-- | src/sliceitoff/display/__init__.py | 2 | ||||
-rw-r--r-- | src/sliceitoff/display/static.py | 10 | ||||
-rw-r--r-- | src/sliceitoff/field/field.py | 26 | ||||
-rw-r--r-- | src/sliceitoff/game/level.py | 2 |
6 files changed, 30 insertions, 16 deletions
diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 6a18855..e98cf77 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -9,3 +9,7 @@ 0.3.post1 - Just release fixes. Readme, changelog and unnecessary wav file. + +0.4-alpha1 + + - Levels have different colors
\ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index 71dd03c..1b15c84 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "sliceitoff" -version = "0.3.post1" +version = "0.4-alpha1" description = "Arcade game where one slices play area off while avoiding slicing happy faces." repository = "https://git.hix.fi/sliceitoff.git/" authors = ["Viljami Ilola <+@hix.fi>"] diff --git a/src/sliceitoff/display/__init__.py b/src/sliceitoff/display/__init__.py index 543636b..cc319b9 100644 --- a/src/sliceitoff/display/__init__.py +++ b/src/sliceitoff/display/__init__.py @@ -1,4 +1,4 @@ """ display - All drawing to the display should happen here """ from .scaling import Scaling from .display import Display -from .static import INTERNAL_WIDTH, INTERNAL_HEIGHT, CGA_COLORS +from .static import INTERNAL_WIDTH, INTERNAL_HEIGHT, CGA_COLORS, RAINBOW_COLORS diff --git a/src/sliceitoff/display/static.py b/src/sliceitoff/display/static.py index 054e6b8..fdbba3c 100644 --- a/src/sliceitoff/display/static.py +++ b/src/sliceitoff/display/static.py @@ -22,3 +22,13 @@ CGA_COLORS=[ (0xF3,0xF3,0x4E,0xFF), (0xFF,0xFF,0xFF,0xFF) ] + +RAINBOW_COLORS=[ + CGA_COLORS[15], + CGA_COLORS[13], + CGA_COLORS[9], + CGA_COLORS[11], + CGA_COLORS[10], + CGA_COLORS[14], + CGA_COLORS[12], +]
\ No newline at end of file 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) diff --git a/src/sliceitoff/game/level.py b/src/sliceitoff/game/level.py index 9f3121f..08e4495 100644 --- a/src/sliceitoff/game/level.py +++ b/src/sliceitoff/game/level.py @@ -17,7 +17,7 @@ class Level(pygame.sprite.Group): super().__init__() self.stats = stats self.status = Status(stats = self.stats) - self.field = Field(stats = self.stats) + self.field = Field(stats = self.stats, level = stats.level) self.enemies = Enemies(count = self.stats.enemies) self.player = Player() self.life = Life() |