]> Skullheadx's Git Forge - Pygame-Jam.git/commitdiff
It can now check if the player is in front of the portal
authorlbcmk <30442978+lbcmk@users.noreply.github.com>
Sun, 10 Jul 2022 18:06:14 +0000 (14:06 -0400)
committerlbcmk <30442978+lbcmk@users.noreply.github.com>
Sun, 10 Jul 2022 18:06:14 +0000 (14:06 -0400)
Assets/buttons/e.png [new file with mode: 0644]
Function/Portal.py
Game.py

diff --git a/Assets/buttons/e.png b/Assets/buttons/e.png
new file mode 100644 (file)
index 0000000..d8b0b3b
Binary files /dev/null and b/Assets/buttons/e.png differ
index af6230b9be663c27bb4a8e0c8c56b569f55f6ba5..342470db83f54927670f679ee3caaa8265befa9a 100644 (file)
@@ -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 40b125600fef7bbec87ceb641e2d8734406f67e6..a70b667f65ba75705dd26b82c30e5f9de621bcfb 100644 (file)
--- 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)