Esempio n. 1
0
for i in range(sidesNum):
    sideBools[i] = True
start_trial(stimWidth, sideBools)

# game loop
running = True
while running:
    for event in pg.event.get():
        PgTools.quit_pg(event)
        if event.type == PgTools.input_mode:
            xCoord, yCoord = event.pos
            if PgTools.touchscreen:
                if screen.fg.get_at((xCoord, yCoord)) != (0, 0, 0):
                    on_bg = False
            if check_stim(xCoord, yCoord) and not on_bg:
                PgTools.response(screen, True, passDelay)
                on_bg = True
                PgTools.write_ln(
                    filename="Sides_Task/results.csv",
                    data=[
                        subjectName,
                        trialNum,
                        sidesNum,
                    ],
                )
            else:
                #pg.event.clear()
                continue
            trialNum += 1
            passedTrials += 1
            if passedTrials == consecutiveAmt:
totalTrial = 1
if randShapes:
    posSeed = randint(0, 99999)
    negSeed = randint(0, 99999)

start_trial(stimLength, stimHeight, colorPair)

# game loop
running = True
while running:
    for event in pg.event.get():
        PgTools.quit_pg(event)
        if event.type == MOUSEBUTTONDOWN:
            xCoord, yCoord = event.pos
            if posStim.collidepoint(xCoord, yCoord) and screen.fg.get_at((xCoord, yCoord)) != (0,0,0):
                PgTools.response(screen, True, passDelay)
                PgTools.write_ln(
                    filename="Two_Choice_Discrimination/results.csv",
                    data=[
                        subjectName,
                        setNum,
                        trialNum,
                        totalTrial,
                        "\"" + str(colorPair[0]) + "\"",
                        "\"" + str(colorPair[1]) + "\"",
                        "\"" + str((xCoord, yCoord)) + "\"",
                        "passed",
                    ],
                )
                passedTrials += 1
            elif negStim.collidepoint(xCoord, yCoord) and screen.fg.get_at((xCoord, yCoord)) != (0,0,0):