Skip to content

Commit

Permalink
Added intertrial. Added maze type choice with GUI
Browse files Browse the repository at this point in the history
.
  • Loading branch information
alfredoivan committed Sep 19, 2014
1 parent dac44b3 commit bed4e8f
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 4 deletions.
54 changes: 50 additions & 4 deletions labyrinth_par/src/main_hexag.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
import sys
import os
from rect_cl import Rectangle # @UnresolvedImport
from Tkinter import *
from matplotlib.rcsetup import all_backends

gvars = vars_tmaze.vars_tmaze() #variables del juego a ser accedidas "globalmente"

Expand All @@ -25,6 +27,8 @@
IMG_GREEN_FRACTAL = 17 #index..
LEFT_RECTANGLE = Rectangle(0,8,0,4)
RIGHT_RECTANGLE = Rectangle(0,8,19,999)
ALL_WINDOW = Rect(0,0,1024,768)
INTERTRIAL_FRAMES_DELAY = 165

vectorInstantaneo = vectorSimple.vectorSimple() #vector con el instantáneo de movimiento, x e y dependen del estado de joystick.

Expand All @@ -36,23 +40,31 @@ def __init__(self):
import Tkinter
import tkMessageBox


top = Tkinter.Tk()

def hexCallBack():
tkMessageBox.showinfo( "Selection:", "Hexagon selected")
gvars.lab_type = "hexag"
print e1.get()
gvars.subject_name = e1.get()
top.destroy()

def tmCallBack():
tkMessageBox.showinfo( "Selection:", "T-Maze selected")
gvars.lab_type = "tmaze"
print e1.get()
gvars.subject_name = e1.get()
top.destroy()

B = Tkinter.Button(top, text ="Hexagon", command = hexCallBack)
C = Tkinter.Button(top, text ="T-Maze", command = tmCallBack)

e1 = Entry(top)

B.pack()
C.pack()
e1.pack()
top.mainloop()

if (gvars.lab_type == "hexag"):
Expand Down Expand Up @@ -121,9 +133,12 @@ def mainFunction():

labyrinth_training.keyboardInput()

labyrinth_training.drawInterTrial()

labyrinth_training.evalWhiteSquare()



##########################
#pygame.display.update()
##########################
Expand Down Expand Up @@ -213,8 +228,8 @@ def init_worldmap_hexag():
#####################################
#inicializo log y declaro el archivo.
#####################################
subject_name = str(raw_input("Ingrese nombre de sujeto: "))
gvars.set_log_file(subject_name)
#subject_name = str(raw_input("Ingrese nombre de sujeto: "))
gvars.set_log_file(gvars.subject_name)
from time import strftime, localtime
cad_temp = strftime("%Y%m%d", localtime())
#cad_temp = strftime("%Y%m%d %H_%M_%S", localtime())
Expand Down Expand Up @@ -326,8 +341,8 @@ def init_worldmap_tmaze():
#####################################
#inicializo log y declaro el archivo.
#####################################
subject_name = str(raw_input("Ingrese nombre de sujeto: "))
gvars.set_log_file(subject_name)
#subject_name = str(raw_input("Ingrese nombre de sujeto: "))
gvars.set_log_file(gvars.subject_name)
from time import strftime, localtime
cad_temp = strftime("%Y%m%d", localtime())
#cad_temp = strftime("%Y%m%d %H_%M_%S", localtime())
Expand Down Expand Up @@ -583,6 +598,8 @@ def evalHexagWin():
#reincio de experimento
#############################################
#log_to_file("Reinicio de experimento.")
print "reinicio de experimento"
gvars.drawInterTrial = INTERTRIAL_FRAMES_DELAY;
gvars.set_door_anim (0)
# Restablecer valores de puerta cerrada, no haría falta en sprite_positions
for i in range(0, len(gvars.sprite_positions)):
Expand Down Expand Up @@ -674,6 +691,7 @@ def tmazeWLAnimations():
#log_to_file("Reinicio de experimento.")
gvars.set_delay_reboot_button(1)
gvars.set_init_whitebox(0) #para que en breve ponga la luz blanca.
gvars.drawInterTrial = INTERTRIAL_FRAMES_DELAY;
gvars.set_user_won(False)
gvars.set_experiment_ended(False)
gvars.set_lights_on ( False )
Expand Down Expand Up @@ -812,6 +830,8 @@ def evalWhiteSquare():
def keyboardInput():
if (gvars.strobe_value == 1):
return;
if (gvars.drawInterTrial > 0):
return;
#=======================================================================
# # Entradas de Teclado.
#=======================================================================
Expand Down Expand Up @@ -868,6 +888,8 @@ def keyboardInput():

@staticmethod
def joystickInput():
if (gvars.drawInterTrial > 0):
return;
if (gvars.strobe_value == 1):
return;
############################################
Expand Down Expand Up @@ -995,8 +1017,12 @@ def initPygame():
#size = w, h = 1600,900
gvars.size = gvars.width_screen, gvars.height_screen = 1366,768

global ALL_WINDOW
ALL_WINDOW = Rect(0,0,1366,768)

#window = pygame.display.set_mode(size)
pygame.display.set_mode(gvars.size, pygame.FULLSCREEN)
#pygame.display.set_mode(gvars.size, pygame.RESIZABLE)


gvars.screen = pygame.display.get_surface()
Expand All @@ -1014,6 +1040,26 @@ def drawScoreBar():
pygame.draw.rect(gvars.screen, (0,0,255), (50,gvars.height_screen/2-gvars.get_player_score(),15,gvars.get_player_score()+1), 0)
pass

@staticmethod
def drawInterTrial():
if (gvars.drawInterTrial == INTERTRIAL_FRAMES_DELAY):
#print "strobe start"
gvars.set_init_whitebox(0)
if (gvars.drawInterTrial == 1):
#print "strobe end"
gvars.set_init_whitebox(0)

if (gvars.drawInterTrial > 0):
#pygame.draw.rect(gvars.screen, pygame.color.Color., Rect, width=0)
#print "drawing intertrial: %d" %gvars.drawInterTrial
pygame.draw.rect(gvars.screen, Color('black'), ALL_WINDOW)
#pygame.draw.circle(gvars.screen, Color('white'), (gvars.width_screen / 2, gvars.height_screen/2), 10, width=10)
pygame.draw.circle(gvars.screen, Color('white'), (gvars.width_screen / 2, gvars.height_screen/2), 10, 0)
#pygame.draw.rect(gvars.screen, Color('black'), ALL_WINDOW)
gvars.drawInterTrial-= 1

pass

@staticmethod
def log_frame():
#=======================================================================
Expand Down
2 changes: 2 additions & 0 deletions labyrinth_par/src/vars_tmaze.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ class vars_tmaze:

lab_type = "tmaze" #hexag or tmaze
joystick_working = False #true if it is working..
subject_name = ""
drawInterTrial=0;

def __init__(self):
self.__anim_count = 0 #variable que indica el fotograma de la animación de fin de experimento.
Expand Down

0 comments on commit bed4e8f

Please sign in to comment.