use polling for determining left and right input, change title prompt
This commit is contained in:
parent
dd12b6d6cf
commit
732f26fb38
3
config
3
config
|
@ -11,7 +11,7 @@ package-root = electric_sieve
|
|||
init-script = electric-sieve
|
||||
|
||||
[display]
|
||||
caption = iBITFIT
|
||||
caption = iBiTFiT
|
||||
dimensions = 480, 720
|
||||
score-font-path = font/Titan-One.ttf
|
||||
title-font-path = font/Oxygen.ttf
|
||||
|
@ -19,6 +19,7 @@ scoreboard-font-path = font/terminus/Terminus-Bold.ttf
|
|||
initials-font = font/terminus/Terminus-Bold.ttf
|
||||
show-framerate = no
|
||||
rotate = no
|
||||
prompt-image = resource/Title_prompt.png
|
||||
|
||||
[mouse]
|
||||
visible = no
|
||||
|
|
|
@ -17,6 +17,7 @@ from lib.pgfw.pgfw.GameChild import GameChild
|
|||
from lib.pgfw.pgfw.Sprite import Sprite, BlinkingSprite
|
||||
from lib.pgfw.pgfw.Vector import Vector
|
||||
from lib.pgfw.pgfw.extension import render_box
|
||||
from lib.pgfw.pgfw.Input import Joystick
|
||||
|
||||
from .land.Land import Land
|
||||
|
||||
|
@ -45,7 +46,8 @@ class ElectricSieve(Game):
|
|||
self.get_configuration().type_declarations.add_chart({
|
||||
"display":
|
||||
{
|
||||
"bool": "rotate"
|
||||
"bool": "rotate",
|
||||
"path": "prompt-image"
|
||||
},
|
||||
"input":
|
||||
{
|
||||
|
@ -236,48 +238,18 @@ class Title(GameChild):
|
|||
GameChild.__init__(self, parent)
|
||||
self.display_surface = self.get_display_surface()
|
||||
self.delegate = self.parent.delegate
|
||||
# bg_color = (255, 222, 173)
|
||||
# bg_color = (220, 220, 148)
|
||||
bg_color = 200, 168, 122
|
||||
self.background = surface = Surface(self.display_surface.get_size())
|
||||
tile = Surface((2, 2))
|
||||
tile.fill(bg_color)
|
||||
# tile.set_at(Vector(0, 1), (220, 119, 41))
|
||||
# tile.set_at(Vector(0, 0), (220, 119, 41))
|
||||
for y in range(0, surface.get_height(), 2):
|
||||
for x in range(0, surface.get_width(), 2):
|
||||
surface.blit(self.get_game().orient(tile), (x, y))
|
||||
# font = Font(self.get_resource("display", "title-font-path"), 20)
|
||||
# font.set_italic(True)
|
||||
# font.set_bold(True)
|
||||
# self.captions = captions = Sprite(self), Sprite(self)
|
||||
# colors = (0, 68, 170), (255, 255, 255), (128, 128, 128), \
|
||||
# (220, 119, 41), (255, 80, 80), (0, 90, 110)
|
||||
# texts = ["", ""]
|
||||
# for ii, text in \
|
||||
# enumerate(self.get_configuration("display",
|
||||
# "caption").upper().split()):
|
||||
# texts[ii] += "•" * (5 if ii else 3)
|
||||
# for ch in text:
|
||||
# texts[ii] += ch + " "
|
||||
# texts[ii] = texts[ii].strip() + "•" * (5 if ii else 3)
|
||||
# for _ in range(25):
|
||||
# color = choice(colors)
|
||||
# captions[0].add_frame(font.render(texts[0], True, color, (220, 208, 255)))
|
||||
# captions[1].add_frame(font.render(texts[1], True, color, (220, 208, 255)))
|
||||
# cx = self.display_surface.get_rect().centerx
|
||||
# captions[0].location.center = cx, 301
|
||||
# captions[1].location.center = cx, 398
|
||||
self.button_prompt = BlinkingSprite(self, 500)
|
||||
font = pygame.font.Font(self.get_resource("terminus/Terminus.ttf"), 32)
|
||||
self.button_prompt.add_frame(self.get_game().orient(font.render("HOLD LEFT OR RIGHT TO PLAY", True, pygame.Color(0, 0, 0), pygame.Color(255, 255, 255))))
|
||||
if not self.get_game().rotated:
|
||||
self.button_prompt.location.midbottom = self.get_display_surface().get_rect().midbottom
|
||||
else:
|
||||
self.button_prompt.location.midright = self.get_display_surface().get_rect().midright
|
||||
self.scoreboard = Scoreboard(self)
|
||||
self.music = Sound(self.get_resource("audio", "title"))
|
||||
self.advance = Sound(self.get_resource("audio", "title-advance"))
|
||||
self.prompt_surface = pygame.image.load(self.get_configuration("display", "prompt-image")).convert_alpha()
|
||||
self.prompt_surface = pygame.transform.smoothscale(self.prompt_surface, (440, 440 * 0.6666))
|
||||
self.subscribe(self.respond)
|
||||
|
||||
def respond(self, event):
|
||||
|
@ -286,11 +258,8 @@ class Title(GameChild):
|
|||
if not self.music.get_num_channels():
|
||||
self.music.play(-1, 0, 1000)
|
||||
self.get_game().static.noise.fadeout(1000)
|
||||
if self.delegate.compare(event, "left", cancel=False) or self.delegate.compare(event, "right", cancel=False):
|
||||
if self.delegate.compare(event, "advance"):
|
||||
self.holding_button = True
|
||||
elif self.delegate.compare(event, "left", cancel=True) or self.delegate.compare(event, "right", cancel=True):
|
||||
self.holding_button = False
|
||||
self.holding_button_elapsed = 0
|
||||
|
||||
def activate(self):
|
||||
self.active = True
|
||||
|
@ -332,17 +301,17 @@ class Title(GameChild):
|
|||
self.idle_time += self.get_game().time_filter.get_last_frame_duration()
|
||||
if self.holding_button:
|
||||
self.holding_button_elapsed += self.get_game().time_filter.get_last_frame_duration()
|
||||
logo = Sprite(self)
|
||||
font = pygame.font.Font(self.get_resource("terminus/TerminusItalic.ttf"),
|
||||
62 - int(self.holding_button_elapsed / self.get_configuration("input", "title-hold") * 38))
|
||||
logo.add_frame(self.get_game().orient(font.render("iBITFIT", True, pygame.Color(0, 0, 0), pygame.Color(255, 255, 255))))
|
||||
if not self.get_game().rotated:
|
||||
logo.location.midtop = self.get_display_surface().get_rect().midtop
|
||||
else:
|
||||
logo.location.midleft = self.get_display_surface().get_rect().midleft
|
||||
logo.update()
|
||||
self.button_prompt.update()
|
||||
self.scoreboard.update()
|
||||
logo = Sprite(self)
|
||||
logo.clear_frames()
|
||||
elapsed = self.holding_button_elapsed / self.get_configuration("input", "title-hold")
|
||||
if elapsed:
|
||||
logo.add_frame(self.get_game().orient(pygame.transform.scale(
|
||||
self.prompt_surface, (max(0, 440 - int(elapsed * 440)), max(0, 440 * 0.6666 - int(elapsed * 440 * 0.6666))))))
|
||||
else:
|
||||
logo.add_frame(self.prompt_surface)
|
||||
logo.location.center = self.get_display_surface().get_rect().center
|
||||
logo.update()
|
||||
|
||||
|
||||
class Strip(Sprite):
|
||||
|
@ -359,7 +328,6 @@ class Strip(Sprite):
|
|||
else:
|
||||
self.hshifts = Shift(self, -1, "shift-2"), Shift(self, 1, "shift-2")
|
||||
self.add_frames()
|
||||
self.subscribe(self.respond)
|
||||
|
||||
def deactivate(self):
|
||||
self.active = False
|
||||
|
@ -371,24 +339,13 @@ class Strip(Sprite):
|
|||
def add_frames(self):
|
||||
pass
|
||||
|
||||
def respond(self, event):
|
||||
"""
|
||||
Translate input events into movement of the sieve object. This function is usually set as a callback, but it can be called directly.
|
||||
|
||||
@param event `pygame.event.Event` with input
|
||||
"""
|
||||
if self.active:
|
||||
compare = self.delegate.compare
|
||||
if compare(event, "left") or compare(event, "left", True):
|
||||
self.hshifts[self.LEFT].active = not event.cancel
|
||||
elif compare(event, "right") or compare(event, "right", True):
|
||||
self.hshifts[self.RIGHT].active = not event.cancel
|
||||
|
||||
def activate(self):
|
||||
self.active = True
|
||||
|
||||
def update(self):
|
||||
if self.active:
|
||||
self.hshifts[self.LEFT].active = self.get_game().input.is_command_active("left")
|
||||
self.hshifts[self.RIGHT].active = self.get_game().input.is_command_active("right")
|
||||
for shift in self.hshifts:
|
||||
shift.update()
|
||||
if shift.time:
|
||||
|
@ -487,12 +444,20 @@ class Scoreboard(GameChild):
|
|||
sprites[ii][0].location.left = self.MARGIN
|
||||
sprites[ii][1].location.right = self.get_display_surface().get_rect().right - self.MARGIN
|
||||
y = self.get_display_surface().get_rect().centery + self.SPACING * (ii - len(self.SIZES) / 2)
|
||||
if (ii < 5):
|
||||
y -= 75
|
||||
else:
|
||||
y += 30
|
||||
for sprite in sprites[ii]:
|
||||
sprite.location.centery = y
|
||||
else:
|
||||
sprites[ii][0].location.bottom = self.get_display_surface().get_height() - self.MARGIN
|
||||
sprites[ii][1].location.top = self.MARGIN
|
||||
x = self.get_display_surface().get_rect().centerx + self.SPACING * (ii - len(self.SIZES) / 2)
|
||||
if (ii < 5):
|
||||
x -= 75
|
||||
else:
|
||||
x += 30
|
||||
for sprite in sprites[ii]:
|
||||
sprite.location.centerx = x
|
||||
|
||||
|
|
2
lib/pgfw
2
lib/pgfw
|
@ -1 +1 @@
|
|||
Subproject commit 34451c3f4cacee9b2df3b0dff68e6539f5754bc4
|
||||
Subproject commit 6adf4ec697bab7fdd677a3f4bdcf51abc9bed16f
|
Binary file not shown.
After Width: | Height: | Size: 139 KiB |
Loading…
Reference in New Issue