예제 #1
0
/* 成功返回指向S的指针, 失败返回NULL*/
static struct room_info* init_maze(struct room_info* maze, int M, int N, char* maze_data)
{
	int row = 0;
	int col = 0;
	struct room_info* prince = NULL;

	/* 第一遍识别墙等,确定坐标 */
	for (row = 0; row < M; row++)
	{
		for (col = 0; col < N; col++)
		{
			int idx = row * N + col;
			char c = *(maze_data + idx);

			init_room(maze + idx);

			maze[idx].row = row;
			maze[idx].col = col;

			switch (c)
			{
			case '.':
				maze[idx].type = TYPE_ROAD;
				break;
			case '*':
				maze[idx].type = TYPE_WINDOW;
				break;
			case 'S':
				prince = maze + idx;
				maze[idx].type = TYPE_PRINCE;
				break;
			case 'P':
				maze[idx].type = TYPE_PRINCESS;
				break;
			default:
				return NULL;
			}
		}
	}

	/*第二遍建立图*/
	for (row = 0; row < M; row++)
	{
		for (col = 0; col < N; col++)
		{
			int idx = row * N + col;

			maze[idx].child[D_UP]	= get_child(maze, M - 1, N - 1, maze + idx, D_UP);
			maze[idx].child[D_DOWN]	= get_child(maze, M - 1, N - 1, maze + idx, D_DOWN);
			maze[idx].child[D_LEFT]	= get_child(maze, M - 1, N - 1, maze + idx, D_LEFT);
			maze[idx].child[D_RIGHT]= get_child(maze, M - 1, N - 1, maze + idx, D_RIGHT);
		}
	}

	return prince;
}
예제 #2
0
void init(void)
{
	//h_prog = build_program_from_files("shading_Blinn_Phong.vert", "shading_Blinn_Phong.frag");
	h_prog = build_program_from_files("shading_Phong_Phong.vert", "shading_Phong_Phong.frag");
	//h_prog = build_program_from_files("car.vert", "car.frag");

	h_prog_pick = build_program_from_files("picking_color.vert", "picking_color.frag");

	//P = glm::ortho(-2.0f, 2.0f, -2.0f, 2.0f, -50.0f, 50.0f);
	camera.P = glm::perspective(camera.fovy, 1.0f, 0.1f, 40.0f);
	gui.T = glm::translate(glm::mat4(1.0f), glm::vec3(0.0f, 0.0f, -10.0f));

	glEnable(GL_DEPTH_TEST);
	glEnable(GL_MULTISAMPLE);

	//load_scene();
	
	load_bookshelf(glm::vec4(-3.0f,-7.5f,3.0f,0.0f));
	


	Book* b_temp;
	BookIndex be;

	b_temp = load_book(Bookshelf_list[0], "aaa", "bbbb");
	be.x = 1; be.y = 2;
	b_temp->SetMovement(b_temp->ipos, be);

	
	load_bookshelf(glm::vec4(3.0f, -7.5f, -3.0f, 0.0f));


	load_book(Bookshelf_list[1], "aaa", "bbbb");
	load_book(Bookshelf_list[1], "aaa", "bbbb");
	load_book(Bookshelf_list[1], "aaa", "bbbb");
	load_book(Bookshelf_list[1], "aaa", "bbbb");
	load_book(Bookshelf_list[1], "aaa", "bbbb");
	load_book(Bookshelf_list[1], "aaa", "bbbb");
	load_book(Bookshelf_list[1], "aaa", "bbbb");
	load_book(Bookshelf_list[1], "aaa", "bbbb");
	load_book(Bookshelf_list[1], "aaa", "bbbb");
	load_book(Bookshelf_list[1], "aaa", "bbbb");
	load_book(Bookshelf_list[1], "aaa", "bbbb");
	load_book(Bookshelf_list[1], "aaa", "bbbb");


	//load_bookshelf(glm::vec4(0.0f, 1.0f, 4.0f, 0.0f));

	init_room();


}
예제 #3
0
파일: init.c 프로젝트: Mars-Goliath/Lem-in
void	init_lem(t_lem *lem)
{
	lem->colony = -1;
	lem->buffer = NULL;
	lem->nb_rooms = 0;
	lem->phase = 0;
	lem->match = 0;
	lem->start = NULL;
	lem->end = NULL;
	if (!(lem->room = (t_room *)malloc(sizeof(t_room))))
		errors(-2);
	init_room(lem);
}
예제 #4
0
파일: wtower2.c 프로젝트: heypnus/xkx2001
void init()
{
        init_room();
}
예제 #5
0
파일: h2generic.cpp 프로젝트: mmuman/haiku
// implements the POSIX open()
static status_t
device_open(const char* name, uint32 flags, void **cookie)
{
	CALLED();

	status_t err = ENODEV;
	bt_usb_dev* bdev = NULL;
	hci_id hdev;
	int i;

	acquire_sem(dev_table_sem);
	for (i = 0; i < MAX_BT_GENERIC_USB_DEVICES; i++) {
		if (bt_usb_devices[i] && !strcmp(name, bt_usb_devices[i]->name)) {
			bdev = bt_usb_devices[i];
			break;
		}
	}
	release_sem_etc(dev_table_sem, 1, B_DO_NOT_RESCHEDULE);

	if (bdev == NULL) {
		ERROR("%s: Device not found in the open list!", __func__);
		*cookie = NULL;
		return B_ERROR;
	}

	// Set RUNNING
	if (TEST_AND_SET(&bdev->state, RUNNING)) {
		ERROR("%s: dev already running! - reOpened device!\n", __func__);
		return B_ERROR;
	}

	acquire_sem(bdev->lock);
	// TX structures
	for (i = 0; i < BT_DRIVER_TXCOVERAGE; i++) {
		list_init(&bdev->nbuffersTx[i]);
		bdev->nbuffersPendingTx[i] = 0;
	}

	// RX structures
	bdev->eventRx = NULL;
	for (i = 0; i < BT_DRIVER_RXCOVERAGE; i++) {
		bdev->nbufferRx[i] = NULL;
	}

	// dumping the USB frames
	init_room(&bdev->eventRoom);
	init_room(&bdev->aclRoom);
	// init_room(new_bt_dev->scoRoom);

	list_init(&bdev->snetBufferRecycleTrash);

	// Allocate set and register the HCI device
	if (btDevices != NULL) {
		bluetooth_device* ndev;
		// TODO: Fill the transport descriptor
		err = btDevices->RegisterDriver(&bluetooth_hooks, &ndev);

		if (err == B_OK) {
			bdev->hdev = hdev = ndev->index; // Get the index
			bdev->ndev = ndev;  // Get the net_device

		} else {
			hdev = bdev->num; // XXX: Lets try to go on
		}
	} else {
		hdev = bdev->num; // XXX: Lets try to go on
	}

	bdev->hdev = hdev;

	*cookie = bdev;
	release_sem(bdev->lock);

	return B_OK;

}