Tuesday, April 15, 2014

PsyGame

#the scores aren't working. 
#still trying to figure that out
#and then I'll try to make it into a class, instead of a function
 #need to add better instructions
#hold down your a,b,c  answer to see what the computer
#thinks of your answer.



import sys
import pygame
from pygame.locals import*
import math
from random import randint, choice
from math import*
from sys import exit

pygame.init()


              

one_results = {'a': 'so boringly normal.', 'b': 'At least you have an epi-pen. Right?',

                'c': 'Yea, I step on bees all the time.', 'd': 'Raid? Hell no, we got napalm.',

                'e': 'Sure, yell at it as it dies.', 'f': 'What makes you say that?',

                'g': 'Seriously? It is just a bee.'}

two_results = {'a': 'Kicking is fun. Alch-y.', 'b': 'Maybe if you yell explatives she will notice.',

                'c': 'Eh, you can get booze somewhere else.', 'd': 'throwing pine-sol at her might actually work.',

                'e': 'well maybe she can hear you, but the Captain Morgans is not going to fetch itself!',

                'f': 'but louder right?', 'g': 'That is illegal in 30 states.'}

three_results = {'a': 'again with the normal boring stuff!', 'b': 'At least you did not cry... did you?',

                'c': 'I aknowlege your suffering.', 'd': 'Fart in a can is the best for use in closed spaces. Kids love it.',

                'e': 'Did I mention the kids parent is extremely hot?', 'f': 'It was really good coffee after all.',

                'g': 'Uh-huh, and how long have you had these reactions?'}

four_results = {'a': 'It might work, but to what end?', 'b': 'It stuns them into silence. Good job!',

                'c': 'If they follow you, does the tree still fall in the woods?', 'd': 'Bleach... It might just burn thier throte enough...',

                'e': 'There is no try, only do!', 'f': 'Fine, I will kick them for you.', 'g': 'How are you going to get that into thier mouth?'}

five_results = {'a': 'normal is as normal does.', 'b': 'What because it might be something comming to get you?', 'c': 'My faucet leaks too.',

                'd': 'I love the smell of Lysol in the morning!', 'e': 'That does seem like a logical solution.',

                'f': 'Anything in particular, or the first thing that comes near?', 'g': 'Pretty sure you are not supposed to stick those in your ears.'}

six_results = {'a': 'Owww, oww owwy!', 'b': 'Sure, now you are a suspect.', 'c': 'Ninny ninny two by two, nothing left for you to do.',

                'd': 'Satan loves germs!', 'e': 'Oh, ok, but I really think you should explore this.', 'f': 'Are there three more churches near by?',

                'g': 'Hardly, the thing weighs 800 lbs!'}

seven_results = {'a': 'that seems inappropriate.', 'b': 'I think that is probably appropriate, next to wondering WTF.', 'c': 'LSD normal, or everyday normal?',

                'd': 'Might as well, reality is not working for you.', 'e': 'Louder then the growling Ninny-eater sitting over you?',

                'f': 'Yup, let me just write that down.', 'g': 'Cotton candy does sound delicious.'}

eight_results = {'a': 'Gas pedal or brake?', 'b': 'At least if you startle them, they might move.', 'c': 'or drive away...ninny',

                'd': 'Because they are sweaty gross bicyclist?', 'e': 'In a court of law, "I did not see them" will not fly.',

                'f': 'Honk, honk, honk.', 'g': 'So you are saying that you are not angry?'}

nine_results = {'a': 'Do not worry, I will not write that down...(writing quickly)', 'b': 'So more like panic, or dread?', 'c': 'Sure, it all makes sense now.',

                'd': 'Well as long they do not want you to drink it.', 'e': 'If it works, let me know.', 'f': 'Do the voices know what 51-50 means?',

                'g': 'That is very interesting. (run.... run now.)'}

ten_results = {'a': 'Make sure you wash your shoe afterward.', 'b': 'Bless you might have been better.', 'c': 'Good idea. Spread the plague to everyone.',

                'd': 'Splendid response.', 'e': 'You like that word?', 'f': 'Because blood is awesome.', 'g': 'It is for the good of all mankind.'}

