From: lbcmk <30442978+lbcmk@users.noreply.github.com> Date: Sun, 10 Jul 2022 02:49:45 +0000 (-0400) Subject: Portal Object in game X-Git-Url: http://git.skullheadx.com/nixos/static/index.html?a=commitdiff_plain;h=00f7497d976ad0025c3b48e59c63ed41c865b36f;p=Pygame-Jam.git Portal Object in game --- diff --git a/Function/Portal.py b/Function/Portal.py new file mode 100644 index 0000000..af6230b --- /dev/null +++ b/Function/Portal.py @@ -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 index 0000000..5772ea0 --- /dev/null +++ b/Function/WorldCoords.py @@ -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 a4eda61..ebe6b6c 100644 --- 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)