Newer
Older
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
131
132
133
134
135
136
137
138
139
140
141
'''Class defining the screens'''
import pygame #library is used for drawing
class Screens:
'''this class contains the implementation of all screens'''
def __init__(self):
self.name = 'NoName'
#defining the size of the screen
self.width = 1000
self.height = 800
self.screen_size = (1000, 800)
#defining the background color
self.backgroundcolor = (255, 255, 255)
#x -- the x-coordinate of the center of the text block
#y -- the y-coordinate of the center of the text block
#size -- the size of the font (in points)
#color -- color of the text (RGB)
#screen -- the screen on which to draw
def text(self, x, y, size, text, color, screen):
'''this function is used to draw a block of text'''
font = pygame.font.Font(None, size)
text = font.render(text, True, color, self.backgroundcolor)
text_rectangle = text.get_rect()
text_rectangle.center = (x, y)
screen.blit(text, text_rectangle)
#parnr -- participant number
#screen -- the screen on which to draw
def screen_welcome(self, parnr, screen):
'''function draws the welcome screen'''
#redrawing the screen
screen.fill((255,255,255))
parnr_text = "Your participant number is: " + str(parnr)
#here the function is actually used, followed by a screen update
self.text(500, 200, 80, "Welcome", (0, 0, 0,), screen)
self.text(500, 250, 40, "to the Corsi Block-Tapping Test!", (0, 0, 0), screen)
self.text(500, 350, 40, parnr_text, (0, 0, 0), screen)
self.text(500, 580, 40, "Press SPACE to continue", (0, 0, 0), screen)
pygame.display.flip() #updates the display
#screen -- the screen on which to draw
def screen_description(self, screen):
'''function draws the screen with description'''
#redrawing the screen
screen.fill((255,255,255))
#executing the functions that draw the text
self.text(500, 200, 40, "In the test, you will see multiple blocks.", (0, 0, 0,), screen)
self.text(500, 250, 40, "These blocks will light up gray in succession.", (0, 0, 0,), screen)
self.text(500, 300, 40, "Afterwards, they turn black again.", (0, 0, 0,), screen)
self.text(500, 350, 40, "When they do, tap the blocks in the same sequence.", (0, 0, 0,), screen)
self.text(500, 580, 40, "Press SPACE to continue", (0, 0, 0,), screen)
pygame.display.flip() #updates the display
#screen -- the screen on which to draw
def screen_rules(self, screen):
'''function draws the screen with rules of use'''
#redrawing the screen
screen.fill((255,255,255))
#executing the functions that draw the text
self.text(500, 200, 40, "There will be 4 trials.", (0, 0, 0,), screen)
self.text(500, 250, 40, "After each test, you will be shown your results.", (0, 0, 0,), screen)
self.text(500, 300, 40, "You will see an intermediate screen between each trial.", (0, 0, 0,), screen)
self.text(500, 350, 40, "After all 4 tests, you will be shown your total results.", (0, 0, 0,), screen)
self.text(500, 420, 40, "Please do not tap blocks that have been tapped already.", (0, 0, 0,), screen)
self.text(500, 470, 40, "Do not start clicking blocks before all blocks have turned black.", (0, 0, 0,), screen)
self.text(500, 580, 40, "Press SPACE to start the task.", (0, 0, 0,), screen)
pygame.display.flip() #updates the display
#testnr -- the number of the tests that are already finished
#time -- time spent by the participant on the test
#correctseq -- number of blocks repeated correctly from the beginning
#errornr -- number of errors made in repeating the sequence
#screen -- the screen on which to draw
def screen_intermediate(self, testnr, time, correctseq, errornr, screen):
'''function draws the screen with intermediate results'''
#redrawing the screen
screen.fill((255,255,255))
#variables for converting parameters into text
testnr_text = "This was test: " + str(testnr)
time_text = "Time spent: " + str(time)
correctseq_text = "Number of correct blocks from the beginning: " + str(correctseq)
errornr_text = "Number of errors made: " + str(errornr)
#executing the functions that draw the text
self.text(500, 200, 80, "Intermediate results", (0, 0, 0,), screen)
self.text(500, 300, 40, testnr_text, (0, 0, 0,), screen)
self.text(500, 350, 40, time_text, (0, 0, 0,), screen)
self.text(500, 400, 40, correctseq_text, (0, 0, 0,), screen)
self.text(500, 450, 40, errornr_text, (0, 0, 0,), screen)
self.text(500, 580, 40, "Press SPACE to start the next trial.", (0, 0, 0,), screen)
pygame.display.flip() #updates the display
#time1 -- time spent on sequence 1
#time2 -- time spent on sequence 2
#time3 -- time spent on sequence 3
#time4 -- time spent on sequence 4
#correctseqmax -- the maximum length of the correct sequence
#finalscore -- final score of the participant
#screen -- the screen on which to draw
def screen_final(self, time1, time2, time3, time4, correctseqmax, finalscore, screen):
'''draws the final screen, summarizing all the results'''
#redrawing the screen
screen.fill((255,255,255))
#variables for converting parameters into text
time_text1 = "Your time on trial 1: " + str(time1) + " seconds"
time_text2 = "Your time on trial 2: " + str(time2) + " seconds"
time_text3 = "Your time on trial 3: " + str(time3) + " seconds"
time_text4 = "Your time on trial 4: " + str(time4) + " seconds"
correctseq_text = "Maximum of correct blocks from the start: " + str(correctseqmax)
finalscore_text = "Your final score is: " + str(finalscore)
#executing the functions that draw the text
self.text(500, 180, 80, "Final results", (0, 0, 0,), screen)
self.text(500, 250, 40, time_text1, (0, 0, 0,), screen)
self.text(500, 300, 40, time_text2, (0, 0, 0,), screen)
self.text(500, 350, 40, time_text3, (0, 0, 0,), screen)
self.text(500, 400, 40, time_text4, (0, 0, 0,), screen)
self.text(500, 450, 40, correctseq_text, (0, 0, 0,), screen)
self.text(500, 500, 40, finalscore_text, (0, 0, 0,), screen)
self.text(500, 580, 40, "Press SPACE to continue.", (0, 0, 0,), screen)
pygame.display.flip() #updates the display
#screen -- the screen on which to draw
def screen_goodbye(self, screen):
'''draws the final screen, summarizing all the results'''
#redrawing the screen
screen.fill((255,255,255))
#executing the functions that draw the text
self.text(500, 200, 80, "Thank you for participating!", (0, 0, 0,), screen)
self.text(500, 350, 40, "Press SPACE to send your results to the researcher.", (0, 0, 0,), screen)
self.text(500, 400, 40, "Have a nice day!", (0, 0, 0,), screen)
pygame.display.flip() #updates the display