def gen(xmax, ymax): # genere le tableau de base tab = [] for y in range(ymax): line = [] for x in range(xmax): if y == 0 and x == 0: line.append("1") elif y == ymax - 1 and x == xmax - 1: line.append("0") else: if y % 2 == 0: if x % 2 != 0: line.append("X") else: line.append("0") else: line.append("X") tab.append(line) y = 0 x = 0 while not end(tab, ymax, xmax): y, x = move(tab, y, x, ymax, xmax) if goto_up(tab, x, y) == "no" and goto_down( tab, x, y, ymax) == "no" and goto_left(tab, x, y) == "no" and goto_right( tab, x, y, xmax) == "no" and not end(tab, ymax, xmax): x, y = newway(tab, ymax, xmax) return tab
def handleKeys(keys): nAcc = np.array([0, 0]) if (keys[pygame.K_q]): end() if (keys[pygame.K_DOWN]): nAcc[1] = 1 elif (keys[pygame.K_UP]): nAcc[1] = -1 if (keys[pygame.K_LEFT]): nAcc[0] = -1 elif (keys[pygame.K_RIGHT]): nAcc[0] = 1 return nAcc
def show_end_screen(self): #end show #shows the end screen when the player dies time.sleep(1) end() draw_text(screen, "Score: " + str(self.score), 50, 400, 300, WHITE) pg.display.update() #waits for an input from the user about respawning i = 1 while i < 6: for event in pg.event.get(): if event.type == pg.KEYDOWN: if event.key == pg.K_SPACE: self.new() time.sleep(i) i += 1 #exits if no input is given for 5 seconds exit()
ry_coor = 450 rx_size = 200 ry_size = 100 font = pygame.font.Font('freesansbold.ttf', 60) #Who_win = check_for_win() #if who_win == User_win: if User_win: screen.blit(font.render('YOU WON', True, cyber_blue), (rx_coor - 50, ry_coor - 200)) else: screen.blit(font.render('YOU LOST', True, cyber_blue), (rx_coor - 50, ry_coor - 200)) # end button if endgame == True: pygame.draw.rect(screen, cyber_blue, (rx_coor, ry_coor, rx_size, ry_size), 15) screen.blit(font.render('QUIT', True, cyber_blue), (rx_coor + 22, ry_coor + 25)) # (x coor, y coor, x size, y size) pygame.display.update() if event.type == pygame.MOUSEBUTTONDOWN: # Set the x, y postions of the mouse click x, y = event.pos if rx_coor < x < (rx_coor + rx_size) and ry_coor < y < (ry_coor + ry_size): end()
def MainHall(): print("============================= Main Hall =============================") print("\nYou are in the Main Hall. All the people were gathered around Jon’s body (examine body), quietly staring at the body and each other.") print("\nYou see: Rob, Eric, Pennyworth, Sansa, Bran (You can interact with these people by typing 'talk' followed by the name, for example talk Rob") action=input("What you want to do in the main hall? :") if action == 'examine body': print("============================= Body Examination =============================") print("\nYour dear friend Jon is laying on the floor on his stomach in a puddle of blood, with the dagger in his back.") print("\nThe dagger that Jon was stabbed, was made of stainless steel. it had an approximately 8-inch blade, and approximately 6-inch handle. The dagger was seamlessly transferred from the blade into handle, without any visible transition elements, with any had guard. The handle was made of black obsidian.") print("\nSurprisingly the blade had a 10-inch string resembling dental floss attached to the end of its handle, with a small loop at the end.") print("\nAfter closer examination, you noticed that at the butt of the handle, there was a small etching 'SSA'. What does the 'SSA' stand for? Perhaps Stainless Steel, who knows?") print("\nIn Jon's pockets you found a cellphone, a notepad (use notepad), a key, a dagger (use dagger name).") print("\n These items were added to your inventory, you see items in the inventory by typing 'inventory'") inventory.add("cellphone(cellphone find),(sellphone sort)") inventory.add("notepad (use notepad)") inventory.add("Study Room key") inventory.add("dagger") Clues.add("dagger has engraved SSA") print("\nThe cell phone looked just like a regular phone, with two additional application: sort, and find (activate them by typing 'cellphone sort' and 'cellphone find').") print("\nPerhaps I should check the kitchen, to see if any knives are missing, or talk to sombody") if action == 'talk Eric': Eric() if action == 'talk Pennyworth': Pennyworth() if action == 'talk Rob': Rob() if action == 'talk Sansa': Sansa() if action == 'use notepad': Notepad() if action == 'clues': print("============================= Clues =============================") print(Clues) if action == 'rooms': print("============================= Rooms =============================") print(rooms) if action == 'people': print("============================= People =============================") print(people) if action == 'inventory': print("============================= Inventory =============================") print(inventory) if action == 'instructions': inst() if action == 'cellphone sort': print("============================= Cellphone Sort =============================") print("Do you want to sort the SafeCombo list?") sortAction=input("yes or no :") if sortAction == 'yes': SortedList=bubSortRec(list(SafeCombo)) print("This is the sorted list: ",SortedList) print("According to the Jon's Notepad (examine notepad), there are some additional steps have to be taken in order to find the combination.") print("Now this list is stored in SortedList array") if action == 'cellphone find': print("============================= Cellphone Find =============================") num = input("Which number would you like to find? :") result = binarySearchRec(SortedList1, 0, len(SortedList1)-1, int(num)) print(int(result)) if action == 'accuse Pennyworth': print("============================= Pennyworth =============================") print("\nPennyworth: You are mistaken!") if action == 'accuse Eric': print("============================= Eric =============================") print("\nSansa: You can't be serious!") if action == 'accuse Sansa' and len(Clues)<10: print("============================= Sansa =============================") print("Sansa: You got nothing on me!") if action == 'accuse Sansa' and len(Clues)>=10: print("============================= Sansa =============================") print("\nSansa: Oh noooo!") print("\nSansa: It was all Rob's idea.") print("\nRob: Sansa and I, were planning this since we found out that Jon knew about us, and was going cut Sansa's funds!") print("\nRob turns around, leans his head back, and starts pulling out a string from his throat.") print("\nSuddenly you se a dagger coming out from his throat, the same dagger that was used to kill Jon.") print("\nWith dagger in his hand, Rob is charging at you!") defense = input("\nWhat's your move? :") if defense == 'use gun Rob' and 'gun' in inventory: print("You aim at Rob, and slowly squeeze trigger.") print("Rob's body slowly collapsed on the floor... ") end() if defense == 'use gun Rob' and 'gun' not in inventory: print("\nYou don't have a gun!") print("You got stabbed in the heart, everything became blurry and dark.") end() if defense == 'use dagger Rob': print("\nYou were able to stab Rob, befor he stabbed you.") print("Rob's body slowly collapsed on the floor... ") end() if action == 'accuse Rob' and len(Clues)<10: print("============================= Rob =============================") print("You got nothing on me!") if action == 'accuse Rob' and len(Clues)>=10: print("============================= Rob =============================") print("\nRob: You got me!") print("\nRob: Sansa and I, were planning this since we found out that Jon knew about us, and was going cut Sansa's funds!") print("\nRob turns around, leans his head back, and starts pulling out a string from his throat.") print("\nSuddenly you se a dagger coming out from his throat, the same dagger that was used to kill Jon.") print("\nWith dagger in his hand, Rob is charging at you!") defense = input("\nWhat's your move? :") if defense == 'use gun Rob' and 'gun' in inventory: print("You aim at Rob, and slowly squeeze trigger.") print("Rob's body slowly collapsed on the floor... ") if defense == 'use gun Rob' and 'gun' not in inventory: print("\nYou don't have a gun!") print("You got stabbed in the heart, everything became blurry and dark.") end() if defense == 'use dagger Rob': print("\nYou were able to stab Rob, befor he stabbed you.") print("Rob's body slowly collapsed on the floor... ") end() if action == 'foyer': room() else: MainHall()