From 911b37085e023b84ac1855a081ca5b1627b48423 Mon Sep 17 00:00:00 2001 From: Storm Dragon Date: Sat, 30 Nov 2019 18:31:23 -0500 Subject: [PATCH] Massive updates to the stormgames library. --- files/instructions.txt | 5 +++ storm_games.py => libstorm_games.py | 49 +++++++++++++---------------- numnastics | 2 +- 3 files changed, 27 insertions(+), 29 deletions(-) create mode 100644 files/instructions.txt rename storm_games.py => libstorm_games.py (71%) diff --git a/files/instructions.txt b/files/instructions.txt new file mode 100644 index 0000000..8e2da99 --- /dev/null +++ b/files/instructions.txt @@ -0,0 +1,5 @@ +You are given a scrambled list of numbers from 1 to 9. Press the number you want to flip from, and that number, plus all the numbers to the right of it will reverse. +you can also navigate by using the up, down, left, and right arrows. When you are on the number you want, press enter and the flip will take place. +the object of the game is to get the numbers in the right order, from 1 through 9. +1 2 3 4 5 6 7 8 9 +in as few tries as possible, as quickly as you can. diff --git a/storm_games.py b/libstorm_games.py similarity index 71% rename from storm_games.py rename to libstorm_games.py index 7354705..deaf0e5 100755 --- a/storm_games.py +++ b/libstorm_games.py @@ -90,43 +90,36 @@ def display_message(info): time.sleep(0.001) def instructions(): - info = ( - "Welcome to " + gameName + ": brought to you by Storm Dragon. Use the up and down arrows to navigate these instructions.",\ - "The object of the game is to arrange the random string of numbers so they read one through nine in as few tries as possible.",\ - "You can use the up or left arrow to move back in the string, and the down or right arrow to move forward, or close to the end of the string of numbers.",\ - "you can also jump directly to the number you want by pressing it on your keyboard. If you want to go to the number 8 in the string, just press 8.",\ - "When you are on the number you want, press the enter key and that number, plus all the numbers to the end of the string, will be reversed.",\ - "For example, if you have the string of numbers 1 2 3 4 5 6 9 8 7, pressing enter while on the number 9 will reverse 9 8 7, making the string 1 2 3 4 5 6 7 8 9 and you will win the game.",\ - "If you need to her the string of numbers from your current position, press the spacebar.",\ - "Have fun, and good luck!",\ - "Press escape or enter to return to the game menu.") - i = 0 - speak(info[i]) - while True: - event = pygame.event.wait() - if event.type == pygame.KEYDOWN: - if event.key == pygame.K_ESCAPE or event.key == pygame.K_RETURN: return - if event.key == pygame.K_DOWN and i < len(info) - 1: i = i + 1 - if event.key == pygame.K_UP and i > 0: i = i - 1 - speak(info[i]) - event = pygame.event.clear() - time.sleep(0.001) - + # Read in the instructions file + try: + with open('files/instructions.txt', 'r') as f: + info = f.readlines() + except: + info = ["Instructions file is missing."] + display_text(info) + def credits(): - info = ( + info = [ gameName + ": brought to you by Storm Dragon",\ "Billy Wolfe, designer and coder.",\ - "https://social.wolfe.casa/storm",\ - "Press escape or enter to return to the game menu.") + "https://social.wolfe.casa/storm"] + display_text(info) + +def display_text(text): i = 0 - speak(info[i]) + text.insert(0, "Press space to read the whole text. Use up and down arrows to navigate the text line by line. Press enter or escape when you are done reading.") + text.append("End of text.") + speak(text[i]) while True: event = pygame.event.wait() if event.type == pygame.KEYDOWN: if event.key == pygame.K_ESCAPE or event.key == pygame.K_RETURN: return - if event.key == pygame.K_DOWN and i < len(info) - 1: i = i + 1 + if event.key == pygame.K_DOWN and i < len(text) - 1: i = i + 1 if event.key == pygame.K_UP and i > 0: i = i - 1 - speak(info[i]) + if event.key == pygame.K_SPACE: + speak(''.join(text[1:])) + else: + speak(text[i]) event = pygame.event.clear() time.sleep(0.001) diff --git a/numnastics b/numnastics index 5f80dfb..ff0ae07 100755 --- a/numnastics +++ b/numnastics @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- -from storm_games import * +from libstorm_games import * # Initial variable settings mode = "menu"