Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Generated by OpenSesame 0.27 (Frisky Freud)
- # Wed Jan 30 11:58:44 2013 (posix)
- # <http://www.cogsci.nl/opensesame>
- set foreground "white"
- set subject_parity "even"
- set font_size "18"
- set description "Default description"
- set title "New experiment"
- set font_bold "no"
- set compensation "0"
- set coordinates "relative"
- set height "768"
- set mouse_backend "xpyriment"
- set width "1024"
- set sampler_backend "legacy"
- set font_family "mono"
- set keyboard_backend "legacy"
- set background "black"
- set subject_nr "0"
- set canvas_backend "xpyriment"
- set start "experiment"
- set synth_backend "legacy"
- set font_italic "no"
- define sequence sequence
- run inline_script "always"
- run sketchpad "always"
- define sketchpad sketchpad
- set duration "1000"
- set description "Displays stimuli"
- draw textline 32.0 -128.0 "accepted" center=1 color=white font_family="mono" font_size=18 font_italic=no font_bold=no show_if="always"
- define sequence experiment
- run loop "always"
- define inline_script inline_script
- ___run__
- # Keep pulling mouse responses until the participant
- # clicked in the area of interest:
- # Make sure the cursor appears at the center of the screen:
- # See also: http://www.pygame.org/docs/ref/mouse.html#pygame.mouse.set_pos
- # Determine center coordinates:
- xCen = exp.width/2
- yCen = exp.height/2
- import pygame
- pygame.mouse.set_visible(True)
- pygame.mouse.set_pos((xCen,yCen))
- self.sleep(100)
- while True:
- # get_click() returns a button, position, timestamp tuple:
- # See also: http://osdoc.cogsci.nl/python-inline-code/mouse-functions/#mouse.get_click
- my_mouse.flush()
- button, pos, timestamp = my_mouse.get_click()
- # pos contains an (x,y) tuple:
- x, y = pos
- # If both the x and the y coordinates fell within
- # the area, break out of the while loop:
- if (x > xMin and x < xMax) and (y > yMin and y < yMax) :
- break
- __end__
- ___prepare__
- # Initialize a mouse object:
- # See also: http://osdoc.cogsci.nl/python-inline-code/mouse-functions/#mouse.__init__
- from openexp.mouse import mouse
- global my_mouse
- my_mouse = mouse(exp, visible = True)
- # In this example the area of interest is a rectangle and
- # is determined relative to the resolution of the screen (and not in
- # absolute values). You can change the minima and maxima
- # to your specific situation.
- # Determine the center of the screen by using the
- # built-in variables width and height:
- global xCen, yCen
- xCen = exp.width/2
- yCen = exp.height/2
- global xMin, xMax, yMin, yMax
- xMin = xCen-exp.width/4
- xMax = xCen+exp.width/4
- yMin = yCen-exp.width/4
- yMax = yCen+exp.width/4
- # To visually check whether you defined the
- # area of interest correctly you could use a canvas object
- # (simply remove or deactivate this piece of code if you don't need
- # it any more).
- # Initialize a canvas object:
- # See also: http://osdoc.cogsci.nl/python-inline-code/canvas-functions/#canvas.__init__
- from openexp.canvas import canvas
- global my_canvas
- my_canvas = canvas(exp)
- # determine the width and height of the area of interest:
- w = xMax - xMin
- h = yMax - yMin
- # rect() draws a rectangle on the canvas:
- # See also: http://osdoc.cogsci.nl/python-inline-code/canvas-functions/#canvas.rect
- my_canvas.rect(xMin, yMin, w, h)
- my_canvas.show()
- #self.sleep(2000)
- __end__
- set description "Executes Python code"
- define loop loop
- set repeat "1"
- set description "Repeatedly runs another item"
- set skip "0"
- set offset "no"
- set item "sequence"
- set column_order ""
- set cycles "10"
- set order "random"
- run sequence
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement