Hi All,
I am working on a project for school. Notice that I am a liberal arts major. My project is to develop a multiple choice test. I decided it would be a cool time to teach myself how to program so people could take the test on the computer. I didn't have to do it that way, I could have used anything like survey monkey, etc. but I wanted to learn it. That was dumb but I got pretty far and I really want to finish.
Anyways my code is below I have questions on two parts:
im trying to create a start screen below I have copies over some code so thats why there is quit functions and what not.
If you could point me in the right direction in creating a start page that would be great.- i'm also looking to put the answers into a list how would the -if statments- look if i were to give an answer based on how many a's were chosen or b's, c's or d's
Both questions can also be found as comments below in the location I am working. Thanks for any help. I graduate soon and I promise to give you the best french fries ever when you come into my place of employment after I get my history degree...
#!/usr/bin/env python ''' __Apr04_EX1.py__ = "TAT PROGRAM" __author__ = "Jim" __email__ = "removed" __copyright__ = "Copyright 2012, Spring '12" __python version__ = "2.7.2" __last updated__ = "april 10, 2012" open in cmd ''' #-----import modules----- import sys, pygame, time, random #-----global variables----- pygame.init() window_size = 800, 533 window = pygame.display.set_mode((window_size)) pygame.mouse.set_visible(1) #(1=true or 0=false) Mouse click answer pygame.display.set_caption('Thematic Apperception Test') #-----function definitions----- def font(): basicFont = pygame.font.SysFont(None, 50) questionFont = pygame.font.SysFont(None, 30) startcolor = (255,255,255) questioncolor = (50,55,25) text = basicFont.render('Thematic Apperception Test', True, startcolor) text2 = questionFont.render("1) Who are these people?", True, questioncolor) text3 = questionFont.render("A Husband and wife", True, questioncolor) text4 = questionFont.render("A businessman and his mistress", True, questioncolor) text5 = questionFont.render("A murderer and his victim", True, questioncolor) text6 = questionFont.render("A doctor and his patient", True, questioncolor) text7 = questionFont.render("I don't know", True, questioncolor) text2_2 = questionFont.render("2) What are they feeling?", True, questioncolor) text3_2 = questionFont.render("Happy and/or tired", True, questioncolor) text4_2 = questionFont.render("Incomplete and/or unhappy", True, questioncolor) text5_2 = questionFont.render("Sad and/or lost", True, questioncolor) text6_2 = questionFont.render("Accomplished and/or healthy", True, questioncolor) text7_2 = questionFont.render("I don't know", True, questioncolor) text2_3 = questionFont.render("3) What are they thinking?", True, questioncolor) text3_3 = questionFont.render("What they are doing tomorrow", True, questioncolor) text4_3 = questionFont.render("how they cant wait to meet again", True, questioncolor) text5_3 = questionFont.render("how to cover up a mistake", True, questioncolor) text6_3 = questionFont.render("how to fix a problem", True, questioncolor) text7_3 = questionFont.render("I don't know", True, questioncolor) text2_4 = questionFont.render("4) What are they hoping for?", True, questioncolor) text3_4 = questionFont.render("To have a nice day", True, questioncolor) text4_4 = questionFont.render("To stop living a lie", True, questioncolor) text5_4 = questionFont.render("That this will be covered up", True, questioncolor) text6_4 = questionFont.render("That it was successful", True, questioncolor) text7_4 = questionFont.render("I don't know", True, questioncolor) text2_5 = questionFont.render("5) What led to this situation?", True, questioncolor) text3_5 = questionFont.render("A willing vacation", True, questioncolor) text4_5 = questionFont.render("An urge to run away", True, questioncolor) text5_5 = questionFont.render("A hateful relationship", True, questioncolor) text6_5 = questionFont.render("A call for help", True, questioncolor) text7_5 = questionFont.render("I don't know", True, questioncolor) text2_6 = questionFont.render("6) What's the outcome?", True, questioncolor) text3_6 = questionFont.render("They return back home", True, questioncolor) text4_6 = questionFont.render("Split up and move on", True, questioncolor) text5_6 = questionFont.render("Panic and run", True, questioncolor) text6_6 = questionFont.render("A new start", True, questioncolor) text7_6 = questionFont.render("I don't know", True, questioncolor) return [ text, text2, text3, text4, text5, text6, text7, text2_2, text3_2, text4_2, text5_2, text6_2, text7_2, text2_3, text3_3, text4_3, text5_3, text6_3, text7_3, text2_4, text3_4, text4_4, text5_4, text6_4, text7_4, text2_5, text3_5, text4_5, text5_5, text6_5, text7_5, text2_6, text3_6, text4_6, text5_6, text6_6, text7_6 ] def startpage(): background = pygame.Rect(0,0,800,533) startimage = pygame.image.load('background.gif') return [startimage, background] def background(): background = pygame.Rect(0,0,800,533) image = pygame.image.load('TAT_1.jpg') return [image, background] def button(): button_a = pygame.image.load('a_Button.png') button_b = pygame.image.load('b_Button.png') button_c = pygame.image.load('c_Button.png') button_d = pygame.image.load('d_Button.png') button_e = pygame.image.load('e_Button.png') rec_a = pygame.Rect(435,180,20,20) rec_b = pygame.Rect(435,220,20,20) rec_c = pygame.Rect(435,260,20,20) rec_d = pygame.Rect(435,300,20,20) rec_e = pygame.Rect(435,340,20,20) return [button_a, button_b, button_c, button_d, button_e,rec_a,rec_b,rec_c,rec_d,rec_e] def isPointInsideRect(x, y, rect): if (x > rect.left) and (x < rect.right) and (y > rect.top) and (y < rect.bottom): return True else: return False #create a button for each answer #-----main body----- text = font() back = background() press = button() start = startpage() #-----draw objects on screen----- answers = [] mouse =False startscreen =False game =True screen =False ##???????????## I'm trying to create a start screen below ##??????????## I have copies over some code so thats why there is quit functions and what not. ##??????????## If you could point me in the right direction in creating a start page that would be great. ''' while True: if startscreen==True: pass elif game==True: for event in pygame.event.get(): if (event.type == pygame.QUIT) or (event.type==pygame.KEYDOWN and event.key==pygame.K_ENTER): sys.exit() elif (event.type == pygame.MOUSEBUTTONDOWN and event.button == 1): position = pygame.mouse.get_pos() mouse = True if len(answers)<=0: window.fill((0,0,0)) window.blit(start[0], start[1]) ##use in start and end screen (change button value)f t for event in pygame.event.get(): if (event.type == pygame.QUIT) or (event.type==pygame.KEYDOWN and event.key==pygame.K_ESCAPE): sys.exit() elif (event.type == pygame.MOUSEBUTTONDOWN and event.button == 1): position = pygame.mouse.get_pos() mouse = True ''' if mouse == True and isPointInsideRect(position[0], position[1], press[5]): answers.append("A") mouse = False elif mouse == True and isPointInsideRect(position[0], position[1], press[6]): answers.append("B") mouse = False elif mouse == True and isPointInsideRect(position[0], position[1], press[7]): answers.append("C") mouse = False elif mouse == True and isPointInsideRect(position[0], position[1], press[8]): answers.append("D") mouse = False elif mouse == True and isPointInsideRect(position[0], position[1], press[9]): answers.append("E") mouse = False if len(answers)<=0: window.fill((0,0,0)) window.blit(back[0], back[1]) #buttons window.blit(press[0], press[5]) window.blit(press[1], press[6]) window.blit(press[2], press[7]) window.blit(press[3], press[8]) window.blit(press[4], press[9]) #title window.blit(text[0], (180,25)) #Question window.blit(text[1], (440,150)) #answers below window.blit(text[2], (460,180)) window.blit(text[3], (460,220)) window.blit(text[4], (460,260)) window.blit(text[5], (460,300)) window.blit(text[6], (460,340)) elif len(answers)==1: window.fill((0,0,0)) window.blit(back[0], back[1]) #buttons window.blit(press[0], press[5]) window.blit(press[1], press[6]) window.blit(press[2], press[7]) window.blit(press[3], press[8]) window.blit(press[4], press[9]) #title window.blit(text[0], (180,25)) #Question window.blit(text[7], (440,150)) #answers below window.blit(text[8], (460,180)) window.blit(text[9], (460,220)) window.blit(text[10], (460,260)) window.blit(text[11], (460,300)) window.blit(text[12], (460,340)) elif len(answers)==2: window.fill((0,0,0)) window.blit(back[0], back[1]) #buttons window.blit(press[0], press[5]) window.blit(press[1], press[6]) window.blit(press[2], press[7]) window.blit(press[3], press[8]) window.blit(press[4], press[9]) #title window.blit(text[0], (180,25)) #Question window.blit(text[13], (440,150)) #answers below window.blit(text[14], (460,180)) window.blit(text[15], (460,220)) window.blit(text[16], (460,260)) window.blit(text[17], (460,300)) window.blit(text[18], (460,340)) elif len(answers)==3: window.fill((0,0,0)) window.blit(back[0], back[1]) #buttons window.blit(press[0], press[5]) window.blit(press[1], press[6]) window.blit(press[2], press[7]) window.blit(press[3], press[8]) window.blit(press[4], press[9]) #title window.blit(text[0], (180,25)) #Question window.blit(text[19], (440,150)) #answers below window.blit(text[20], (460,180)) window.blit(text[21], (460,220)) window.blit(text[22], (460,260)) window.blit(text[23], (460,300)) window.blit(text[24], (460,340)) elif len(answers)==4: window.fill((0,0,0)) window.blit(back[0], back[1]) #buttons window.blit(press[0], press[5]) window.blit(press[1], press[6]) window.blit(press[2], press[7]) window.blit(press[3], press[8]) window.blit(press[4], press[9]) #title window.blit(text[0], (180,25)) #Question window.blit(text[25], (440,150)) #answers below window.blit(text[26], (460,180)) window.blit(text[27], (460,220)) window.blit(text[28], (460,260)) window.blit(text[29], (460,300)) window.blit(text[30], (460,340)) elif len(answers)==5: window.fill((0,0,0)) window.blit(back[0], back[1]) #buttons window.blit(press[0], press[5]) window.blit(press[1], press[6]) window.blit(press[2], press[7]) window.blit(press[3], press[8]) window.blit(press[4], press[9]) #title window.blit(text[0], (180,25)) #Question window.blit(text[31], (440,150)) #answers below window.blit(text[32], (460,180)) window.blit(text[33], (460,220)) window.blit(text[34], (460,260)) window.blit(text[35], (460,300)) window.blit(text[36], (460,340)) elif len(answers)==6: finalanswers = answers.list print finalanswers pygame.quit() ###????????????????########--i'm also looking to put the answers into a list ##??????????##-------- how would the -if statments- look if i were to give an answer based on how many a's were chosen #--- or b's,c's,d's pygame.display.flip() elif screen == True: pass #-------END-------