def spawnEnemy(): enemies.append( EnemyClass(screen, spawnPosX=rando(0, gameWindowWidth), spawnPosY=rando(0, gameWindowHeight), speedX=rando(-10, 10), speedY=rando(-10, 10)))
def createAlger(): algers.append( AlgerClass(screen, _x=rando(-100, gameWindowWidth + 100), _y=rando(-100, gameWindowHeight + 100), _width=rando(20, 75), _height=rando(20, 75)))
def createTerrain(): terrain.append( TerrainClass(screen, rando(-200, gameWindowWidth + 200), rando(-200, gameWindowHeight + 200), rando(10, 200), rando(10, 200))) if collisionChecker(playerObject, terrain[-1]): terrain.pop() createTerrain()
def __init__(self,screen,_x,_y,_width,_height): self.theScreen=screen self.x=_x self.y=_y self.whatSkrald = rando(1,6) self.Terrain1 = pygame.image.load('Skrald_20X90.png') self.Terrain2 = pygame.image.load('Skrald_200X100.png') self.Terrain3 = pygame.image.load('Skrald_40X70.png') self.Terrain4 = pygame.image.load('Skrald_50X50.png') self.Terrain5 = pygame.image.load('Skrald_100X200.png') self.Terrain6 = pygame.image.load('Skrald_70X40.png') if self.whatSkrald ==1: self.width = self.Terrain1.get_size()[0] self.height = self.Terrain1.get_size()[1] if self.whatSkrald ==2: self.width = self.Terrain2.get_size()[0] self.height = self.Terrain2.get_size()[1] if self.whatSkrald ==3: self.width = self.Terrain3.get_size()[0] self.height = self.Terrain3.get_size()[1] if self.whatSkrald ==4: self.width = self.Terrain4.get_size()[0] self.height = self.Terrain4.get_size()[1] if self.whatSkrald ==5: self.width = self.Terrain5.get_size()[0] self.height = self.Terrain5.get_size()[1] if self.whatSkrald ==6: self.width = self.Terrain6.get_size()[0] self.height = self.Terrain6.get_size()[1]
def __init__(self, screen, _x, _y, _width, _height): self.theScreen = screen self.x = _x self.y = _y self.whatSkrald = rando(1, 3) self.Terrain1 = pygame.image.load('Alge_20X40.png') self.Terrain2 = pygame.image.load('Alge_60X60.png') self.Terrain3 = pygame.image.load('Alge_80X40.png') if self.whatSkrald == 1: self.width = self.Terrain1.get_size()[0] self.height = self.Terrain1.get_size()[1] if self.whatSkrald == 2: self.width = self.Terrain2.get_size()[0] self.height = self.Terrain2.get_size()[1] if self.whatSkrald == 3: self.width = self.Terrain3.get_size()[0] self.height = self.Terrain3.get_size()[1]
def __init__(self,screen,terrainCollection,player): self.playerObject=player self.theScreen=screen self.Shark30 = pygame.image.load('Shark_1_30x30.png') self.width = self.Shark30.get_size()[0] self.height = self.Shark30.get_size()[1] self.screenWidth = self.theScreen.get_size()[0] # self.screenHeight = self.theScreen.get_size()[1] self.terrainCollection=terrainCollection self.randomLocation = rando(1,4) if self.randomLocation == 1: self.x = 0 self.y = 0 if self.randomLocation == 2: self.x = 1180 self.y = 780 if self.randomLocation == 3: self.x = 1180 self.y = 0 if self.randomLocation == 4: self.x = 0 self.y = 780
def r(a, b): if a < b: return rando(a, b) else: return rando(b, a)
if collisionChecker(enemy, playerObject): playerObject.DeathSFX.play() restartGame() if enemyIsDead: enemies.remove(enemy) for alger in algers: if collisionChecker(alger, playerObject): algers.remove(alger) playerObject.collisionSFX.play() playerObject.points += 1 createAlger() spawnEnemy() powerUp = rando( 0, 15 ) #Making a random power up, but for all mldules since the size of the player is determined by Module if powerUp == 1 and playerObject.clownfishSize == playerObject.clownfishIMG10 and playerObject.whatFish == 2: playerObject.changeSpeedTo(-1) playerObject.clownfishSize = playerObject.clownfishIMG20 playerObject.powerUpSFC.play() if powerUp == 1 and playerObject.AxolotlSize == playerObject.AxolotlIMG10 and playerObject.whatFish == 3: playerObject.changeSpeedTo(-1) playerObject.powerUpSFC.play() playerObject.AxolotlSize = playerObject.AxolotlIMG20 if powerUp == 1 and playerObject.goldfishSize == playerObject.goldfishIMG10 and playerObject.whatFish == 1: playerObject.changeSpeedTo(-1) playerObject.goldfishSize = playerObject.goldfishIMG20 playerObject.powerUpSFC.play() if powerUp == 2 and playerObject.clownfishSize == playerObject.clownfishIMG20 and playerObject.whatFish == 2: