From 6017084f769e2799d5fdb4b1aa2af1c923c106af Mon Sep 17 00:00:00 2001 From: lbcmk <30442978+lbcmk@users.noreply.github.com> Date: Sun, 10 Jul 2022 14:06:14 -0400 Subject: [PATCH] It can now check if the player is in front of the portal --- Assets/buttons/e.png | Bin 0 -> 540 bytes Function/Portal.py | 19 ++++++++++++++++--- Game.py | 4 +++- 3 files changed, 19 insertions(+), 4 deletions(-) create mode 100644 Assets/buttons/e.png diff --git a/Assets/buttons/e.png b/Assets/buttons/e.png new file mode 100644 index 0000000000000000000000000000000000000000..d8b0b3b0c55cce93dcf87035ff7755dffdf04d56 GIT binary patch literal 540 zcmeAS@N?(olHy`uVBq!ia0y~yU=RRd4mJh`2Kmqb6B!s7^D~{D12U7785lGsmQLL3 z?Gz|+tiG-#(anW7ke5%4mn%@9H*rF@=?cfN?zsI-TTk!x^2ok$Nx{TLx0d%W`&PEK ztd0RJg1&zlYjqX3f6qv0nRj~U`~K&1o0Y9Q%o@Cpvan9_A^G3n$GflByzoh*y_{5)WxmdwQ?Tz-6)3@GNUh%bg z`6wym)q*pLK1wYdk5oNpntqzX;i2o5wzl?h>3ycxk1jr0AAC^2ecGIgzl)|V&5p`) z`?95`QcLUm|H@f2PjhFa&$LIEGmGC#N(t{12EF z(lt?Vi6n=|RgSRp99Pb{O!HIm6_GyBbedJ+xgvASy(5_n7Ac(^(zhxZ#ZDRI_qgZ_ s2s1DEu+Tz`?H)r!m8!lqld%c|PpyQ)nSMzn1_lNOPgg&ebxsLQ0BjrNnE(I) literal 0 HcmV?d00001 diff --git a/Function/Portal.py b/Function/Portal.py index af6230b..342470d 100644 --- a/Function/Portal.py +++ b/Function/Portal.py @@ -17,16 +17,29 @@ class Transition: self.portalYAnim = 1 self.down = False + self.buttonStage = 0 + buttonImage = pg.image.load('./Assets/buttons/e.png') + self.buttonImage = pg.transform.scale(buttonImage, (self.width/2, self.width/2)) + def update(self): return; - def draw(self, surf, offsetX=0, offsetY=0): + def draw(self, surf, playerPos, playerOffset=[0,0], offsetX=0, offsetY=0): coords = getWorldCoords(0, 0) coords[1] += self.portalYAnim a = (((offsetX-self.width/2) + coords[0], offsetY + coords[1]), (offsetX+coords[0], offsetY-self.height/2+coords[1]), (offsetX+self.width/2 + coords[0], offsetY+coords[1]), (offsetX + coords[0], offsetY+self.height/2 + coords[1])) + # print(a[0][0], a[1][1], a[2][0], a[3][1]) + # print(playerPos[0]+40, playerPos[1]-250) + + if(a[0][0] < playerPos[0]+playerOffset[0] < a[2][0] and a[1][1] < playerPos[1]+playerOffset[1] < a[3][1]): + # self.buttonStage += 0.1 + surf.blit(self.buttonImage, (a[0][0]+self.width/4, a[1][1]-(2*self.width/3))) + pressed = pg.key.get_pressed() + if pressed[pg.K_e] or pressed[pg.K_RETURN]: + pass; pg.draw.polygon(surf, (107, 18, 158), a) @@ -36,6 +49,6 @@ class Transition: self.down = False if(self.down == True): - self.portalYAnim += 1 + self.portalYAnim += 0.5 else: - self.portalYAnim -= 1 + self.portalYAnim -= 0.5 diff --git a/Game.py b/Game.py index 40b1256..a70b667 100644 --- a/Game.py +++ b/Game.py @@ -61,7 +61,7 @@ class Game: def draw(self, surf): screen.fill((0, 191, 255)) - self.Transition.draw(surf, 120, 625) + self.Transition.draw(surf, self.player.position, [40, -250], 120, 625) # screen.fill((255,255,255)) # sky = pg.image.load("Assets/world/SKY.png") @@ -70,6 +70,7 @@ class Game: for enemy in self.enemies: enemy.draw(surf) + self.player.draw(surf) self.dashMeter.update(self.player.lastDash) self.dashMeter.draw(surf) @@ -80,6 +81,7 @@ class Game: self.scene.draw() + # print(self.player.get_collision_rect())s # Debug Lines. DO NOT CROSS THEM! pg.draw.line(surf, (255, 0, 0), -Setup.camera_offset, pg.Vector2(SCREEN_WIDTH, -Setup.camera_offset.y), 10) pg.draw.line(surf, (255, 0, 0), -Setup.camera_offset, pg.Vector2(-Setup.camera_offset.x, SCREEN_HEIGHT), 10) -- 2.54.0