From a4a9cbe35e29fae1bdeb482ffed006e184037883 Mon Sep 17 00:00:00 2001 From: Rahul Raman Date: Mon, 14 Jan 2019 09:43:53 +0530 Subject: [PATCH] Update snowyPowerup.py Updated snowyPowerup.py to not let two portals open at the same position, added max portal number limits and changed the texture of the portal Powerup. --- mods/snowyPowerup.py | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/mods/snowyPowerup.py b/mods/snowyPowerup.py index e6dbddd..491f657 100644 --- a/mods/snowyPowerup.py +++ b/mods/snowyPowerup.py @@ -37,7 +37,7 @@ def __init__(self): self.powerupSound = bs.getSound("powerup01") self.powerdownSound = bs.getSound("powerdown01") self.dropSound = bs.getSound("boxDrop") - self.texPort = bs.getTexture("eyeColor") + self.texPort = bs.getTexture("ouyaOButton") # material for powerups self.powerupMaterial = bs.Material() @@ -147,6 +147,10 @@ def __init__(self,position=(0,1,0),powerupType='tripleBombs',expire=True): bs.gameTimer(defaultPowerupInterval-2500,bs.WeakCall(self._startFlashing)) bs.gameTimer(defaultPowerupInterval-1000,bs.WeakCall(self.handleMessage,bs.DieMessage())) + def delpor(self): + Portal.currentnum -= 1 + self.port.delete() + def handleMessage(self,m): self._handleMessageSanityCheck() @@ -179,8 +183,18 @@ def handleMessage(self,m): self.handleMessage(bs.DieMessage()) elif self.powerupType == 'portal': t = bsSpaz.gPowerupWearOffTime - self.port = Portal.Portal(position1 = node.position,r = 0.9,color = (random.random(),random.random(),random.random()),activity = bs.getActivity()) - bs.gameTimer(t,bs.Call(self.port.delete)) + if Portal.currentnum < Portal.maxportals : + Portal.currentnum += 1 + if self.node.position in Portal.lastpos : + self.port = Portal.Portal(position1 = None,r = 0.9,color = (random.random(),random.random(),random.random()),activity = bs.getActivity()) + bs.gameTimer(t,bs.Call(self.delpor)) + else : + m = self.node.position + Portal.lastpos.append(m) + self.port = Portal.Portal(position1 = self.node.position,r = 0.9,color = (random.random(),random.random(),random.random()),activity = bs.getActivity()) + bs.gameTimer(t,bs.Call(self.delpor)) + else : + bs.screenMessage('Only '+str(Portal.maxportals)+' pairs of portals are allowed at a time.') self._powersGiven = True self.handleMessage(bs.DieMessage()) else: