From 2d3f08a7d1445913113289678036acb518d20062 Mon Sep 17 00:00:00 2001 From: "theo@manjaro" Date: Sat, 27 Nov 2021 20:24:50 +0100 Subject: [PATCH] Intro cinematic --- gamedata/assets/title.png | Bin 0 -> 965 bytes gamedata/game.py | 2 +- gamedata/objects/cinematic.py | 60 ++++++++++++++++++++++++++++++++++ gamedata/scenes.py | 8 +++-- 4 files changed, 67 insertions(+), 3 deletions(-) create mode 100644 gamedata/assets/title.png create mode 100644 gamedata/objects/cinematic.py diff --git a/gamedata/assets/title.png b/gamedata/assets/title.png new file mode 100644 index 0000000000000000000000000000000000000000..2cc0502c990b667dbd62fbd29399e9d872b691ac GIT binary patch literal 965 zcmV;$13LVPP)EX>4Tx04R}tkv&MmKpe$iTcx5EK|6>#WT;LSL`6Dk6^c+H)C#RSm|Xe=O&XFE z7e~Rh;NZt%)xpJCR|i)?5c~jfb8}L3krMxx6k5c1aNLh~_a1le0DryARI_6OP&La) zCE`LRyD9`<(Su?1BZiQ~Onpuilkgm0_we!cF3PjK&;2=im7K`{pFljzbi*RvAfDN@ zbk6(4VOEqB;&bA0gDyz?$aUG}H_ioz{X8>lq*L?6VPc`s#&R38qM;H`6Gs$PqkMnH zWrgz=XSG~q&3p0}hH~1nGy0}1FmMZWuerT7_i_3Fq^Yaq4RCM> zj1?$*-Q(R|?Y;ebrrF;QqU3VArm?_100006VoOIv0Db_(0Kvs%DQf@#010qNS#tmY z3ljhU3ljkVnw%H_000McNlirueSad^gZEa<4bO1wgWnpw> zWFU8GbZ8()Nlj2!fese{00EszL_t(|+U=XMP6IIvKzoRpjSZ<1pM%5*3j?3Q27-;x zU|@j}sXHt12^CT$Ha30$CNB}jPR_YY!+T4sHuk0I^~v#FhvnYE_o5=3ua9BT0j$$J z?63sTGQ0BR>GUKt@$tiBmkV~jx)05FcXY;Ch(Uo96o3;H{%sAKTT@2Yti3=@i9rE_ zLT%`KVo<=KeoC*zh-v1I_hR))ts2#ur!}A2>l8f>g8~N4A>I8;cR+jHiuZOMqT;6_ zHF0itzVGSGk5?L}<(WFZbQiy^_bk-Phe3fFH0PH! nb^kEh9K92@Ufw(y6q@D-qt)|)B1W2o00000NkvXXu0mjf!3MU~ literal 0 HcmV?d00001 diff --git a/gamedata/game.py b/gamedata/game.py index 883901e..0d4eaef 100644 --- a/gamedata/game.py +++ b/gamedata/game.py @@ -105,7 +105,7 @@ class Game(): self.pasttime = time.time() # Je charge la scene de base - scenes.overworld(self) + scenes.boot(self) def set_camera(self,posx,posy): self.globals["camerax"], self.globals["cameray"] = posx,posy diff --git a/gamedata/objects/cinematic.py b/gamedata/objects/cinematic.py new file mode 100644 index 0000000..74be728 --- /dev/null +++ b/gamedata/objects/cinematic.py @@ -0,0 +1,60 @@ +from gamedata.objects.base import BaseObject +from gamedata.objects.transition import Transition + +class Cinematic(BaseObject): + + def __init__(self,game): + + super().__init__(0,0,game) + + text = """More and more trash is being thrown away +It's up to you now to clean everything up +Watch out for the baddies !""" + + 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(5) + + 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() + + + 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) + diff --git a/gamedata/scenes.py b/gamedata/scenes.py index 17833b4..24e8c7c 100644 --- a/gamedata/scenes.py +++ b/gamedata/scenes.py @@ -2,9 +2,9 @@ from gamedata.objects.ingame.player import Player from gamedata.objects.ingame.tileset import TilesetRenderer from gamedata.objects.ingame.water import Water from gamedata.objects.results import Results +from gamedata.objects.cinematic import Cinematic def ingame(game,level="Level 2"): - game.scaleCamera(416,234) game.globals["camerax"] = 0 game.globals["cameray"] = 0 game.gameloop.reinit() @@ -16,9 +16,13 @@ def ingame(game,level="Level 2"): game.gameloop.summon(p1) def overworld(game): - game.scaleCamera(416,234) game.globals["camerax"] = 0 game.globals["cameray"] = 0 game.gameloop.reinit() tileset = TilesetRenderer(0,0,game,"Overworld") game.gameloop.summon(tileset) + +def boot(game): + game.scaleCamera(416,234) + c = Cinematic(game) + game.gameloop.summon(c)