void initializeGraphics() { //Build Pop Up Menu BuildPopupMenu(); glutAttachMenu (GLUT_RIGHT_BUTTON); //inittextures for(int i=0;i<MAXTEXTURES;i++) textures[i]=0; // disable Lighting glDisable( GL_LIGHTING ); glClearColor (0.0f, 0.0f, 0.0f, 0.0f); glEnable( GL_DEPTH_TEST ); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glGetFloatv( GL_MODELVIEW_MATRIX, modelViewMatrix ); // save MY copy in modelViewMatrix glPixelStorei(GL_UNPACK_ALIGNMENT, 1); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glEnable(GL_TEXTURE_2D); glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); //Load Textures textures[SIRENID] = loadtextures(sirenFile, 52,45); textures[VEHICLEID] = loadtextures(vehicleFile, 207,177); textures[WALLID] = loadtextures(wallFile, 512,512); textures[FLOORID] = loadtextures(floorFile, 512,512); textures[CARROTID] = loadtextures(carrotFile, 52,45); textures[BUTTONID] = loadtextures(buttonFile, 52,45); textures[PARTICLEID]=textures[VEHICLEID]; textures[PONDID] = loadtextures(marbleFile,225,225); textures[WATERID] = loadtextures(waterFile,393,385); //snow drifts snowcave.resetPoints(snowCavePoints); snowcave.setBoundingBoxes(driftBuffer); snowcave2.resetPoints(snowCavePoints2); // snowcave2.setBoundingBox(-50,-27, //min max X // -50,-30, //min max Y // -50,10); //min max z snowcave2.setBoundingBoxes(driftBuffer); //snowman snowman = Snowman(snowmanOrigin, SNOWMANID, snowmanSize, textures[FLOORID], textures[CARROTID], textures[BUTTONID]); snowman2 = Snowman(snowmanOrigin2, SNOWMANID, snowmanSize, textures[FLOORID], textures[CARROTID], textures[BUTTONID]); snowman3 = Snowman(snowmanOrigin3, SNOWMANID, snowmanSize, textures[FLOORID], textures[CARROTID], textures[BUTTONID]); //Pond pond = Pond(pondOrigin,PONDID,pondRadius,pondHeight); pond.setSpaceDimensions(Point(10,10,10)); pond.setBoundingBox(pondOrigin.x-10,pondOrigin.x+10,-50,pondOrigin.y+5,pondOrigin.z-10,pondOrigin.z+10); //Gifts gifts[0] = Gift(giftOrigin1,GIFT1ID,giftSize); gifts[1] = Gift(giftOrigin2,GIFT2ID,giftSize); gifts[2] = Gift(giftOrigin3,GIFT3ID,giftSize); gifts[3] = Gift(giftOrigin4,GIFT4ID,giftSize); gifts[4] = Gift(giftOrigin5,GIFT5ID,giftSize); //enemy npc.setSpeed(npcSpeed); npc.setSpaceDimensions(Point(bodyRadius/2,bodyRadius/2,bodyRadius/2)); npc.setThrowRange(20); npc.setInDanger(true); //vehicle vehicle.setDamage(0); vehicle.setMaxDamage(100); vehicle.setIsAlive(true); vehicle.setStrikeRange(30); //init shadow paramteres glEnable(GL_COLOR_MATERIAL); glColorMaterial( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE ); glEnable(GL_DEPTH_TEST); glDepthFunc(GL_LEQUAL); glShadeModel (GL_SMOOTH); glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); //this is defined //bool (*fp_processCollision)(Obstacle); fp_processCollision = &processCollision; //Map Creation assessment currMap.createMap(minCoords, maxCoords, npc, gifts, giftCount, fp_processCollision ); currMap.printState(); //setup the controller controller = PathController(&currMap,&npc,&vehicle); controller.setNextTarget(); //set the target controller.setMaxPath(100); }
int main(int argc, char *argv[]) { Snowman sm = Snowman(); std::string VERSION_STRING = "v" + std::to_string(Snowman::MAJOR_VERSION) + "." + std::to_string(Snowman::MINOR_VERSION) + "." + std::to_string(Snowman::PATCH_VERSION); // parse arguments std::string filename, code; bool parseFlags = true; bool flags[128] = {false}; for (int i = 1; i < argc; ++i) { std::string arg(argv[i]); if (parseFlags && (arg[0] == '-') && (arg.length() > 1)) { arg = arg.substr(1); if (arg.length() >= 1 && arg[0] == '-') { arg = arg.substr(1); // no switch on strings :( if (arg == "") parseFlags = false; else if (arg == "debug") arg = "d"; else if (arg == "evaluate") arg = "e"; else if (arg == "help") arg = "h"; else if (arg == "interactive") arg = "i"; else if (arg == "minify") arg = "m"; else { std::cerr << "Unknown long argument `" << arg << "'" << std::endl; return 1; } } for (char& argid : arg) { switch (argid) { case 'd': sm.debugOutput = true; break; case 'e': flags['e'] = true; if ((++i) == argc) { std::cerr << "Argument `-e' requires a parameter" << std::endl; return 1; } code = argv[i]; break; case 'h': case 'i': case 'm': flags[(int)argid] = true; break; default: std::cerr << "Unknown argument `-" << arg << "'" << std::endl; return 1; } } } else if (filename == "") { filename = arg; } else { // pass as command line argument to Snowman program sm.addArg(arg); } } // retrieve code to run if (!(flags['e'] || flags['h'] || flags['i'])) { if ((filename == "") || (filename == "-")) { std::string line; while (std::getline(std::cin, line) && line != "__END__") { code += line + "\n"; } } else { std::ifstream infile(filename.c_str()); if (infile.good()) { std::stringstream buf; buf << infile.rdbuf() << std::endl; code = buf.str(); } else { std::cerr << "Could not read file " << filename << std::endl; return 1; } } } // process -h (--help) flag if (flags['h']) { std::cout << "Usage: " << argv[0] << " [OPTION]... " "[FILENAME]\n" << "Options:\n" " -d, --debug: include debug output\n" " -e, --evaluate: takes one parameter, runs as Snowman code\n" " -h, --help: display this message\n" " -i, --interactive: start a REPL\n" " -m, --minify: don't evaluate code; output minified version " "instead\n" "Snowman will read from STDIN if you do not specify a file name " "or the -ehi options.\n" "Snowman version: " << VERSION_STRING << "\n"; return 0; } // process -i (--interactive) flag if (flags['i']) { std::cout << "Snowman REPL, " << VERSION_STRING << std::endl; std::cout << ">> "; std::string line; while (std::getline(std::cin, line)) { if (flags['m']) { // minify for (std::string s : Snowman::tokenize(line)) { std::cout << s; } std::cout << std::endl << ">> "; } else { sm.run(line); std::cout << sm.debug(); std::cout << ">> "; } } return 0; } // process -m (--minify) flag if (flags['m']) { for (std::string s : Snowman::tokenize(code)) { std::cout << s; } std::cout << std::endl; return 0; } // run code sm.run(code); }