def update(self): if self.pause == False: sheep.moveUp() if sheep.rect.x >=self.width: self.manager.go_to(ending.theEnd()) for red in self.red_sprites: if sheep.rect.colliderect(red): self.manager.go_to(deathPage.death()) for i in self.bone_sprites: boneHit = sheep.rect.colliderect(i) if boneHit == True: if self.sheepDirection == 'right': sheep.rect.right = i.rect.left elif self.sheepDirection == 'left': sheep.rect.left = i.rect.right elif self.sheepDirection == 'up': sheep.rect.top = i.rect.bottom elif self.sheepDirection == 'down': sheep.rect.bottom = i.rect.top
def update(self): #randomly create red sheep (coming from different parts of screen) if random.randint(0,60) == 0: enter = self.direction[random.randint(0,1)] if enter == 'left': redSheepy = straightSheep() redSheepy.rect.x = 30 redSheepy.rect.y = random.randint(self.height//2, self.height-(self.height//3)) self.straightSheep_list.add(redSheepy) self.all_sprites_list.add(redSheepy) elif enter == 'top': redSheeps = redSheep() redSheeps.rect.x = random.randint(0,self.width//2-180) redSheeps.rect.y = self.height/3 self.redSheep_list.add(redSheeps) self.all_sprites_list.add(redSheeps) #let sheep move anywhere but not out of screen sheep.moveUp() if sheep.rect.y>=self.height-(5*self.space): sheep.rect.y=self.height-(5*self.space) elif sheep.rect.y<=0: sheep.rect.y = self.space elif sheep.rect.x>=self.width-(4*self.space): sheep.rect.x = self.width-(4*self.space) #recursively make the smaller sheep on collision def makeSmall(x,y,n): if n == 4: print('stop') else: small = smallSheep() small.rect.x=x-80 small.rect.y=y-120 makeSmall(x,y+60,n+1) self.smSheep.add(small) self.all_sprites_list.add(small) #check for red sheep and poop collisions for i in self.all_sprites_list: for j in self.poop_list: sheepHit = j.rect.colliderect(i) if i in self.redSheep_list or i in self.straightSheep_list: if sheepHit == True: makeSmall(i.rect.x,i.rect.y,0) self.all_sprites_list.remove(i) self.poop_list.remove(j) self.all_sprites_list.remove(j) elif i in self.smSheep: if sheepHit == True: self.numKill += 1 self.smSheep.remove(i) self.all_sprites_list.remove(i) self.poop_list.remove(j) self.all_sprites_list.remove(j) if self.numKill >= 18: self.manager.go_to(couponsInstructions.instructing()) #check for redSheep and sheep collision (end game) for i in self.all_sprites_list: if i not in self.poop_list and i!=sheep: if sheep.rect.colliderect(i) == True: self.manager.go_to(deathPage.death()) elif i.rect.x>=self.width: self.manager.go_to(deathPage.death())
def update(self): def makeMeats(meatsForms, xLoc, yLoc, add=0): if len(meatsForms) == 0: print("a") elif meatsForms[0] == 'x': meat = meatSlab() meat.rect.x = xLoc + add meat.rect.y = yLoc self.meats_list.add(meat) self.all_sprites_list.add(meat) return makeMeats(meatsForms[1:], xLoc, yLoc, add + 100) elif meatsForms[0] == '\n': return makeMeats(meatsForms[1:], xLoc, yLoc - 50, add) #difficulty based on chosen option (see levels file) factor = levelPage.levels().difficult() if self.pause == False: #randomly makes meats if random.randint(0, 120) < 1: numMeats = random.randint(1, 6) meatsForms = meatSlab().slabTypes()[numMeats] xLoc = random.randint(self.width - self.space, self.width) yLoc = random.randint(self.height / 2 - self.space, self.height / 2 + self.space) makeMeats(meatsForms, xLoc, yLoc, add=0) #randomly makes dog sheep if random.randint(0, (40 * factor)) < 1: sheepDogs = sheepDog() randomLocation = random.randint( self.height // 2, self.height - (self.height / 4)) sheepDogs.rect.x = 0 sheepDogs.rect.y = randomLocation self.all_sprites_list.add(sheepDogs) self.sheep_dog_list.add(sheepDogs) #randomly makes falling knifes if random.randint(0, (120 * factor)) < 1: knife = Choppy() randomLocation = random.randint(self.width // 2, self.width) knife.rect.x = randomLocation knife.rect.y = 0 self.all_sprites_list.add(knife) self.knife_list.add(knife) sheep.moveUp() #check for collisions between sheep and knives for i in self.knife_list: i = sheep.rect.colliderect(i) if i == True: self.manager.go_to(deathPage.death()) #check for collisions between sheep and sheep dogs for j in self.sheep_dog_list: sheepDogHit = sheep.rect.colliderect(j) if sheepDogHit == True: self.manager.go_to(deathPage.death()) #check for collisions between sheep dogs and poop for poop in self.poop_list: for scrap in self.sheep_dog_list: poopHit = scrap.rect.colliderect(poop) if poopHit == True: pSD = poopSheepDog() pSD.rect.x = scrap.rect.x pSD.rect.y = scrap.rect.y - (1.5 * self.space) self.all_sprites_list.remove(scrap) self.all_sprites_list.remove(poop) self.sheep_dog_list.remove(scrap) self.poop_list.remove(poop) self.all_sprites_list.add(pSD) self.poop_sheep_dog_list.add(pSD) self.killSheep += 1 if self.killSheep == self.levelUp: self.manager.go_to(mainPlay.mainPlay()) #check when sheep jumps on a meat slab for meats in self.meats_list: meatHit = sheep.rect.colliderect(meats) if meatHit == True: sheep.rect.y = meats.rect.y - (3 * self.space) #scrolling (need to move everything also) if sheep.rect.right >= self.scrollValue: dx = sheep.rect.right - self.scrollValue sheep.rect.right = self.scrollValue for i in self.all_sprites_list: if i != sheep: if i not in self.sheep_dog_list: i.rect.x -= dx else: i.rect.x -= dx - self.speedOffset
def update(self): def makeBlood(bloodForm,xLoc,yLoc,add=0): if len(bloodForm) == 0: print("a") elif bloodForm[0] == 'x': blood = normCell() blood.rect.x = xLoc+add blood.rect.y = yLoc self.blood_list.add(blood) self.all_sprites_list.add(blood) return makeBlood(bloodForm[1:],xLoc,yLoc,add+100) elif bloodForm[0] == '\n': return makeBlood(bloodForm[1:],xLoc,yLoc-50,add) factor = levelPage.levels().difficult() if self.pause == False: #randomly makes blood droplets if random.randint(0,100) == 0: numBlood = random.randint(1,6) bloodForm = normCell().bloodTypes()[numBlood] xLoc = random.randint(self.width-self.space,self.width) yLoc = random.randint(self.height/2-self.space,self.height/2+self.space) makeBlood(bloodForm,xLoc,yLoc,add=0) #randomly make flagella fall if random.randint(0, (80*factor)) == 0: flagella = fallingFlagella() randLocation = random.randint(self.width/2,self.width) flagella.rect.x = randLocation flagella.rect.y = self.space self.all_sprites_list.add(flagella) self.flagella_list.add(flagella) #randomly makes scrapie sheep if random.randint(0, (60*factor)) == 0: randLocation = random.randint(self.width/2,self.height-2.5*self.space) pScrapie = peeScrapie() pScrapie.rect.x = 0 pScrapie.rect.y = randLocation self.all_sprites_list.add(pScrapie) self.peeScrap_list.add(pScrapie) sheep.moveUp() #check for collisions between sheep and flagella for i in self.flagella_list: flaHit = sheep.rect.colliderect(i) if flaHit == True: self.manager.go_to(deathPage.death()) #check for collisions between sheep and scrapie for i in self.peeScrap_list: scrapieHit = sheep.rect.colliderect(i) if scrapieHit == True: self.manager.go_to(deathPage.death()) #check for collisions between scrapie and poop for poop in self.poop_list: for pScrap in self.peeScrap_list: poopHit = pScrap.rect.colliderect(poop) if poopHit == True: poopPeeScraps = poopPeeScrapie() poopPeeScraps.rect.x = pScrap.rect.x poopPeeScraps.rect.y = pScrap.rect.y -(1.2*self.space) self.all_sprites_list.remove(pScrap) self.all_sprites_list.remove(poop) self.peeScrap_list.remove(pScrap) self.poop_list.remove(poop) self.all_sprites_list.add(poopPeeScraps) self.poopPeeScrap_list.add(poopPeeScraps) self.killSheep+=1 if self.killSheep == self.levelUp: self.manager.go_to(mainPlay.mainPlay()) #check when sheep jumps on blood for blood in self.blood_list: bloodHit = sheep.rect.colliderect(blood) if bloodHit == True: sheep.rect.y = blood.rect.y-(3*self.space) #scrolling (need to move everything also) if sheep.rect.right >= self.scrollValue: dx = sheep.rect.right - self.scrollValue sheep.rect.right = self.scrollValue for i in self.all_sprites_list: if i != sheep: if i not in self.peeScrap_list: i.rect.x -= dx else: i.rect.x -= dx - self.speedOffset
def update(self): #makes clouds based on patterns in mainCharacters file def makeClouds(cloudForm, xLoc, yLoc, add=0): if len(cloudForm) == 0: print("a") elif cloudForm[0] == 'x': cloud = Cloud() cloud.rect.x = xLoc + add cloud.rect.y = yLoc self.clouds_list.add(cloud) self.all_sprites_list.add(cloud) return makeClouds(cloudForm[1:], xLoc, yLoc, add + 100) elif cloudForm[0] == '\n': return makeClouds(cloudForm[1:], xLoc, yLoc - 50, add) #difficulty based on chosen option (see levels file) factor = levelPage.levels().difficult() #randomly makes clouds if self.pause == False: if random.randint(0, (120)) == 0: numClouds = random.randint(1, 7) cloudForm = Cloud().cloudTypes()[numClouds] xLoc = random.randint(self.width - self.space, self.width) yLoc = random.randint(self.height / 2 - self.space, self.height / 2 + self.space) makeClouds(cloudForm, xLoc, yLoc, add=0) #randomly make oil spots if random.randint(0, (240 * factor)) == 0: oilSpot = Drop() oilSpot.rect.x = self.width - (self.width / 10) oilSpot.rect.y = self.height - (self.height / 10) self.all_sprites_list.add(oilSpot) self.oilDrop_list.add(oilSpot) #randomly make pee spots if random.randint(0, (300 * factor)) == 0: pee = Pee() pee.rect.x = self.width - (self.width / 10) pee.rect.y = self.height - self.space self.all_sprites_list.add(pee) self.pee_list.add(pee) #randomly makes scrapie sheep if random.randint(0, (70 * factor)) == 0: scrapie = Scrapie() scrapie.rect.x = 0 scrapie.rect.y = self.height - (self.height / 6) self.all_sprites_list.add(scrapie) self.scrapie_list.add(scrapie) #randomly makes butchers if random.randint(0, (180 * factor)) == 0: butcher = Butcher() butcher.rect.x = self.width butcher.rect.y = self.height - (self.height / 6) self.all_sprites_list.add(butcher) self.butcher_list.add(butcher) #randomly makes bird if random.randint(0, (250 * factor)) == 0: bird = stupidBird() bird.rect.x = self.width / 6 bird.rect.y = 0 self.all_sprites_list.add(bird) self.bird_list.add(bird) #let sheep smoothly move sheep.moveUp() #check for collisions between sheep and butcher for butchers in self.butcher_list: butcherHit = sheep.rect.colliderect(butchers) if butcherHit == True: self.manager.go_to(dogPlayExplanation.dogPlayExplanation()) #check for collisions between sheep and pee pools for pee in self.pee_list: peeHit = sheep.rect.colliderect(pee) if peeHit == True: self.manager.go_to( pissPlayExplanation.pissPlayExplanation()) #check for collisions between sheep and oil pools for oils in self.oilDrop_list: oilHit = sheep.rect.colliderect(oils) if oilHit == True: self.manager.go_to(oilPlayExplanation.oilPlayExplanation()) #check for collisions between scrapie and poop for poop in self.poop_list: for scrap in self.scrapie_list: poopHit = scrap.rect.colliderect(poop) if poopHit == True: poopScrapie = poopScrap() poopScrapie.rect.x = scrap.rect.x poopScrapie.rect.y = scrap.rect.y self.all_sprites_list.remove(scrap) self.all_sprites_list.remove(poop) self.scrapie_list.remove(scrap) self.poop_list.remove(poop) self.all_sprites_list.add(poopScrapie) self.poopScrap_list.add(poopScrapie) self.sheepKill += 1 if self.sheepKill == self.levelUp: self.manager.go_to(finalTransition()) #check for collisions b/t sheep and bird-->increase difficulty to see for birdy in self.bird_list: birdHit = sheep.rect.colliderect(birdy) if birdHit == True: self.coverNum += 1 #check when sheep jumps on a cloud for clouds in self.clouds_list: cloudHit = sheep.rect.colliderect(clouds) if cloudHit == True: sheep.rect.y = clouds.rect.y - (3 * self.space) #check for collisions between sheep and scrapie for scraps in self.scrapie_list: scrapieHit = sheep.rect.colliderect(scraps) if scrapieHit == True: self.manager.go_to(deathPage.death()) #scrolling (need to move everything also) if sheep.rect.right >= self.scrollValue: dx = sheep.rect.right - self.scrollValue sheep.rect.right = self.scrollValue for i in self.all_sprites_list: if i != sheep: if i not in self.scrapie_list: i.rect.x -= dx else: i.rect.x -= dx - self.speedOffset
def update(self): def makeFaces(facesForm, xLoc, yLoc, add=0): if len(facesForm) == 0: print("a") elif facesForm[0] == 'x': face = evil() face.rect.x = xLoc + add face.rect.y = yLoc self.face_list.add(face) self.all_sprites_list.add(face) return makeFaces(facesForm[1:], xLoc, yLoc, add + 100) elif facesForm[0] == '\n': return makeFaces(facesForm[1:], xLoc, yLoc - 50, add) #difficulty based on chosen option (see levels file) factor = levelPage.levels().difficult() if self.pause == False: #randomly makes evil faces if random.randint(0, 150) == 0: numFaces = random.randint(1, 6) facesForm = evil().faceTypes()[numFaces] xLoc = random.randint(self.width - self.space, self.width) yLoc = random.randint(self.height / 3, self.height / 2 + self.space) makeFaces(facesForm, xLoc, yLoc, add=0) #randomly makes fire if random.randint(0, (130 * factor)) == 0: fire = firePic() fire.rect.x = self.width - self.space fire.rect.y = self.height - (self.height / 8) self.all_sprites_list.add(fire) self.fire_list.add(fire) #randomly makes oilScrapie sheep if random.randint(0, (50 * factor)) == 0: oilScraps = oilScrapie() oilScraps.rect.x = 0 oilScraps.rect.y = self.height - (self.height / 3) self.all_sprites_list.add(oilScraps) self.oilScrapie_list.add(oilScraps) #randomly makes falling rocks if random.randint(0, (110 * factor)) == 0: randomLocation = random.randint(self.width // 2, self.width) randomRockNum = random.randint(0, 2) selectedRock = self.rockTypes[randomRockNum] selectedRock.rect.x = randomLocation selectedRock.rect.y = 0 self.all_sprites_list.add(selectedRock) self.rocks_list.add(selectedRock) sheep.moveUp() #check for collisions between sheep and rocks for i in self.rocks_list: i = sheep.rect.colliderect(i) if i == True: self.manager.go_to(deathPage.death()) #check for collisions between sheep and oilScrapie for j in self.oilScrapie_list: oilScrapieHit = sheep.rect.colliderect(j) if oilScrapieHit == True: self.manager.go_to(deathPage.death()) #check for collisions between sheep and fire for k in self.fire_list: k = sheep.rect.colliderect(k) if k == True: self.manager.go_to(deathPage.death()) #check for collisions b/t oilScrapie and poop & replace w/ poop sheep for poop in self.poop_list: for scrap in self.oilScrapie_list: poopHit = scrap.rect.colliderect(poop) if poopHit == True: poopoilScrapie = oilPoopScrap() poopoilScrapie.rect.x = scrap.rect.x poopoilScrapie.rect.y = scrap.rect.y - (1.5 * self.space) self.all_sprites_list.remove(scrap) self.all_sprites_list.remove(poop) self.oilScrapie_list.remove(scrap) self.poop_list.remove(poop) self.all_sprites_list.add(poopoilScrapie) self.oilPoopScrap_list.add(poopoilScrapie) self.killSheep += 1 if self.killSheep == self.levelUp: self.manager.go_to(mainPlay.mainPlay()) #check when sheep jumps on a face for faces in self.face_list: faceHit = sheep.rect.colliderect(faces) if faceHit == True: sheep.rect.y = faces.rect.y - (3 * self.space) #scrolling (need to move everything also) if sheep.rect.right >= self.scrollValue: dx = sheep.rect.right - self.scrollValue sheep.rect.right = self.scrollValue for i in self.all_sprites_list: if i != sheep: if i not in self.oilScrapie_list: i.rect.x -= dx else: i.rect.x -= dx - self.speedOffset