forked from SohamKukreti/omilia
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHindiQuestion.py
132 lines (116 loc) · 3.75 KB
/
HindiQuestion.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
import pygame
import sys
import random
def prompt(level):
# initialize Pygame
pygame.init()
if level == 0:
gamestate = "prof"
else:
gamestate = "play"
# set the window size
window_size = (1000, 1000)
# create the window
window = pygame.display.set_mode(window_size)
# set the font
textfont=pygame.font.Font("hindi/img/CompassPro.ttf",32)
text = '''Marty, Try to guess what the word!'''
images = ["hindi/img/hindiImg/q1h.png","hindi/img/hindiImg/q2h.png","hindi/img/hindiImg/q3h.png","hindi/img/hindiImg/q4h.png","hindi/img/hindiImg/q5h.png","hindi/img/hindiImg/q6h.png","hindi/img/hindiImg/q7h.png","hindi/img/hindiImg/q8h.png","hindi/img/hindiImg/q9h.png","hindi/img/hindiImg/q10h.png","hindi/img/hindiImg/q11h.png","hindi/img/hindiImg/q12h.png","hindi/img/hindiImg/q13h.png","hindi/img/hindiImg/q14h.png","hindi/img/hindiImg/q15h.png","hindi/img/hindiImg/q16h.png","hindi/img/hindiImg/q17h.png","hindi/img/hindiImg/q18h.png","hindi/img/hindiImg/q19h.png","hindi/img/hindiImg/q20h.png"]
ansKey = [1,4,4,2,3,2,1,4,1,3,1,2,1,3,2,3,3,1,3,1]
n = random.randint(0,19)
ques_img = pygame.image.load(images[n])
selectedAns = -1
print(ansKey[n])
optionSound = pygame.mixer.Sound("hindi/img/optionsound.mp3")
correctSound = pygame.mixer.Sound("hindi/img/rightans.mp3")
wrongSound = pygame.mixer.Sound("hindi/img/wrongans.wav")
pygame.mixer.music.load("hindi/img/questionbg.wav")
pygame.mixer.music.play(-1)
#creating the buttons
button1 = pygame.Rect(100, 255, 290, 300)
button2 = pygame.Rect(610, 255, 290, 300)
button3 = pygame.Rect(100, 625, 290, 300)
button4 = pygame.Rect(610, 635, 290, 300)
profimg = pygame.image.load("hindi/img/profslide.png")
# main game loop
running = True
while running:
mx, my = pygame.mouse.get_pos()
click = False
# handle events
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
sys.exit()
if event.type == pygame.MOUSEBUTTONDOWN:
if event.button == 1:
click = True
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_ESCAPE:
running = False
if event.key == pygame.K_RETURN:
if gamestate == "prof":
gamestate = "play"
# clear the screen
window.fill((255, 255, 255))
if gamestate == "prof" and level == 0:
window.blit(profimg,(0,0))
proftext=textfont.render(text,True,(255,255,255))
window.blit(proftext, (550, 600))
if gamestate == "play":
window.blit(ques_img,(0,0))
#window.blit(appleimg,(150,35))
#pygame.draw.rect(window, (255, 255, 255), button1)
#pygame.draw.rect(window, (255, 255, 255), button2)
#pygame.draw.rect(window, (255, 255, 255), button3)
#pygame.draw.rect(window, (255, 255, 255), button4)
if button1.collidepoint((mx, my)):
if click:
optionSound.play()
print("button1")
selectedAns = 1
if selectedAns == ansKey[n]:
correctSound.play()
print("successful")
return 1
else:
wrongSound.play()
return -1
if button2.collidepoint((mx, my)):
if click:
optionSound.play()
print("button2")
selectedAns = 2
if selectedAns == ansKey[n]:
correctSound.play()
print("successful")
return 1
else:
wrongSound.play()
return -1
if button3.collidepoint((mx, my)):
if click:
optionSound.play()
print("button3")
selectedAns = 3
if selectedAns == ansKey[n]:
correctSound.play()
print("successful")
return 1
else:
wrongSound.play()
return -1
if button4.collidepoint((mx, my)):
if click:
optionSound.play()
print("button4")
selectedAns = 4
if selectedAns == ansKey[n]:
correctSound.play()
print("successful")
return 1
else:
wrongSound.play()
return -1
# update the screen
pygame.display.update()