eleven_results = {'a': 'Sure, kicking is always my first reaction.', 'b': 'Did I mention the individual is mute?',

                'c': 'Probably best. Ninny.', 'd': 'Especially if they touch you.',

                'e': 'It is ok not to answer.(ninny)', 'f': 'how about we just touch some lamposts and go watch monk?',

                'g': 'Is it legal for you to have that?'} #even responses.

twelve_results = {'a': 'eh, good thing I did not make it longer.', 'b': 'Results are gauranteed to be unprofessional, uneducated guesses. Ninny.',

                'c': 'Been on that couch a lot have you?', 'd': 'Please refrain from huffing until test is complete.', 'e': 'Ok, ok, I heard you.',

                'f': 'awww, it was not that bad.', 'g': 'I give, here are your results.'}  # odd responses.


   



even_choices = {'a': 'kick something/someone',
                'b': 'yell Shut the F--k up',
                'c': 'walk away',
                'd': 'always disinfect. Or run to nearest medical facility.',
                'e': 'no',
                'f': 'maybe if we do it 3 more times.',
                'g': 'other'}











H = 800
W = 800
screen = pygame.display.set_mode((H, W))
s_font = pygame.font.Font(None, 24)
font = pygame.font.Font(None, 32)
L_font = pygame.font.Font(None, 64)   
clock = pygame.time.Clock()
BLUE = (45, 0, 200)
GREEN = (0, 200, 45)
PURPLE = (200, 95, 255)
BLACK = (0, 0, 0)
RED = (255, 0, 20)
WHITE = (240, 240, 255)   
WHITE1 = (200, 240, 255)



          
       
choicea = font.render("a = low anger", False, GREEN)
choiceb = font.render("b = anxiety", False, GREEN)
choicec = font.render("c = nothing,   this is normal", False, GREEN)
choiced = font.render("d = There is a can of gas that needs some using", False, GREEN)
choicee = font.render("e = Be louder,   that always works", False, GREEN)
choicef = font.render("f = just kill", False, GREEN)
choiceg = font.render("g = other", False, GREEN)

choicea2 = font.render("a = kick something/someone", False, GREEN)
choiceb2 = font.render("b = yell Shut the F--k up", False, GREEN)
choicec2 = font.render("c = walk away", False, GREEN)
choiced2 = font.render("d = always disinfect. Or run to nearest medical facility.", False, GREEN)
choicee2 = font.render("e =  'no'", False, GREEN)
choicef2 = font.render("f = maybe if we do it 3 more times.",False, GREEN)
choiceg2 = font.render("g = 'other'", False, GREEN)



