From: lbcmk <30442978+lbcmk@users.noreply.github.com> Date: Sun, 10 Jul 2022 18:06:14 +0000 (-0400) Subject: It can now check if the player is in front of the portal X-Git-Url: http://git.skullheadx.com/nixos/static/gitweb.css?a=commitdiff_plain;h=6017084f769e2799d5fdb4b1aa2af1c923c106af;p=Pygame-Jam.git It can now check if the player is in front of the portal --- diff --git a/Assets/buttons/e.png b/Assets/buttons/e.png new file mode 100644 index 0000000..d8b0b3b Binary files /dev/null and b/Assets/buttons/e.png differ 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)