WorldMap::WorldMap() : mWorld(0), mSub(0), mLevelCount(0), mSection(0), mCount(0), mNewWorld(false), //fult mWorldMax(3) { readButtons(); mMusic = "Resources/Sound/Music/Title_Screen_"; mSprite.setTexture(*ResourceManager::getInst().getTexture("Resources/Menu/WorldMenu/WorldmapBG.png")); mSprite.setPosition(0,0); readSave(); readWorld(); updateWorld(); readAnimals(); LevelManager::getInst().setDeadAnimalCollection(mDeadAnimalVector); mCurrentWorld = mWorld; mCurrentSection = mSection; mFactButton = new FactButton(sf::Vector2f(20,20), "addAnimalipedia", "Resources/Menu/AchievementMenu/faktaknapp.png", "Resources/Sound/Menu/Menu_forward.wav"); mCutscenes.push_back("Resources/Data/Cutscenes/Cutscene_2.xml"); mCutscenes.push_back("Resources/Data/Cutscenes/Cutscene_3.xml"); mCutscenes.push_back("Resources/Data/Cutscenes/Cutscene_ending.xml"); }
//============================================================================== simulation::WorldPtr readWorld( const common::Uri& fileUri, const common::ResourceRetrieverPtr& nullOrRetriever) { const auto retriever = getRetriever(nullOrRetriever); //-------------------------------------------------------------------------- // Load xml and create Document tinyxml2::XMLDocument _dartFile; try { openXMLFile(_dartFile, fileUri, retriever); } catch(std::exception const& e) { dtwarn << "[SdfParser::readSdfFile] Loading file [" << fileUri.toString() << "] failed: " << e.what() << "\n"; return nullptr; } //-------------------------------------------------------------------------- // Load DART tinyxml2::XMLElement* sdfElement = nullptr; sdfElement = _dartFile.FirstChildElement("sdf"); if (sdfElement == nullptr) return nullptr; //-------------------------------------------------------------------------- // version attribute std::string version = getAttributeString(sdfElement, "version"); // TODO: We need version aware SDF parser (see #264) // We support 1.4 only for now. if (version != "1.4" && version != "1.5") { dtwarn << "[SdfParser::readSdfFile] The file format of [" << fileUri.toString() << "] was found to be [" << version << "], but we only support SDF " << "1.4 and 1.5!\n"; return nullptr; } //-------------------------------------------------------------------------- // Load World tinyxml2::XMLElement* worldElement = nullptr; worldElement = sdfElement->FirstChildElement("world"); if (worldElement == nullptr) return nullptr; std::string fileName = fileUri.getFilesystemPath(); // Uri's path is unix-style path std::string skelPath = fileName.substr(0, fileName.rfind("/") + 1); return readWorld(worldElement, skelPath, retriever); }
int main (int argc, char ** argv) { if (argc<2) { printf ("Oops! You didn't say the jello world file!\n"); printf ("Usage: %s [worldfile]\n", argv[0]); exit(0); } readWorld(argv[1],&jello); glutInit(&argc,argv); /* double buffered window, use depth testing, 640x480 */ glutInitDisplayMode (GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH); windowWidth = 640; windowHeight = 480; glutInitWindowSize (windowWidth, windowHeight); glutInitWindowPosition (0,0); glutCreateWindow ("Jello cube"); /* tells glut to use a particular display function to redraw */ glutDisplayFunc(display); /* replace with any animate code */ glutIdleFunc(doIdle); /* callback for mouse drags */ glutMotionFunc(mouseMotionDrag); /* callback for window size changes */ glutReshapeFunc(reshape); /* callback for mouse movement */ glutPassiveMotionFunc(mouseMotion); /* callback for mouse button changes */ glutMouseFunc(mouseButton); /* register for keyboard events */ glutKeyboardFunc(keyboardFunc); /* do initialization */ myinit(); /* forever sink in the black hole */ glutMainLoop(); return(0); }
//============================================================================== simulation::WorldPtr readSdfFile( const common::Uri& fileUri, const common::ResourceRetrieverPtr& retriever) { return readWorld(fileUri, retriever); }
int main(int argc, char* args[]) { //Please Read Note above at top. char line, ch; char **CurrentWorld; int position; int maxTicks, rows, columns, i, j; int SCREEN_WIDTH, SCREEN_HEIGHT, rectH, rectW, noRect; //Read textfile CurrentWorld = readWorld(&rows, &columns, &maxTicks); //SCREEN_WIDTH = 600; //SCREEN_HEIGHT = 600; //the window must be calculated by the number of rows and columns //whilst having some spcae as a buffer ///It must also be divisible by 10 ie be a whole number //buffer of 5 will be filled by a border set of squares SCREEN_WIDTH = (columns + (columns%10)+1)*10; SCREEN_HEIGHT = (rows + (rows%10)+1)*10; //work our rectangle dimensions //noRect = columns*rows; rectW = columns; rectH = rows; //SDL World Primitives SDL_Rect Rect; SDL_Surface* screen; SDL_Event event; Uint32 flags = SDL_SWSURFACE|SDL_FULLSCREEN; //Start SDL SDL_Init( SDL_INIT_EVERYTHING ); screen = SDL_SetVideoMode( SCREEN_WIDTH, SCREEN_HEIGHT, 32, SDL_SWSURFACE ); //This will not draw directly to the sceen. You must call flip to actually see the results of the drawing SDL_FillRect(screen,&Rect,SDL_MapRGB(screen->format,255,255,255)); //Call this to write a caption to screen SDL_WM_SetCaption ("Stable world!", NULL); //You must have this or SDL will crash whenever user input is detected SDL_PollEvent (&event); //To ensure that the quit box at the top of your window works switch (event.type) { case SDL_QUIT: exit(0); //case } //3d array to hold all worlds char ***CompleteWorld = (char***)malloc(maxTicks*sizeof(char(**)));; //initialise and allocate the second part of the array ie number of columns per row for(i = 1; i < maxTicks; i++) { CompleteWorld[i] = (char**) malloc(rows*sizeof(char*)); for(j=0; j<rows; j++) { CompleteWorld[i][j] = (char*) malloc(columns*sizeof(char)); } } //add to first entry of CompleteWorld CompleteWorld[0] = CurrentWorld; //display the movie ShowMovie(CompleteWorld, maxTicks, rows, columns, screen, &Rect, rectH, rectW); //free memory for(i = 0; i < maxTicks; i++) { free(CompleteWorld[i]); for(j=0; j<rows; j++) { free(CompleteWorld[i][j]); } } SDL_Quit(); return 0; }