def display_box():
    scorea = 0
    scoreb = 0
    scorec = 0
    scored = 0
    scoree = 0
    scoref = 0
    scoreg = 0
    scoreh = 0   
   
    pygame.draw.rect(screen, (200, 195, 100), (20, 20, 760, 760))
    pygame.draw.rect(screen, (BLUE), (30, 30, 740, 740), 10)
    intro = font.render("For instructions, press Space bar", False, BLUE)
    title1 = font.render("For entertainment only", False, GREEN)
    title2 = L_font.render("Personality", False, BLUE)
    title3 = L_font.render("Test", False, BLUE)
    title4 = s_font.render("illegitimate results will vary.",False, BLACK)
    author = font.render("Nellie Tobey, 2014", False, BLACK)
    clock.tick(30)
    instructionNext =font.render("to move on, push enter", False, BLUE)
       
    screen.blit(intro, (40, 40))
    screen.blit(title1, (60, 60))
    screen.blit(title2, (290, 300))
    screen.blit(title3, (340, 340))
    screen.blit(title4, (290, 380))
    screen.blit(author, (40, 640))
    pygame.display.flip()
   
   
   
   
           
    done = False   
   
    next = 0
    next_next = 0
    x = 1
    question_list = [" 1. You have stepped on a bee, and it died stinging you.",
                " 2. An elderly lady is blocking the way at the liquor store",
        " 3. A strangers child has knocked over your morning coffee.",
        " 4. Someone is trying to dramatically tell you a story.",
                " 5. A clicking noise is getting louder as you try to rest.",
                " 6. Someone has defiled a church and placed thier cross upside down.",
                " 7. You have awakened in a field of cotton candy neon blossoms.",
                " 8. The bicyclist in front of you refuses to get off the road even as you honk.",
                " 9. The voices say what?",
                " 10. A woman has sneezed and blood splatters on the floor in front of you.",
                " 11. A mysterious and dangerous looking individual is approaching you rapidly.",
                " 12. Are you tierd of questions?"]

   

    Results = font.render("Your scores. If you score higher then 20 any one catagorie..", False, BLACK)
    Results2 = font.render("... wow. And quit cheating my game!", False, BLACK)

    ResultsA = font.render( "Anger index = %r" % scorea, False, BLUE)

    ResultsB = font.render("Passive aggressive 'or just an angry asshole' index = %r" % scoreb, False, BLUE)

    ResultsC = font.render( "Normal, normal Ninny = %r" % scorec, False, BLUE)

    ResultsD = font.render( "Issues? Nothing prozac can't fix = %r" % scored, False, BLUE)

    ResultsE = font.render("Get your ears checked and/or Narcasism = %r" % scoree, False, BLUE)

    ResultsF = font.render( "OCD or Friggen nuts =  %r" % scoref, False, BLUE)

    ResultsG = font.render("Indecisive and/or Friggen Nuts = %r" % scoreg, False, BLUE)

    ResultsH = font.render( "Bat shit. = %r" % scoreh, False, BLUE)

   
    while done==False:
       
       
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                done = True
                exit()
       
        if next ==0:
            screen.blit(intro, (40, 40))
            screen.blit(title1, (60, 60))
            screen.blit(title2, (290, 300))
            screen.blit(title3, (340, 340))
            screen.blit(author, (40, 640))
            pygame.display.flip()
        keys = pygame.key.get_pressed()
        if (keys[K_SPACE]) and next == 0:
            next = +1
        if next == 1:           
            text = L_font.render("INSTRUCTIONS", False, (0, 35, 0))
            text_1 = font.render("push ENTER to begin your test!", False, (BLACK))

            pygame.draw.rect(screen, (200, 255, 255), (20, 20, 760, 760))
            screen.blit(text, (W/2 - 170, H/2 - 200))
            screen.blit(text_1, (W/2 - 100, H/2 - 150))

            pygame.display.flip()
            if (keys[K_RETURN]) and next ==1:
                next = 2
               
        elif next == 2:
            screen.fill(WHITE)
            pygame.draw.rect(screen, (BLUE), (30, 30, 740, 740), 10)
            question1 = font.render(question_list[0], False, RED)
            screen.blit(question1, (100, 50))
            screen.blit(choicea, (100, 120))
            screen.blit(choiceb, (100, 140))
            screen.blit(choicec, (100, 160))
            screen.blit(choiced, (100, 180))
            screen.blit(choicee, (100, 200))
            screen.blit(choicef, (100, 220))
            screen.blit(choiceg, (100, 240))
           
            instruction = font.render("choose your first response and press SPACE.", False, BLACK)
            screen.blit(instruction, (100, 300))
           
           
           
            pygame.display.flip()
           
       
            answer = ""
            if (keys[K_a]):
                answer = one_results['a']
                scorea = +1
            if (keys[K_b]):
                answer = one_results['b']
               
            if (keys[K_c]):
                answer = one_results['c']
               
            if (keys[K_d]):
                answer = one_results['d']
               
            if (keys[K_e]):
                answer = one_results['e']
               
            if (keys[K_f]):
                answer = one_results['f']
               
            if (keys[K_g]):
                answer = one_results['g']
               

            choices1 = font.render(answer, False, RED)
            screen.blit(choices1, (100, 390))
           
           
           
            if (keys[K_SPACE]) and (next ==2):
                next = 3
           
        elif next == 3:
            screen.fill(WHITE)
            pygame.draw.rect(screen, (BLACK), (30, 30, 740, 740), 10)
            question2 = font.render(question_list[1], False, RED)
            screen.blit(question2, (20, 50))
            screen.blit(choicea2, (100, 120))
            screen.blit(choiceb2, (100, 140))
            screen.blit(choicec2, (100, 160))
            screen.blit(choiced2, (100, 180))
            screen.blit(choicee2, (100, 200))
            screen.blit(choicef2, (100, 220))
            screen.blit(choiceg2, (100, 240))
            instruction = font.render("choose your first response and press ENTER.", False, BLACK)
            screen.blit(instruction, (100, 300))

       
            answer = ""
            if (keys[K_a]):
                answer = two_results['a']
               
            if (keys[K_b]):
                answer = two_results['b']
               
            if (keys[K_c]):
                answer = two_results['c']
               
            if (keys[K_d]):
                answer = two_results['d']
               
            if (keys[K_e]):
                answer = two_results['e']
               
            if (keys[K_f]):
                answer = two_results['f']
               
            if (keys[K_g]):
                answer = two_results['g']
               

            choices1 = font.render(answer, False, RED)
            screen.blit(choices1, (100, 390))
           
            pygame.display.flip()
            if (keys[K_RETURN]) and next ==3:
                next = 4
           
        elif next == 4:
            screen.fill(WHITE)
            pygame.draw.rect(screen, (BLUE), (30, 30, 740, 740), 10)
            question3 = font.render(question_list[2], False, RED)
            screen.blit(question3, (20, 50))
            screen.blit(choicea, (100, 120))
            screen.blit(choiceb, (100, 140))
            screen.blit(choicec, (100, 160))
            screen.blit(choiced, (100, 180))
            screen.blit(choicee, (100, 200))
            screen.blit(choicef, (100, 220))
            screen.blit(choiceg, (100, 240))
            instruction = font.render("choose your first response and press SPACE.", False, BLACK)
            screen.blit(instruction, (100, 300))

       
            answer = ""
            if (keys[K_a]):
                answer = three_results['a']
               
            if (keys[K_b]):
                answer = three_results['b']
               
            if (keys[K_c]):
                answer = three_results['c']
               
            if (keys[K_d]):
                answer = three_results['d']
               
            if (keys[K_e]):
                answer = three_results['e']
               
            if (keys[K_f]):
                answer = three_results['f']
               
            if (keys[K_g]):
                answer = three_results['g']
               

            choices1 = font.render(answer, False, RED)
            screen.blit(choices1, (100, 390))
           
            pygame.display.flip()
            if (keys[K_SPACE]) and next ==4:
                next = 5
       
       
        elif next == 5:
            screen.fill(WHITE)
            pygame.draw.rect(screen, (BLUE), (30, 30, 740, 740), 10)
            question4 = font.render(question_list[3], False, RED)
            screen.blit(question4, (20, 50))
            screen.blit(choicea2, (100, 120))
            screen.blit(choiceb2, (100, 140))
            screen.blit(choicec2, (100, 160))
            screen.blit(choiced2, (100, 180))
            screen.blit(choicee2, (100, 200))
            screen.blit(choicef2, (100, 220))
            screen.blit(choiceg2, (100, 240))
            instruction = font.render("choose your first response and press ENTER.", False, BLACK)
            screen.blit(instruction, (100, 300))
           
            answer = ""
           
            if (keys[K_a]):
                answer = four_results['a']
               
            if (keys[K_b]):
                answer = four_results['b']
               
            if (keys[K_c]):
                answer = four_results['c']
               
            if (keys[K_d]):
                answer = four_results['d']
               
            if (keys[K_e]):
                answer = four_results['e']
               
            if (keys[K_f]):
                answer = four_results['f']
               
            if (keys[K_g]):
                answer = four_results['g']
               

            choices1 = font.render(answer, False, RED)
            screen.blit(choices1, (100, 390))
            if (keys[K_RETURN]) and next ==5:
                next = 6
       
            pygame.display.flip()
       
        elif next == 6:
            screen.fill(WHITE1)
            pygame.draw.rect(screen, (BLUE), (30, 30, 740, 740), 10)
            question5 = font.render(question_list[4], False, RED)
            screen.blit(question5, (20, 50))
            screen.blit(choicea, (100, 120))
            screen.blit(choiceb, (100, 140))
            screen.blit(choicec, (100, 160))
            screen.blit(choiced, (100, 180))
            screen.blit(choicee, (100, 200))
            screen.blit(choicef, (100, 220))
            screen.blit(choiceg, (100, 240))
            instruction = font.render("choose your first response and press SPACE.", False, BLACK)
            screen.blit(instruction, (100, 300))

       
            answer = ""
            if (keys[K_a]):
                answer = five_results['a']
               
            if (keys[K_b]):
                answer = five_results['b']
               
            if (keys[K_c]):
                answer = five_results['c']
               
            if (keys[K_d]):
                answer = five_results['d']
               
            if (keys[K_e]):
                answer = five_results['e']
               
            if (keys[K_f]):
                answer = five_results['f']
               
            if (keys[K_g]):
                answer = five_results['g']
               

            choices1 = font.render(answer, False, RED)
            screen.blit(choices1, (100, 390))
            if (keys[K_SPACE]) and next ==6:
                next = 7
            pygame.display.flip()

       
       
        elif next == 7:
            screen.fill(WHITE1)
            pygame.draw.rect(screen, (BLUE), (30, 30, 740, 740), 10)
            question6 = font.render(question_list[5], False, RED)
            screen.blit(question6, (20, 50))
            screen.blit(choicea2, (100, 120))
            screen.blit(choiceb2, (100, 140))
            screen.blit(choicec2, (100, 160))
            screen.blit(choiced2, (100, 180))
            screen.blit(choicee2, (100, 200))
            screen.blit(choicef2, (100, 220))
            screen.blit(choiceg2, (100, 240))
            instruction = font.render("choose your first response and press ENTER.", False, BLACK)
            screen.blit(instruction, (100, 300))

       
            answer = ""
            if (keys[K_a]):
                answer = six_results['a']
               
            if (keys[K_b]):
                answer = six_results['b']
               
            if (keys[K_c]):
                answer = six_results['c']
               
            if (keys[K_d]):
                answer =six_results['d']
               
            if (keys[K_e]):
                answer = six_results['e']
               
            if (keys[K_f]):
                answer = six_results['f']
               
            if (keys[K_g]):
                answer = six_results['g']
               

            choices1 = font.render(answer, False, RED)
            screen.blit(choices1, (100, 390))
            if (keys[K_RETURN]) and next ==7:
                next = 8
            pygame.display.flip()

           
           
       
        elif next == 8:
           
            screen.fill(WHITE1)
            pygame.draw.rect(screen, (BLUE), (30, 30, 740, 740), 10)
            color = font.render("Did the screen change color?", False, GREEN)
            screen.blit(color, ( 135, 200 ))
            colorblind = font.render("y for yes, n for no", False, GREEN)
            screen.blit(colorblind, (135, 240))
            instruction = font.render("choose your first response and press SPACE.", False, BLACK)
            screen.blit(instruction, (100, 300))
           

            answer = ""
            if (keys[K_y]):
                answer = "you can answer something honestly!"
                choices1 = font.render(answer, False, RED)
                screen.blit(choices1, (100, 390))
            if (keys[K_n]):
                answer = "This is no fun if you aren't paying attention."
                choices2 = font.render(answer, False, RED)
                screen.blit(choices2, (100, 390))
           
           

                scorea = +10
                scoreb = +10
                scorec = +1
                scored = +5
                scoree = +10
                scoref = +2
                scoreg = +5
                scoreh = +1

             
           
            if (keys[K_SPACE]) and next ==8:
                next = 9
           
            pygame.display.flip()

       
        elif next == 9:
       


            screen.fill(WHITE1)
            pygame.draw.rect(screen, (BLUE), (30, 30, 740, 740), 10)

            screen.blit(Results, (100, 180))
            screen.blit(Results2, (100, 210))
            screen.blit(ResultsA, (120, 230))
            screen.blit(ResultsB, (120, 250))
            screen.blit(ResultsC, (120, 270))
            screen.blit(ResultsD, (120, 290))
            screen.blit(ResultsE, (120, 310))
            screen.blit(ResultsF, (120, 330))
            screen.blit(ResultsG, (120, 350))
            screen.blit(ResultsH, (120, 370))
            pygame.display.flip()


display_box()         

           
               

Sunday, April 13, 2014

trying to make it pretty

Working on the personality test again.  Was hoping to improve it to be simpler , easier code, but it doesn't seem to want to only want let the [K_RETURN] occur only once per button press.   Trying to figure out what I'm doing wrong.  Will post it's ugly version soon, and hopefully a pretty version later.