def henryRoom(self): # Create objects in room player = char.Char(self.screen, self.pick, 300, 700) henry = char.Char(self.screen, 'henry', 470, 400) backDoor = door.Door(self.screen, 0, 800) npcs = [henry] doors = [backDoor] # Create game state while True: self.state = "henry" # Blit objects in room self.check_events(player) image = pygame.transform.scale( pygame.image.load( os.path.join(os.getcwd(), "images/henryRoom.png")), (self.height, self.width)) player.update() self.updateScreen(image, player, npcs, doors) # Room logic if self.collide(player, backDoor) == True: self.firstHallway() return None elif self.collide(player, henry) == True: if self.counter == 3: self.health = 100 self.key2 = True self.firstHallway() return None else: self.health -= 49 self.counter = 0 self.spawnRoom(640, 400) return None # Problem to solve linear = pygame.transform.scale( pygame.image.load( os.path.join(os.getcwd(), "images/question.png")), (790, 100)) # Set question hint = self.baseFont.render( "Give me the amount of pizzas equal to sisters", True, (0, 0, 0)) # Obtain rect hintRect = hint.get_rect() hintRect.top = 370 hintRect.right = 1100 # Blit question self.screen.blit(linear, (500, 300)) self.screen.blit(hint, hintRect) pygame.display.flip()
def jordansRoom(self): # Set flags flagBoi = False self.answer = '' self.check = '350' # Create objects in room player = char.Char(self.screen, self.pick, 100, 700) jordan = char.Char(self.screen, 'jordan', 450, 500) backDoor = door.Door(self.screen, 0, 800) npcs = [jordan] doors = [backDoor] # Create game state while True: self.state = "jordan" # Blit objects in room self.check_events(player) image = pygame.transform.scale( pygame.image.load( os.path.join(os.getcwd(), "images/jordanRoom.png")), (self.height, self.width)) player.update() self.updateScreen(image, player, npcs, doors) # Room logic if self.collide(player, backDoor) == True: self.secondHallway() return None # Problem to solve elif flagBoi == True: # Set question question_p1 = self.baseFont.render( "Given 50 bikes, each with a tank that can go 100 km: how many kms can you go?", True, (0, 0, 0)) question_p2 = self.baseFont.render( "(press ~ to restart, press <ENTER> to submit, press <BACKSPACE> to go back one character)", True, (0, 0, 0)) # Obtain rect p1Rect = question_p1.get_rect() p1Rect.centerx = 620 p1Rect.bottom = 300 p2Rect = question_p2.get_rect() p2Rect.centerx = 620 p2Rect.top = 300 # Blit question self.screen.blit(question_p1, p1Rect) self.screen.blit(question_p2, p2Rect) pygame.display.flip() # Raise flag elif self.collide(player, jordan) == True: flagBoi = True
def samsRoom(self): # Set flags flagBoi = False self.answer = '' self.check = '69' # Create objects in room player = char.Char(self.screen, self.pick, 100, 700) sam = char.Char(self.screen, 'sam', 640, 200) backDoor = door.Door(self.screen, 0, 800) npcs = [sam] doors = [backDoor] # Create game state while True: self.state = "sam" # Blit objects inroom self.check_events(player) image = pygame.transform.scale( pygame.image.load( os.path.join(os.getcwd(), "images/samRoom.png")), (self.height, self.width)) player.update() self.updateScreen(image, player, npcs, doors) # Room logic if self.collide(player, backDoor) == True: self.secondHallway() return None # Problem to solve elif flagBoi == True: # Set question question_p1 = self.baseFont.render( "What is sam's player level in tetris?", True, (0, 0, 0)) question_p2 = self.baseFont.render( "(press ~ to restart, press <ENTER> to submit, press <BACKSPACE> to go back one character)", True, (0, 0, 0)) # Obtain rects p1Rect = question_p1.get_rect() p1Rect.centerx = 620 p1Rect.bottom = 300 p2Rect = question_p2.get_rect() p2Rect.centerx = 620 p2Rect.top = 300 # Blit question self.screen.blit(question_p1, p1Rect) self.screen.blit(question_p2, p2Rect) pygame.display.flip() # Raise flag elif self.collide(player, sam) == True: flagBoi = True
def secondHallway(self): # Create objects in room player = char.Char(self.screen, self.pick, 640, 575) backDoor = door.Door(self.screen, 640, 800) jordansDoor = door.Door(self.screen, 750, 500) samsDoor = door.Door(self.screen, 640, 200) npcs = [] doors = [backDoor, jordansDoor, samsDoor] # Create game state while True: self.state = "second hallway" # Blit objects in room self.check_events(player) image = pygame.transform.scale( pygame.image.load( os.path.join(os.getcwd(), "images/secondhallway.png")), (self.height, self.width)) player.update() self.updateScreen(image, player, npcs, doors) # Room logic if self.collide(player, backDoor) == True: self.firstHallway() return None elif self.collide(player, samsDoor) == True: if self.key3 == False: pass elif self.key3 == True: self.samsRoom() return None elif self.collide(player, jordansDoor) == True: self.jordansRoom() return None
def spawnRoom(self, x, y): # Create objects in room player = char.Char(self.screen, self.pick, x, y) wisp = pizza.Pizza(self.screen) gateway = door.Door(self.screen, 0, 0) npcs = [wisp] doors = [gateway] # Create game state while True: self.state = "spawn" # Blit objects in room self.check_events(player) image = pygame.transform.scale( pygame.image.load(os.path.join(os.getcwd(), "images/spawn.png")), (self.height, self.width)) player.update() self.updateScreen(image, player, npcs, doors) # Continuous player rect x = player.rect.centerx y = player.rect.centery # Room logic if self.collide(player, wisp) == True: if self.health < 100: self.health += 5 self.counter += 1 self.spawnRoom(x, y) return None elif self.collide(player, gateway) == True: self.firstHallway() return None
def adamRoom(self): # Set flags flag = False # Create objects in room player = char.Char(self.screen, self.pick, 300, 550) adam = char.Char(self.screen, 'adam', 1280, 450) storage_adam = char.Char(self.screen, 'adam', 20, 430) sleeping_adam1 = char.Char(self.screen, 'adam', 500, 100) working_adam = char.Char(self.screen, 'adam', 1165, 450) backDoor = door.Door(self.screen, 640, 800) npcs = [adam, storage_adam, sleeping_adam1, working_adam] doors = [backDoor] # Create game state while True: self.state = "adam" # Blit objects in room self.check_events(player) image = pygame.transform.scale( pygame.image.load( os.path.join(os.getcwd(), "images/adamsRoom.png")), (self.height, self.width)) player.update() self.updateScreen(image, player, npcs, doors) # Room logic if self.collide(player, backDoor) == True: self.firstHallway() return None elif self.collide(player, storage_adam) == True: self.health -= 51 self.spawnRoom(640, 400) return None elif self.collide(player, sleeping_adam1) == True: if flag == False: self.health -= 51 self.spawnRoom(640, 400) return None elif flag == True: self.health = 100 self.key1 = True self.firstHallway() return None elif self.collide(player, working_adam) == True: self.health -= 51 self.spawnRoom(640, 400) return None # Problem to solve elif flag == True: # Set question/answer whatever = self.baseFont.render("how dare you disturb me", True, (0, 0, 0)) prompt = self.baseFont.render("what is the correct answer?", True, (0, 0, 0)) # Obtain rects whateverRect = whatever.get_rect() promptRect = prompt.get_rect() whateverRect.top = 500 promptRect.top = 600 whateverRect.right = 700 promptRect.right = 700 # Blit question/answer self.screen.blit(whatever, whateverRect) self.screen.blit(prompt, promptRect) pygame.display.flip() # Blit objects pumpernickel = pygame.transform.scale( pygame.image.load( os.path.join(os.getcwd(), "images/pumpernickel.png")), (160, 150)) self.screen.blit(pumpernickel, (410, 20)) go = pygame.transform.scale( pygame.image.load( os.path.join(os.getcwd(), "images/go.png")), (160, 150)) self.screen.blit(go, (1065, 380)) periwinkle = pygame.transform.scale( pygame.image.load( os.path.join(os.getcwd(), "images/periwinkle.png")), (160, 150)) self.screen.blit(periwinkle, (0, 360)) pygame.display.flip() # Raise flag elif self.collide(player, adam) == True: flag = True