]> Skullheadx's Git Forge - Pygame-Jam.git/commitdiff
Portal Object in game
authorlbcmk <30442978+lbcmk@users.noreply.github.com>
Sun, 10 Jul 2022 02:49:45 +0000 (22:49 -0400)
committerlbcmk <30442978+lbcmk@users.noreply.github.com>
Sun, 10 Jul 2022 02:49:45 +0000 (22:49 -0400)
Function/Portal.py [new file with mode: 0644]
Function/WorldCoords.py [new file with mode: 0644]
Game.py

diff --git a/Function/Portal.py b/Function/Portal.py
new file mode 100644 (file)
index 0000000..af6230b
--- /dev/null
@@ -0,0 +1,41 @@
+from Setup import *
+from CommonImports.colours import white
+from Function.createText import createText
+from Function.WorldCoords import *
+
+class Transition:
+
+    def __init__(self, nextLevel, X, Y):
+        self.level = nextLevel
+        self.x = X
+        self.y = Y
+
+        self.height = 150
+        self.width = 80
+
+        self.portal_stage = 0
+        self.portalYAnim = 1
+        self.down = False
+
+        
+    def update(self):
+        return;
+
+    def draw(self, surf, 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]))
+
+        pg.draw.polygon(surf, (107, 18, 158), a)
+
+        if(self.portalYAnim <= -25 and self.down == False):
+            self.down = True
+        elif(self.portalYAnim >= 0):
+            self.down = False
+        
+        if(self.down == True):
+            self.portalYAnim += 1
+        else:
+            self.portalYAnim -= 1
diff --git a/Function/WorldCoords.py b/Function/WorldCoords.py
new file mode 100644 (file)
index 0000000..5772ea0
--- /dev/null
@@ -0,0 +1,7 @@
+from Setup import *
+
+def getWorldCoords(X, Y):
+    coords = get_display_rect(pg.Rect(X, Y, 0, 0))
+    coordsList = list(coords.topleft)
+
+    return coordsList
\ No newline at end of file
diff --git a/Game.py b/Game.py
index a4eda61d94d2e440ea3f5796db49a38a16120e0a..ebe6b6c32a78f85fbed06188a8960624951c18bf 100644 (file)
--- a/Game.py
+++ b/Game.py
@@ -1,3 +1,4 @@
+from re import T
 import Setup
 from Setup import *
 from Setup import camera_offset
@@ -11,6 +12,7 @@ from EndScreen import EndScreen
 from UI.DashMeter import DashMeter
 from UI.HealthBar import HealthBar
 
+from Function.Portal import Transition
 
 class Game:
 
@@ -35,6 +37,8 @@ class Game:
         self.level = 1
         self.scene.level = self.level
 
+        self.Transition = Transition(-2, 0,0)
+
     # def load_world(self, level):
 
     def update(self, delta):
@@ -56,6 +60,9 @@ class Game:
 
     def draw(self, surf):
         screen.fill((0, 191, 255))
+
+        self.Transition.draw(surf, 120, 625)
+
         self.world.draw(surf)
         for enemy in self.enemies:
             enemy.draw(surf)
@@ -68,6 +75,7 @@ class Game:
         if self.player.dead:
             self.scene.update()
             self.scene.draw()
+        
 
         # 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)