from gamedata.objects.base import BaseObject from gamedata.objects.transition import Transition class EndCinematic(BaseObject): def __init__(self,game): super().__init__(0,0,game) clean = len(game.globals["completedlevels"])==self.game.globals["nblevels"] speedrun = len(game.globals["speedrunlevels"])==self.game.globals["nblevels"] self.medalwave = self.game.sprite_lib["medals/waveoff.png"] self.medalclock = self.game.sprite_lib["medals/clockoff.png"] self.bgm = self.game.sound_lib["bgm/cinematic.ogg"] self.bgm.play() self.game.globals["levelname"]=None text = """Good job finishing all those levels ! But there is some trash left Try cleaning everything up !""" if clean: self.medalwave = self.game.sprite_lib["medals/wave.png"] text = """Thanks for cleaning everything ! Try to beat every level as fast as you can !""" if speedrun: self.medalclock = self.game.sprite_lib["medals/clock.png"] text = """You were quick ! But there's some trash left Try cleaning everything up !""" if speedrun and clean: text = """Good job completing the game ! You truly are amazing !""" text+=""" Made by @justayte for the #Seajam Go support #TeamSeas""" self.lines = text.split("\n") self.sprites = [] for i in self.lines: self.sprites.append(game.getchars(i)) self.currentlines = 1 self.timer = game.lib.Timer(4) self.textpadding = 10 self.depth = 2 self.fill = game.pygame.Surface([self.game.globals["cameraw"],self.game.globals["camerah"]]) self.fill.fill([62,33,55]) self.totalheight = len(self.lines)*9+(len(self.lines)-1)*self.textpadding self.offset = (self.game.globals["camerah"]-self.totalheight)/2 self.title = self.game.sprite_lib["title.png"] self.sfx = self.game.sound_lib["sfx/return.wav"] def step(self): if self.currentlines < len(self.lines)+2 and self.timer.tick(self.game.dt): self.currentlines += 1 if self.currentlines == len(self.lines): self.timer = self.game.lib.Timer(5) elif self.currentlines == len(self.lines)+2: # Spawn transition t = Transition(self.game) self.game.gameloop.summon(t) self.sfx.play() self.bgm.stop() if self.game.inputs["keys"]["up"]["timer"]==1: self.timer.timer = 0 def draw(self): self.game.window.blit(self.fill,[0,0]) if self.currentlines<=len(self.lines): for i in range(self.currentlines): cx = self.game.globals["cameraw"]/2 self.game.lib.drawcenter(self.game,self.sprites[i],cx,self.offset+i*(self.textpadding+9)) else: cx = self.game.globals["cameraw"]/2 cy = self.game.globals["camerah"]/2 self.game.lib.drawcenter(self.game,self.title,cx,cy) self.game.lib.drawcenter(self.game,self.medalwave,cx-20,cy+40) self.game.lib.drawcenter(self.game,self.medalclock,cx+20,cy+40)