update trail effect, change sieve to white

This commit is contained in:
ohsqueezy 2022-12-30 23:27:52 -05:00
parent fe48c24a09
commit 673cf69d80
3 changed files with 35 additions and 13 deletions

5
config
View File

@ -12,12 +12,13 @@ init-script = electric-sieve
[display] [display]
caption = Electric Sieve caption = Electric Sieve
dimensions = 420, 700 #dimensions = 420, 700
dimensions = 480, 720
score-font-path = font/Titan-One.ttf score-font-path = font/Titan-One.ttf
title-font-path = font/Oxygen.ttf title-font-path = font/Oxygen.ttf
scoreboard-font-path = font/terminus/Terminus.ttf scoreboard-font-path = font/terminus/Terminus.ttf
initials-font = font/terminus/Terminus-Bold.ttf initials-font = font/terminus/Terminus-Bold.ttf
show-framerate = no show-framerate = yes
rotate = no rotate = no
[mouse] [mouse]

View File

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import sys import sys, random
from random import randint, randrange, choice from random import randint, randrange, choice
from time import time from time import time
from operator import itemgetter from operator import itemgetter
@ -73,6 +73,10 @@ class ElectricSieve(Game):
# Create a black background # Create a black background
self.background = Surface(self.get_display_surface().get_size()) self.background = Surface(self.get_display_surface().get_size())
self.background.fill((0, 0, 0)) 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 # Create game objects
self.title = Title(self) self.title = Title(self)
@ -168,16 +172,16 @@ class ElectricSieve(Game):
self.land.update() self.land.update()
# Set the background alpha low to create a trail effect on the triangles. # 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. # 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 # Draw triangles onto the trail effect surface, update position
self.triangles.update() self.triangles.update()
# Set alpha back to full for drawing the bottom layer background # 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)) self.get_display_surface().blit(self.background, (0, 0))
# Draw the triangles to the screen, using the intermediate trail effect surface # Draw the triangles to the screen, using the intermediate trail effect surface
@ -451,7 +455,8 @@ class Sieve(Strip):
surface.fill(transparent_color) surface.fill(transparent_color)
surface.set_colorkey(transparent_color) surface.set_colorkey(transparent_color)
frames = surface, surface.copy() 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: for x in bar_locations:
bar_rects.append(Rect(x + surface.get_width(), 0, bar_w, sh)) bar_rects.append(Rect(x + surface.get_width(), 0, bar_w, sh))
for ii, frame in enumerate(frames): 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)) surface = Surface((self.display_surface.get_height(), self.parent.location.w - 10))
frames = surface, surface.copy() frames = surface, surface.copy()
# colors = (255, 255, 0), (100, 89, 213) # 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]) pixel_arrays = PixelArray(frames[0]), PixelArray(frames[1])
for x in range(len(pixel_arrays[0])): for x in range(len(pixel_arrays[0])):
for y in range( len(pixel_arrays[0][0])): for y in range( len(pixel_arrays[0][0])):
@ -530,6 +536,7 @@ class Triangles(GameChild, list):
def __init__(self, parent): def __init__(self, parent):
GameChild.__init__(self, parent) GameChild.__init__(self, parent)
self.hue = 0
self.music = Sound(self.get_resource("audio", "triangles")) self.music = Sound(self.get_resource("audio", "triangles"))
self.deactivate() self.deactivate()
self.display_surface = self.get_game().trail_effect self.display_surface = self.get_game().trail_effect
@ -591,12 +598,14 @@ class Triangles(GameChild, list):
self.booster.update() self.booster.update()
if self[0].location.collidelist(self.parent.sieve.locations) != -1: if self[0].location.collidelist(self.parent.sieve.locations) != -1:
sieve = self.parent.sieve sieve = self.parent.sieve
removed = False
if self[0].location.colliderect(sieve.electric.location): if self[0].location.colliderect(sieve.electric.location):
self.parent.acid.increase() self.parent.acid.increase()
self.streak += 1 self.streak += 1
self.score += self.streak ** .8 + self.parent.acid.get_volume() * 5 + self[0].count self.score += self.streak ** .8 + self.parent.acid.get_volume() * 5 + self[0].count
self.remove(self[0]) self.remove(self[0])
self.hit.play() self.hit.play()
removed = True
else: else:
for br in sieve.bar_rects: for br in sieve.bar_rects:
for tr in self[0].collision_rects: for tr in self[0].collision_rects:
@ -609,7 +618,10 @@ class Triangles(GameChild, list):
self.parent.static.increase() self.parent.static.increase()
self.streak = 0 self.streak = 0
self.miss.play() self.miss.play()
removed = True
break break
if removed:
self.get_display_surface().blit(self.get_game().alpha_filter, (0, 0), None, pygame.BLEND_RGBA_SUB)
for triangle in self: for triangle in self:
triangle.update() triangle.update()
@ -630,7 +642,11 @@ class Triangle(Sprite):
height = surface.get_height() height = surface.get_height()
margin = 26 margin = 26
self.collision_rects = collision_rects = [] 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 x = 0
surface = surface.copy() surface = surface.copy()
for width in widths: for width in widths:
@ -644,12 +660,16 @@ class Triangle(Sprite):
collision_rects.append(Rect(points[0], (width - margin - 1, 1))) collision_rects.append(Rect(points[0], (width - margin - 1, 1)))
else: else:
collision_rects.append(Rect(height - 2 - 1, self.get_display_surface().get_height() - x - width + margin // 2 + 1, 1, width - margin - 1)) 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), # points = ((x + margin // 2 + (width * .1), height - 2 - 2),
(x + width - margin // 2 - 1 - (width * .1), height - 2 - 2), # (x + width - margin // 2 - 1 - (width * .1), height - 2 - 2),
(x + width / 2.0, 1 + 5)) # (x + width / 2.0, 1 + 5))
polygon(surface, (0, 0, 0), points) # polygon(surface, opposite_color, points)
x += width - sieve.bar_w x += width - sieve.bar_w
self.add_frame(self.get_game().orient(surface)) 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: if not self.get_game().rotated:
self.location.centerx = self.get_display_surface().get_rect().centerx self.location.centerx = self.get_display_surface().get_rect().centerx
else: else:

View File

@ -7,3 +7,4 @@
1398635792.99 20 FIT 1398635792.99 20 FIT
1398635792.99 15 FIT 1398635792.99 15 FIT
1398635792.99 10 FIT 1398635792.99 10 FIT
1672460647.69491 211 ---