예제 #1
0
파일: main.py 프로젝트: peipeihan2020/SSVEP
def main():
    pygame.init()
    # fenetre = pygame.display.set_mode((width, height), pygame.FULLSCREEN)
    fenetre = pygame.display.set_mode((width, height), pygame.RESIZABLE)
    fenetre.fill(BLACK)
    x, y = get_start()
    player_position = (x + 32, y + 32)
    end_rect, player = maze.build_game(player_position, x, y)
    maze.draw(fenetre, end_rect, player)
    # time in millisecond from start program
    current_time = pygame.time.get_ticks()

    # how long to show or hide

    delay = st.get_system_refresh_period()
    move_delay = 7000

    # time of next change
    change_time = current_time + delay
    j = 0
    th = mv.save_data()
    maze.draw(fenetre, end_rect, player)
    win = False

    while not win:
        for event in pygame.event.get():
            if event.type == pygame.QUIT or (event.type == pygame.KEYDOWN
                                             and event.key == pygame.K_ESCAPE):
                pygame.quit()
                sys.exit()

        win = maze.update(fenetre, end_rect)
        current_time = pygame.time.get_ticks()
        if current_time >= change_time:
            change_time = current_time + delay
            st.draw_stimuli(j, fenetre)
            j += 1
        if win:
            mv.stop(th)
            win_message(fenetre)
예제 #2
0
mainurl = config['CONNECTION']['mainurl']
height = int(config['MAZE']['height'])
width = int(config['MAZE']['width'])
ponyname = config['PONY']['ponyname']
difficulty = int(config['MAZE']['difficulty'])

mazeconnection = conn.connectionPony(height, width, ponyname, difficulty,
                                     mainurl)

maze_id = mazeconnection.new()
#maze_id=json.loads(NewMaze(15,15,'Pinkie Pie').text)['maze_id']
#maze=mazeconnectio.get()
maze_json = mazeconnection.get()
maze = maze.game(maze_json)
maze.shortest_path(maze.endpoint)
for i in range(0, maze.pony):
    maze.makeMovePony()
    direction = conn.MoveDirection(maze.pony_old, maze.pony, maze.size[0])

    mazeconnection.move(direction)  #make move send move to connection

    maze.update(mazeconnection.get())
    print(direction)
    maze.printmaze()
    print(maze.game_state)
    if maze.cells[maze.pony] == 0:
        break
    if maze.game_state['state'] != 'active':
        break
예제 #3
0
def update():
    maze.update()