annotated_code.md 2.1 KB

Main

Main function keeps track of the game position and oscillates between calling noninteractive.py and interaction.py with these positions as arguments.

def main():
    position = [...]

A position in this program is determined as any point where the program is outputting data without that isn't a response to user input.

"Positions" are treated as checkpoints, and described with words describing the topic of dialogue rather than numbers.

for i in range(0, len(position)):
    noninteractive.output(position[i])
    interaction.dialogue(position[i])

Cycles through the list of all possible positions, calling noninteractive and then interaction in every loop.

Interaction

def processIn(prompt, orderedOptions) Takes in an input prompt and possible options, prompts for input with given prompt until answer matches an option. Returns the index of the list of the option chose by the user.

def dialogue(position):
    if position == "start": #Uses conditionals to determine position
        print_slow.print_slow("Ok... A mirror. Wait no, don't look at that!") #Uses print_slow.py to output dialogue, simulating typing
        orderedOptions = ["comfort", "ignore", "demean"] #Sets possible options of user response
        tmp = processIn("Options: Comfort, Ignore, or Demean: ", orderedOptions) #Prompts for user response using processIn
        response(orderedOptions, tmp) #Uses response() to respond to user input appropriately.

This is the core of the program and determines how interactions take place. response() is just a simple program that finds the appropriate responses (hard-coded) based on the position and the response number (tmp).

NonInteractive

This program only has one function, def output(position), and it takes the position to print appropriate hard-coded noninteractive responses.

PrintSlow()

PrintSlow.PrintSlow() Takes in a string, prints it out character by character, with a 0.05ms delay for each character. After the string is complete, a newline character is printed. The return value is always 0.