You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

191 lines
9.4 KiB
Python

#####
# Intro scene
#####
import logging
from Remake_1869 import Utils
from pyglet.window import key
from pyglet.window import mouse
class IntroScene:
def __init__(self):
self.sceneName = "INTRO"
print('Current Scene: {}'.format(self.sceneName))
self.isAlive = True
self.isInTransfer = False
self.introSkipped = False
self.targetScene = None
self.mouse_x = 0
self.mouse_y = 0
self.current_ScenePhase = 1
self.remaining_fading_toggle_alpha = 255
def close(self,game):
#ensure everything must be closed or Fade-out is fadeout
game.clearStopwatchTask(game.d_active_sprites['blackscreen'])
game.register_animation(game.d_active_sprites['blackscreen'],'FadeInSlow')
game.setStopwatch(game.d_active_sprites['blackscreen'],5*60)
game.register_animation(game.d_active_labels['press_enter'],'FadingToggleAlpha')
game.setStopwatch(game.d_active_labels['press_enter'],10)
self.current_ScenePhase = 10
def on_mouse_motion(self, game, x, y, dx, dy):
self.mouse_x = x
self.mouse_y = y
def on_mouse_press(self, game, x, y, button, modifiers):
if button == 1: # Left click
pass
def on_key_press(self, game, symbol, modifiers):
if self.current_ScenePhase < 8:
for sprite in game.d_active_sprites:
game.d_active_sprites[sprite].opacity = 0
game.clear_animationLists()
self.current_ScenePhase = 8
self.introSkipped = True
else:
if symbol == key.ENTER:
self.isInTransfer = True
self.targetScene = 'CONFIG'
self.close(game)
def initializeSceneLogic(self,game):
game.register_animation(game.d_active_sprites['max_design_intro_sprite'],'FadeIn')
game.setStopwatch(game.d_active_sprites['max_design_intro_sprite'],5*60)
def prepareSprites(self, game, d_sprites):
d_sprites['max_design_intro_sprite'].opacity = 0
d_sprites['artwork_intro_sprite'].opacity = 0
d_sprites['programmers_intro_sprite'].opacity = 0
d_sprites['music_intro_sprite'].opacity = 0
d_sprites['title_intro_sprite'].opacity = 0
d_sprites['blackscreen'].opacity = 0
self.initializeSceneLogic(game)
def killSprites(self,game, d_sprites):
d_sprites['max_design_intro_sprite'].batch = None
d_sprites['artwork_intro_sprite'].batch = None
d_sprites['programmers_intro_sprite'].batch = None
d_sprites['music_intro_sprite'].batch = None
d_sprites['title_intro_sprite'].batch = None
d_sprites['blackscreen'].batch = None
def prepareLabels(self, game, d_labels):
d_labels['press_enter'].color = (255,255,255,0)
def killLabels(self, game ,d_labels):
d_labels['press_enter'].batch = None
def prepareWidgets(self, game, d_widgets):
pass
def killWidgets(self, game ,d_widgets):
pass
def maintain_SpriteAnimations(self, l_deactivateAnims, sprite, animationType):
if animationType is 'FadeIn':
if Utils.fadeIn_sprite(sprite,sprite.opacity,5) is False:
l_deactivateAnims.append(sprite)
if animationType is 'FadeInSlow':
if Utils.fadeIn_sprite(sprite,sprite.opacity,2) is False:
l_deactivateAnims.append(sprite)
if animationType is 'FadeOut':
if Utils.fadeOut_sprite(sprite,sprite.opacity,5) is False:
l_deactivateAnims.append(sprite)
def maintain_LabelAnimations(self, l_deactivateAnims, label, animationType):
if animationType is 'ToggleAlpha':
Utils.toggle_label(label, label.color)
l_deactivateAnims.append(label)
if animationType is 'FadingToggleAlpha':
if self.remaining_fading_toggle_alpha > 0:
self.remaining_fading_toggle_alpha -= 16
else:
self.remaining_fading_toggle_alpha = 0
Utils.fading_toggle_label(label, label.color, self.remaining_fading_toggle_alpha)
l_deactivateAnims.append(label)
if animationType is 'FadeIn':
if Utils.fadeIn_label(label,label.color,5) is False:
l_deactivateAnims.append(label)
def maintain_WidgetAnimation(self, l_deactivateAnims, widget, animationType):
pass
def doSceneLogic(self,game):
if self.current_ScenePhase == 1:
if game.checkStopwatch(game.d_active_sprites['max_design_intro_sprite'],0):
game.clearStopwatchTask(game.d_active_sprites['max_design_intro_sprite'])
game.register_animation(game.d_active_sprites['max_design_intro_sprite'],'FadeOut')
game.setStopwatch(game.d_active_sprites['max_design_intro_sprite'],3*60)
self.current_ScenePhase = 2
if self.current_ScenePhase == 2:
if game.checkStopwatch(game.d_active_sprites['max_design_intro_sprite'],0):
game.clearStopwatchTask(game.d_active_sprites['max_design_intro_sprite'])
game.register_animation(game.d_active_sprites['artwork_intro_sprite'],'FadeIn')
game.setStopwatch(game.d_active_sprites['artwork_intro_sprite'],10*60)
self.current_ScenePhase = 3
if self.current_ScenePhase == 3:
if game.checkStopwatch(game.d_active_sprites['artwork_intro_sprite'],0):
game.clearStopwatchTask(game.d_active_sprites['artwork_intro_sprite'])
game.register_animation(game.d_active_sprites['artwork_intro_sprite'],'FadeOut')
game.setStopwatch(game.d_active_sprites['artwork_intro_sprite'],3*60)
self.current_ScenePhase = 4
if self.current_ScenePhase == 4:
if game.checkStopwatch(game.d_active_sprites['artwork_intro_sprite'],0):
game.clearStopwatchTask(game.d_active_sprites['artwork_intro_sprite'])
game.register_animation(game.d_active_sprites['programmers_intro_sprite'],'FadeIn')
game.setStopwatch(game.d_active_sprites['programmers_intro_sprite'],10*60)
self.current_ScenePhase = 5
if self.current_ScenePhase == 5:
if game.checkStopwatch(game.d_active_sprites['programmers_intro_sprite'],0):
game.clearStopwatchTask(game.d_active_sprites['programmers_intro_sprite'])
game.register_animation(game.d_active_sprites['programmers_intro_sprite'],'FadeOut')
game.setStopwatch(game.d_active_sprites['programmers_intro_sprite'],3*60)
self.current_ScenePhase = 6
if self.current_ScenePhase == 6:
if game.checkStopwatch(game.d_active_sprites['programmers_intro_sprite'],0):
game.clearStopwatchTask(game.d_active_sprites['programmers_intro_sprite'])
game.register_animation(game.d_active_sprites['music_intro_sprite'],'FadeIn')
game.setStopwatch(game.d_active_sprites['music_intro_sprite'],10*60)
self.current_ScenePhase = 7
if self.current_ScenePhase == 7:
if game.checkStopwatch(game.d_active_sprites['music_intro_sprite'],0):
game.clearStopwatchTask(game.d_active_sprites['music_intro_sprite'])
game.register_animation(game.d_active_sprites['music_intro_sprite'],'FadeOut')
game.setStopwatch(game.d_active_sprites['music_intro_sprite'],3*60)
self.current_ScenePhase = 8
if self.current_ScenePhase == 8:
if game.checkStopwatch(game.d_active_sprites['music_intro_sprite'],0) or self.introSkipped:
game.clearStopwatchTask(game.d_active_sprites['music_intro_sprite'])
game.register_animation(game.d_active_sprites['title_intro_sprite'],'FadeIn')
game.setStopwatch(game.d_active_sprites['title_intro_sprite'],5*60)
self.current_ScenePhase = 9
if self.current_ScenePhase == 9:
if game.checkStopwatch(game.d_active_sprites['title_intro_sprite'],0):
game.clearStopwatchTask(game.d_active_sprites['title_intro_sprite'])
game.register_animation(game.d_active_labels['press_enter'],'FadeIn')
game.setStopwatch(game.d_active_labels['press_enter'],3*60)
self.current_ScenePhase = 10
if self.current_ScenePhase == 10:
if game.checkStopwatch(game.d_active_labels['press_enter'],0):
game.clearStopwatchTask(game.d_active_labels['press_enter'])
if self.isInTransfer is True:
game.register_animation(game.d_active_labels['press_enter'],'FadingToggleAlpha')
game.setStopwatch(game.d_active_labels['press_enter'],10)
else:
game.register_animation(game.d_active_labels['press_enter'],'ToggleAlpha')
game.setStopwatch(game.d_active_labels['press_enter'],30)
def run(self, game):
game.stopwatch_tick()
self.doSceneLogic(game)
if self.isInTransfer is True:
if game.checkStopwatch(game.d_active_sprites['blackscreen'],0):
self.isAlive = False
self.targetScene = 'CONFIG'
return self.targetScene