Exemplo n.º 1
0
    def __init__(self):
        Activity.__init__(self)
        self.settings = Settings.Instance()

        self.results = {}
        self.history = []
        self.reset()

        #Defines the positions that the box can appear in each slide
        #self.positions = {i+1: (self.corner_radius + 100*(i % 3), self.corner_radius + 100*(int(i/3)))
        #                  for i in range(9)}

        self.positions = {
            1: (100, 100),
            2: (300, 100),
            3: (500, 100),
            4: (100, 300),
            5: (300, 300),
            6: (500, 300),
            7: (100, 500),
            8: (300, 500),
            9: (500, 500),
        }

        self.normalFont = pygame.font.Font("fonts/freesansbold.ttf", 20)
        self.smallFont = pygame.font.Font("fonts/freesansbold.ttf", 15)
        self.cellFont = pygame.font.Font("fonts/freesansbold.ttf", 70)

        self.show_answer = False
        self.triggered_loc = False
        self.triggered_sound = False
Exemplo n.º 2
0
def main():
    settings = Settings.Instance()

    pygame.init()
    if settings.android:
        settings.android = True
        android.init()
        android.map_key(android.KEYCODE_SEARCH, pygame.K_ESCAPE)

    nback = NBack()
    pygame.display.set_caption('N-Back v' + settings.version)
    nback.run()
Exemplo n.º 3
0
    def __init__(self):
        self.clock = pygame.time.Clock()

        self.settings = Settings.Instance()

        #Sets Window Size
        if self.settings.fullscreen:
            self.screen = pygame.display.set_mode(self.settings.windowSize,
                                                  pygame.FULLSCREEN, 32)
        else:
            self.screen = pygame.display.set_mode(self.settings.windowSize, 0,
                                                  32)

        #standalone is True if One wants to skip the menu
        self.drawMenu = True if not self.settings.standalone else False
        self.drawGame = False if not self.settings.standalone else True
        self.drawResults = False

        self.compiledPosResults = {
            "correct": 0,
            "avoid": 0,
            "miss": 0,
            "wrong": 0
        }
        self.compiledSoundResults = {
            "correct": 0,
            "avoid": 0,
            "miss": 0,
            "wrong": 0
        }

        self.menu = UI.activities.Menu()
        self.grid1 = UI.activities.Game1()
        self.grid2 = UI.activities.Game2()
        self.grid3 = UI.activities.Game3()

        self.gridArray = [self.grid1, self.grid2, self.grid3]

        self.curGridIndex = 0
        self.game = self.grid1

        self.board_position = {1: [80, 80], 2: [40, 30], 3: [120, 120]}
        self.currentTotalSlidesElapsed = 0
        self.switchAddOn = 0
        self.warmup_slides = 3
        self.thresholdSwitchGame = 0.5
Exemplo n.º 4
0
    def __init__(self):
        Activity.__init__(self)
        self.settings = Settings.Instance()

        self.results = {}
        self.history = []
        self.reset()

        self.positions = {i+1: (self.corner_radius + 100*(i % 3),
                                self.corner_radius + 100*(int(i/3)))
                          for i in range(9)}

        self.normalFont = pygame.font.Font("fonts/freesansbold.ttf", 20)
        self.smallFont = pygame.font.Font("fonts/freesansbold.ttf", 15)
        self.cellFont = pygame.font.Font("fonts/freesansbold.ttf", 70)
        
        self.show_answer = False
        self.triggered = False
Exemplo n.º 5
0
    def __init__(self):
        self.clock = pygame.time.Clock()

        self.settings = Settings.Instance()

        if self.settings.fullscreen:
            self.screen = pygame.display.set_mode(self.settings.windowSize,
                                                  pygame.FULLSCREEN, 32)
        else:
            self.screen = pygame.display.set_mode(self.settings.windowSize, 0,
                                                  32)

        self.drawMenu = True if not self.settings.standalone else False
        self.drawGame = False if not self.settings.standalone else True
        self.drawResults = False

        self.menu = UI.activities.Menu()
        self.game = UI.activities.Game()
Exemplo n.º 6
0
 def __init__(self):
     Activity.__init__(self)
     self.version = Settings.Instance().version
     
     self.titleFont = pygame.font.Font("fonts/freesansbold.ttf", 50)
     self.menuFont = pygame.font.Font("fonts/freesansbold.ttf", 20)
     self.smallFont = pygame.font.Font("fonts/freesansbold.ttf", 15)
     
     if self.android:
         newgameKey = "Search"
         triggerKey = "Touch"
     else:
         newgameKey = "Escape"
         triggerKey = "Space"
     
     titleText = self.titleFont.render("Welcome to N-Back!", True, (255,255,0))
     titleVersion = self.smallFont.render("Version " + self.version, True, (255,255,0))
     self.title = pygame.Surface((650,200)).convert()
     self.title.blit(titleText, (self.title.get_width()/2-titleText.get_width()/2, self.title.get_height()/2-titleText.get_height()/2))
     self.title.blit(titleVersion, (self.title.get_width()/2-titleVersion.get_width()/2, (self.title.get_height()/2-titleVersion.get_height()/2)+40))
     
     self.controlsBox = widgets.TextBox("Controls\n  New Game - {0}\n  Trigger N-Back - {1}".format(newgameKey, triggerKey), self.menuFont, (270,100), color=(0,0,50), textColor=(255,255,0), radius=10)
Exemplo n.º 7
0
 def __init__(self):
     settings = Settings.Instance()
     self.surface = pygame.Surface(settings.windowSize).convert()
     self.windowSize = settings.windowSize
     self.android = settings.android
Exemplo n.º 8
0
                    self.game.trigger_loc()

                elif event.key == K_a:
                    try:
                        self.game.trigger_sound()
                    except:
                        pass

                #If menu starts at startup
                elif not self.settings.standalone:
                    if event.key == K_ESCAPE:
                        self.drawMenu = False
                        self.drawGame = True
                        self.game.start()
                    elif event.key == K_F1:
                        self.drawResults = not self.drawResults
                        if self.drawResults:
                            self.results = UI.activities.Results(
                                self.game.results)

            elif event.type == USEREVENT + 1:
                self.game.showSlideSwitch()
                #print("Correct: {correct}\nWrong: {wrong}\nAvoided: {avoid}\nMissed: {miss}".format(**self.compiledPosResults))


settings = Settings.Instance()
pygame.init()
nback = NBack()
pygame.display.set_caption('N-Back')
nback.run()