From 673cf69d802aea1c4cea1b548cbc0fc074492566 Mon Sep 17 00:00:00 2001 From: frank Date: Fri, 30 Dec 2022 23:27:52 -0500 Subject: [PATCH] update trail effect, change sieve to white --- config | 5 ++-- electric_sieve/ElectricSieve.py | 42 ++++++++++++++++++++++++--------- resource/high-scores | 1 + 3 files changed, 35 insertions(+), 13 deletions(-) diff --git a/config b/config index 16cc4d0..724bd0c 100644 --- a/config +++ b/config @@ -12,12 +12,13 @@ init-script = electric-sieve [display] caption = Electric Sieve -dimensions = 420, 700 +#dimensions = 420, 700 +dimensions = 480, 720 score-font-path = font/Titan-One.ttf title-font-path = font/Oxygen.ttf scoreboard-font-path = font/terminus/Terminus.ttf initials-font = font/terminus/Terminus-Bold.ttf -show-framerate = no +show-framerate = yes rotate = no [mouse] diff --git a/electric_sieve/ElectricSieve.py b/electric_sieve/ElectricSieve.py index 4a93c1e..b42e93e 100644 --- a/electric_sieve/ElectricSieve.py +++ b/electric_sieve/ElectricSieve.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -import sys +import sys, random from random import randint, randrange, choice from time import time from operator import itemgetter @@ -73,6 +73,10 @@ class ElectricSieve(Game): # Create a black background self.background = Surface(self.get_display_surface().get_size()) self.background.fill((0, 0, 0)) + + # Alpha filter + self.alpha_filter = Surface(self.get_display_surface().get_size(), pygame.SRCALPHA) + self.alpha_filter.fill(Color(0, 0, 0, 80)) # Create game objects self.title = Title(self) @@ -168,16 +172,16 @@ class ElectricSieve(Game): self.land.update() # Set the background alpha low to create a trail effect on the triangles. - self.background.set_alpha(255 * 0.1) + #self.background.set_alpha(255 * 0.1) # Draw the alpha background only to the trail effect surface. This will partially erase the previous drawings of the triangles. - self.trail_effect.blit(self.background, (0, 0)) + #self.trail_effect.blit(self.background, (0, 0)) # Draw triangles onto the trail effect surface, update position self.triangles.update() # Set alpha back to full for drawing the bottom layer background - self.background.set_alpha(255) + #self.background.set_alpha(255) self.get_display_surface().blit(self.background, (0, 0)) # Draw the triangles to the screen, using the intermediate trail effect surface @@ -451,7 +455,8 @@ class Sieve(Strip): surface.fill(transparent_color) surface.set_colorkey(transparent_color) frames = surface, surface.copy() - colors = (0, 255, 0), (153, 0, 204) + # colors = (0, 255, 0), (153, 0, 204) + colors = (255, 255, 255), (255, 255, 255) for x in bar_locations: bar_rects.append(Rect(x + surface.get_width(), 0, bar_w, sh)) for ii, frame in enumerate(frames): @@ -514,7 +519,8 @@ class Electric(Sprite): surface = Surface((self.display_surface.get_height(), self.parent.location.w - 10)) frames = surface, surface.copy() # colors = (255, 255, 0), (100, 89, 213) - colors = (180, 152, 111), (180, 152, 111) + # colors = (180, 152, 111), (180, 152, 111) + colors = (255, 255, 255), (255, 255, 255) pixel_arrays = PixelArray(frames[0]), PixelArray(frames[1]) for x in range(len(pixel_arrays[0])): for y in range( len(pixel_arrays[0][0])): @@ -530,6 +536,7 @@ class Triangles(GameChild, list): def __init__(self, parent): GameChild.__init__(self, parent) + self.hue = 0 self.music = Sound(self.get_resource("audio", "triangles")) self.deactivate() self.display_surface = self.get_game().trail_effect @@ -591,12 +598,14 @@ class Triangles(GameChild, list): self.booster.update() if self[0].location.collidelist(self.parent.sieve.locations) != -1: sieve = self.parent.sieve + removed = False if self[0].location.colliderect(sieve.electric.location): self.parent.acid.increase() self.streak += 1 self.score += self.streak ** .8 + self.parent.acid.get_volume() * 5 + self[0].count self.remove(self[0]) self.hit.play() + removed = True else: for br in sieve.bar_rects: for tr in self[0].collision_rects: @@ -609,7 +618,10 @@ class Triangles(GameChild, list): self.parent.static.increase() self.streak = 0 self.miss.play() + removed = True break + if removed: + self.get_display_surface().blit(self.get_game().alpha_filter, (0, 0), None, pygame.BLEND_RGBA_SUB) for triangle in self: triangle.update() @@ -630,7 +642,11 @@ class Triangle(Sprite): height = surface.get_height() margin = 26 self.collision_rects = collision_rects = [] - for ii, color in enumerate(((60, 255, 220), (90, 255, 190), (120, 255, 160), (150, 255, 130))): + for ii, lightness in enumerate(range(30, 110, 10)): + color = pygame.Color(0, 0, 0) + color.hsla = parent.hue, 100, lightness, 100 +# opposite_color = pygame.Color(0, 0, 0) +# opposite_color.hsla = (parent.hue + 180) % 360, 100, lightness, 100 x = 0 surface = surface.copy() for width in widths: @@ -644,12 +660,16 @@ class Triangle(Sprite): collision_rects.append(Rect(points[0], (width - margin - 1, 1))) else: collision_rects.append(Rect(height - 2 - 1, self.get_display_surface().get_height() - x - width + margin // 2 + 1, 1, width - margin - 1)) - points = ((x + margin // 2 + (width * .1), height - 2 - 2), - (x + width - margin // 2 - 1 - (width * .1), height - 2 - 2), - (x + width / 2.0, 1 + 5)) - polygon(surface, (0, 0, 0), points) +# points = ((x + margin // 2 + (width * .1), height - 2 - 2), +# (x + width - margin // 2 - 1 - (width * .1), height - 2 - 2), +# (x + width / 2.0, 1 + 5)) +# polygon(surface, opposite_color, points) x += width - sieve.bar_w self.add_frame(self.get_game().orient(surface)) + next_hue = parent.hue + while abs(next_hue - parent.hue) < 60: + next_hue = random.randint(0, 359) + parent.hue = next_hue if not self.get_game().rotated: self.location.centerx = self.get_display_surface().get_rect().centerx else: diff --git a/resource/high-scores b/resource/high-scores index e73c31e..ed21b33 100644 --- a/resource/high-scores +++ b/resource/high-scores @@ -7,3 +7,4 @@ 1398635792.99 20 FIT 1398635792.99 15 FIT 1398635792.99 10 FIT +1672460647.69491 211 ---