Exemplo n.º 1
0
void MazeParser::parseTexture(int count, char *line)
{
   char *start, *end;
   char tex_name[MAX_LINE_SIZE];
   char arg[MAX_LINE_SIZE];

   end = findFirstSpace(line);
   copyString(arg, line, end);
   end = skipSpace(end);

   start = skipSpace(end);
   end = findFirstSpace(start);
   copyString(tex_name, start, end);

   scene->addTexture( new Texture(tex_name) );

   return;
}
Exemplo n.º 2
0
void parseTexture(int count, char *line) {
	char *start, *end;
	char tex_name[MAX_LINE_SIZE];
	char arg[MAX_LINE_SIZE];

	end = findFirstSpace(line);
	copyString(arg, line, end);
	end = skipSpace(end);

	tex_codes[count] = atoi(arg);

	start = skipSpace(end);
	end = findFirstSpace(start);
	copyString(tex_name, start, end);

	tex[count] = new Texture(tex_name);

	return;
}
Exemplo n.º 3
0
int getWall(char **line) {
	char arg[3];
	char *start, *end;

	start = skipSpace(*line);
	end = findFirstSpace(start);
	copyString(arg, start, end);
	*line = skipSpace(end);

	return (atoi(arg));
}
Exemplo n.º 4
0
void parseScene(char *line) {
	char command[MAX_LINE_SIZE];
	char arg[MAX_LINE_SIZE];
	char *start, *end;


	/* i need to get the first word */
	end = findFirstSpace(line);

	/* observe what the command is */
	copyString(command, line, end);

	if (!strcmp(command,"DIMENSIONS")) {
		/* parse the dimensions of the scene */
		
		start = skipSpace(end);
		end = findFirstSpace(start);
		copyString(arg, start, end);
		end = skipSpace(end);

		cells_wide = atoi(arg);

		start = skipSpace(end);
		end = findFirstSpace(start);
		copyString(arg, start, end);
		end = skipSpace(end);

		cells_high = atoi(arg);
		assert(lineCanBeIgnored(end));	/* the rest of the line should be able to be ignored */

		fprintf(stderr,"width: %d   height: %d\n", cells_wide, cells_high);
	}
	else if (!strcmp(command,"HEIGHT")) {
		start = skipSpace(end);
		end = findFirstSpace(start);
		copyString(arg, start, end);
		end = skipSpace(end);

		wall_height = atoi(arg);
		fprintf(stderr,"wall height: %d\n", wall_height);
	}
	else if (!strcmp(command,"CELL")) {
		start = skipSpace(end);
		end = findFirstSpace(start);
		copyString(arg, start, end);
		end = skipSpace(end);

		cell_size = atoi(arg);
		fprintf(stderr,"cell size: %d\n", cell_size);
	}
	else if (!strcmp(command,"TEXTURES")) {
		start = skipSpace(end);
		end = findFirstSpace(start);
		copyString(arg, start, end);
		end = skipSpace(end);

		num_tex = atoi(arg);
		fprintf(stderr,"number of textures: %d\n", num_tex);

		loadTextures();
	}
	else if (!strcmp(command,"FLOORPLAN")) {
		assert(lineCanBeIgnored(end));	/* the rest of the line should be able to be ignored */

		loadFloorPlan();
	}
	else {
		fprintf(stderr,"ERROR! Unrecognized command in scene file \n");
		fprintf(stderr,"%s\n", line);
		exit(-1);
	}

	return;
}