title screen glowing effects; maybe fixed continue bug

This commit is contained in:
Frank DeMarco 2020-10-24 03:38:45 -04:00
parent 772263e918
commit edc4cdd8c4
4 changed files with 61 additions and 37 deletions

94
NS.py
View File

@ -18,7 +18,7 @@ from pygame.transform import rotate, flip
from pygame.time import get_ticks
from pygame.font import Font
from pygame.draw import aalines, lines
from pygame.gfxdraw import aapolygon, arc, polygon
from pygame.gfxdraw import aapolygon, arc, polygon, aaellipse, ellipse, filled_ellipse
from pygame.locals import *
from lib.pgfw.pgfw.Game import Game
@ -74,6 +74,7 @@ class NS(Game, Animation):
self.dialogue = Dialogue(self)
self.chemtrails = Chemtrails(self)
self.boss = Boss(self)
self.tony = Tony(self)
if self.serial_enabled():
self.serial_kill = False
self.serial_data = 0
@ -314,6 +315,27 @@ class Meter(GameChild):
icon.update()
class Tony(Sprite):
def __init__(self, parent):
Sprite.__init__(self, parent)
dsr = self.get_display_surface().get_rect()
for offset in range(12):
w, h = dsr.w + 40, int(dsr.h * .65)
glow = Surface((w, h), SRCALPHA)
for ii, y in enumerate(range(h, 0, -8)):
hue = range(200, 140, -5)[(ii - offset) % 12]
alpha = min(100, int(round(y / float(h - 10) * 100)))
color = get_hsla_color(hue, 100, 50, alpha)
if ii == 0:
aaellipse(glow, w // 2, y, w // 2 - 4, h // 20, color)
ellipse(glow, w // 2, y, w // 2 - 4, h // 20, color)
filled_ellipse(glow, w // 2, y, w // 2 - 4, h // 20, color)
frame = load(self.get_resource("Big_Tony.png")).convert_alpha()
frame.blit(glow, (-20, int(dsr.h * .35)), None, BLEND_RGBA_SUB)
self.add_frame(frame)
class Title(GameChild):
UNLOCK_MOVES = NS.N, NS.NW, NS.E, NS.S
@ -326,7 +348,20 @@ class Title(GameChild):
dsr = ds.get_rect()
self.plank.location.center = dsr.center
self.angle = choice((pi / 4, 3 * pi / 4, 5 * pi / 4, 7 * pi / 4))
self.tony = RainbowSprite(self, load(self.get_resource("Big_Tony.png")).convert_alpha(), 30, 500)
self.background = Sprite(self)
self.background.load_from_path(self.get_resource("Title_tile.png"), True)
for y in range(0, dsr.h + self.background.location.h, self.background.location.h):
for x in range(0, dsr.w + self.background.location.w, self.background.location.w):
if x != 0 or y != 0:
self.background.add_location((x, y))
self.effect = Sprite(self, 100)
palette = (255, 255, 255), (255, 255, 128), (255, 255, 0)
thickness = 8
for offset in range(len(palette)):
frame = Surface(dsr.size)
for x in range(0, dsr.w, thickness):
frame.fill(palette[(offset + x) % len(palette)], (x, 0, thickness, dsr.h))
self.effect.add_frame(frame)
def reset(self):
self.first_pressed = False
@ -388,25 +423,16 @@ class Title(GameChild):
'''
if self.active:
ds = self.get_display_surface()
ds.fill((142, 207, 111))
dsr = ds.get_rect()
# bounce the title plank around the screen
if self.plank.location.right > dsr.right or self.plank.location.left < dsr.left:
self.angle = reflect_angle(self.angle, 0)
if self.plank.location.right > dsr.right:
self.plank.move(dsr.right - self.plank.location.right)
else:
self.plank.move(dsr.left - self.plank.location.left)
if self.plank.location.bottom > dsr.bottom or self.plank.location.top < dsr.top:
self.angle = reflect_angle(self.angle, pi)
if self.plank.location.bottom > dsr.bottom:
self.plank.move(dy=dsr.bottom - self.plank.location.bottom)
else:
self.plank.move(dy=dsr.top - self.plank.location.top)
dx, dy = get_delta(self.angle, 2, False)
self.plank.move(dx, dy)
# self.plank.update()
self.tony.update()
self.effect.update()
# tiled background
self.background.move(-2, 2)
if self.background.location.right < 0:
self.background.move(self.background.location.w)
if self.background.location.top > 0:
self.background.move(dy=-self.background.location.h)
self.background.update(flags=BLEND_RGBA_MIN)
self.get_game().tony.update()
# advance unlock pattern
platform = self.get_game().platform
if not self.get_game().wipe.is_playing() and platform.get_edge_pressed() == self.UNLOCK_MOVES[self.unlock_index]:
@ -417,9 +443,9 @@ class Title(GameChild):
self.get_game().wipe.start(self.start_game)
self.get_audio().play_sfx("confirm")
else:
self.unlock_index += 1
platform.set_glowing(platform.get_buttons_from_edges([self.UNLOCK_MOVES[self.unlock_index]]))
self.get_audio().play_sfx("land_0")
self.unlock_index += 1
# reset unlock pattern if idle
if self.first_pressed:
self.first_pressed_elapsed += self.get_game().time_filter.get_last_frame_duration()
@ -488,7 +514,7 @@ class Dialogue(Animation):
def set_name(self, text):
font = Font(self.get_resource(self.FONT_PATH), self.FONT_SIZE)
self.name = Sprite(self)
self.name.add_frame(font.render(text, True, self.TEXT_COLOR))
self.name.add_frame(font.render(text, True, self.TEXT_COLOR).convert_alpha())
self.name.location.midleft = self.name_box.location.left + 5, self.name_box.location.centery
def show_text(self, text):
@ -520,7 +546,7 @@ class Dialogue(Animation):
lines = self.full_text[:self.text_index].split("\n")
frame = Surface((self.text_box.location.w - 10, 30 * len(lines)), SRCALPHA)
for ii, line in enumerate(lines):
surface = font.render(line, True, self.TEXT_COLOR)
surface = font.render(line, True, self.TEXT_COLOR).convert_alpha()
frame.blit(surface, (0, 30 * ii))
message.add_frame(frame)
message.location.topleft = self.text_box.location.left + 9, self.text_box.location.top + 8
@ -548,9 +574,8 @@ class Introduction(Animation):
self.words = []
for word in "hey you lizard slime bag show me you can scrape".split(" "):
font = Font(self.get_resource(Dialogue.FONT_PATH), 96)
sprite = RainbowSprite(self, font.render(word, True, (255, 0, 0)), 30)
sprite = RainbowSprite(self, font.render(word, True, (255, 0, 0)).convert_alpha(), 30)
self.words.append(sprite)
self.tony = load(self.get_resource("Big_Tony.png")).convert()
self.skateboard = Sprite(self)
self.skateboard.load_from_path(self.get_resource("Introduction_skateboard.png"), True)
self.slime_bag = Sprite(self)
@ -688,7 +713,7 @@ class Introduction(Animation):
else:
platform.set_glowing(platform.get_buttons_from_edges(
[self.TUTORIAL_MOVES[self.tutorial_index]]))
self.get_display_surface().blit(self.tony, (0, 0))
self.get_game().tony.update()
self.slime_bag.update()
self.skateboard.update()
for word in self.words:
@ -724,7 +749,7 @@ class SkipPrompt(GameChild):
left += self.buttons[-1].location.width + AdvancePrompt.BUTTON_SPACING
self.text = Sprite(self)
font = Font(self.get_resource(Dialogue.FONT_PATH), 18)
self.text.add_frame(font.render("TO SKIP", True, (0, 0, 0)))
self.text.add_frame(font.render("TO SKIP", True, (0, 0, 0)).convert_alpha())
self.text.location.midleft = (
self.buttons[2].location.right + 5,
self.buttons[2].location.centery)
@ -1169,10 +1194,10 @@ class Chemtrails(Sprite):
self.attack()
if self.timer.amount < 0:
self.life.decrease()
if not boss.is_playing(boss.show_end_dialogue):
if not boss.is_playing(boss.show_end_dialogue, include_delay=True):
self.timer.reset()
boss.combo()
if not boss.is_playing(boss.show_introduction_dialogue):
if not boss.is_playing(boss.show_introduction_dialogue, include_delay=True):
self.timer.update()
self.life.update()
# self.boys.update()
@ -1193,7 +1218,7 @@ class Chemtrails(Sprite):
boss.sword.block()
if self.queue_index == len(queue):
self.timer.reset()
if not boss.is_playing(boss.show_end_dialogue):
if not boss.is_playing(boss.show_end_dialogue, include_delay=True):
boss.combo()
self.get_audio().play_sfx("complete_pattern_3")
else:
@ -1675,17 +1700,17 @@ class Countdown(GameChild):
dsr = self.get_display_surface().get_rect()
font = Font(self.get_resource(Dialogue.FONT_PATH), 76)
self.heading = Sprite(self)
self.heading.add_frame(font.render("CONTINUE?", True, (0, 0, 0), (255, 255, 255)))
self.heading.add_frame(font.render("CONTINUE?", True, (0, 0, 0), (255, 255, 255)).convert_alpha())
self.heading.location.midtop = dsr.centerx, 50
self.game_over = Sprite(self)
self.game_over.add_frame(font.render("GAME OVER", True, (0, 0, 0), (255, 255, 255)))
self.game_over.add_frame(font.render("GAME OVER", True, (0, 0, 0), (255, 255, 255)).convert_alpha())
self.game_over.location.center = dsr.centerx, dsr.centery - 40
self.glyphs = []
for ii in range(10):
glyph = Sprite(self)
frame = Surface((140, 140))
frame.fill((255, 255, 255))
digits = font.render("%i" % ii, True, (0, 0, 0), (255, 255, 255))
digits = font.render("%i" % ii, True, (0, 0, 0), (255, 255, 255)).convert_alpha()
rect = digits.get_rect()
rect.center = frame.get_rect().center
frame.blit(digits, rect)
@ -1866,7 +1891,6 @@ class Ending(Animation):
def __init__(self, parent):
Animation.__init__(self, parent)
self.tony = load(self.get_resource("Big_Tony.png")).convert()
self.slime_bag = Sprite(self)
self.slime_bag.load_from_path(self.get_resource("Introduction_slime_bag.png"), True)
self.slime_bag.location.center = self.get_display_surface().get_rect().centerx, 300
@ -1928,7 +1952,7 @@ class Ending(Animation):
else:
self.start_wipe()
self.advance_prompt.cancel_first_press()
self.get_display_surface().blit(self.tony, (0, 0))
self.get_game().tony.update()
self.slime_bag.update()
dsr = self.get_display_surface().get_rect()
if self.text.location.right > dsr.right or self.text.location.left < dsr.left:

4
config
View File

@ -1,6 +1,6 @@
[setup]
license = Public Domain
title = Electric Scrapeboard
title = Scrapeboard
url = http://shampoo.ooo/games/esb
version = 0.2.3
init-script = OPEN-GAME
@ -8,7 +8,7 @@ additional-packages = lib
data-exclude = local/, *.pyc
[display]
caption = Electric Scrapeboard
caption = Scrapeboard
show-framerate = no
dimensions = 640, 480
fullscreen = no

Binary file not shown.

Before

Width:  |  Height:  |  Size: 134 KiB

After

Width:  |  Height:  |  Size: 16 KiB

BIN
resource/Title_tile.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 70 KiB