1 # utility functions for the game
5 # function to draw text on surface
6 def put_text (surface
, x
, y
, size
, (r
,g
,b
), text
):
7 harisfont
= os
.path
.join ("font", "HarisComic-2.ttf")
8 textsurf
= pygame
.font
.Font (harisfont
, size
).render (text
, True, pygame
.Color (r
,g
,b
))
9 surface
.blit (textsurf
, (x
, y
))
13 # function to ask a question and return answer
14 def ask_question (surface
, question
, answers
):
15 pygame
.draw
.rect (surface
, pygame
.Color (255, 255, 128), pygame
.Rect (40, 40, 480-40, 480-40))
17 put_text (surface
, 60, 60, 22, (0, 0, 192), question
)
20 for answer
in answers
:
21 put_text (surface
, 60, i
*20+60, 22, (0, 0, 128), "%d" % i
)
22 put_text (surface
, 80, i
*20+60, 22, (0, 0, 0), answer
)
25 for event
in pygame
.event
.get ():
26 if event
.type == pygame
.QUIT
:
28 elif event
.type == pygame
.KEYDOWN
: