Massive updates to the stormgames library.

This commit is contained in:
Storm Dragon 2019-11-30 18:31:23 -05:00
parent 4db7cfeb9e
commit 911b37085e
3 changed files with 27 additions and 29 deletions

5
files/instructions.txt Normal file
View File

@ -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.

View File

@ -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)

View File

@ -1,7 +1,7 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from storm_games import *
from libstorm_games import *
# Initial variable settings
mode = "menu"