void MapCopier::copy( MapBuilder& builder, MapComponent* component, MapVertexAttribute<int>& vertex_id, MapTexVertexAttribute<int>& tex_vertex_id, int& cur_vertex_id, int& cur_tex_vertex_id ) { bind_attribute_copiers(builder.target(), component->map()) ; // Step 1 : clear vertex and tex vertex ids FOR_EACH_VERTEX(MapComponent, component, it) { vertex_id[it] = -1 ; } FOR_EACH_HALFEDGE(MapComponent, component, it) { tex_vertex_id[it->tex_vertex()] = -1 ; } // Step 2: enumerate vertices FOR_EACH_VERTEX(MapComponent, component, it) { vertex_id[it] = cur_vertex_id ; builder.add_vertex(it->point()) ; copy_vertex_attributes(builder.current_vertex(), it) ; cur_vertex_id++ ; }
int main(int argc, char *argv[]) { MapBuilder MB; MB.convert(); system("PAUSE"); return EXIT_SUCCESS; }
int main (void) { //save_state.print_table(); if(1) { iGraph.CreateMainWindow (SCREEN_WIDTH, SCREEN_HEIGHT, "A Lust for Power"); iGraph.SetKeyboardInput(KeyboardInput); iGraph.SetBackgroundColor (26,32,40); load_images(); iGraph.SetMainLoop(main_loop); iGraph.StartMainLoop(); }; map_builder.delete_list(); halt(); return 0; };
int main(int argc, char * argv[]) { ULogger::setType(ULogger::kTypeConsole); ULogger::setLevel(ULogger::kWarning); // GUI stuff, there the handler will receive RtabmapEvent and construct the map QApplication app(argc, argv); MapBuilder mapBuilder; // Here is the pipeline that we will use: // CameraOpenni -> "CameraEvent" -> OdometryThread -> "OdometryEvent" -> RtabmapThread -> "RtabmapEvent" // Create the OpenNI camera, it will send a CameraEvent at the rate specified. // Set transform to camera so z is up, y is left and x going forward CameraOpenni camera("", 10, rtabmap::Transform(0,0,1,0, -1,0,0,0, 0,-1,0,0)); if(!camera.init()) { UERROR("Camera init failed!"); exit(1); } // Create an odometry thread to process camera events, it will send OdometryEvent. OdometryThread odomThread(new OdometryBOW(0)); // 0=SURF 1=SIFT // Create RTAB-Map to process OdometryEvent Rtabmap * rtabmap = new Rtabmap(); rtabmap->init(); RtabmapThread rtabmapThread(rtabmap); // ownership is transfered // Setup handlers odomThread.registerToEventsManager(); rtabmapThread.registerToEventsManager(); mapBuilder.registerToEventsManager(); // The RTAB-Map is subscribed by default to CameraEvent, but we want // RTAB-Map to process OdometryEvent instead, ignoring the CameraEvent. // We can do that by creating a "pipe" between the camera and odometry, then // only the odometry will receive CameraEvent from that camera. RTAB-Map is // also subscribed to OdometryEvent by default, so no need to create a pipe between // odometry and RTAB-Map. UEventsManager::createPipe(&camera, &odomThread, "CameraEvent"); // Let's start the threads rtabmapThread.start(); odomThread.start(); camera.start(); mapBuilder.show(); app.exec(); // main loop // remove handlers mapBuilder.unregisterFromEventsManager(); rtabmapThread.unregisterFromEventsManager(); odomThread.unregisterFromEventsManager(); // Kill all threads camera.kill(); odomThread.join(true); rtabmapThread.join(true); return 0; }
int main(int argc, char * argv[]) { ULogger::setType(ULogger::kTypeConsole); ULogger::setLevel(ULogger::kError); if(argc < 8) { showUsage(); } int argIndex = 1; int cameraRate = atoi(argv[argIndex++]); if(cameraRate <= 0) { printf("camera_rate should be > 0\n"); showUsage(); } int odomUpdate = atoi(argv[argIndex++]); if(odomUpdate <= 0) { printf("odom_update should be > 0\n"); showUsage(); } int mapUpdate = atoi(argv[argIndex++]); if(mapUpdate <= 0) { printf("map_update should be > 0\n"); showUsage(); } printf("Camera rate = %d Hz\n", cameraRate); printf("Odometry update rate = %d Hz\n", cameraRate/odomUpdate); printf("Map update rate = %d Hz\n", (cameraRate/odomUpdate)/mapUpdate); std::string calibrationDir = argv[argIndex++]; std::string calibrationName = argv[argIndex++]; std::string pathLeftImages = argv[argIndex++]; std::string pathRightImages = argv[argIndex++]; Transform opticalRotation(0,0,1,0, -1,0,0,0, 0,-1,0,0); CameraStereoImages camera( pathLeftImages, pathRightImages, false, // assume that images are already rectified (float)cameraRate, opticalRotation); if(camera.init(calibrationDir, calibrationName)) { OdometryF2M odom; Rtabmap rtabmap; rtabmap.init(); QApplication app(argc, argv); MapBuilder mapBuilder; mapBuilder.show(); QApplication::processEvents(); SensorData data = camera.takeImage(); int cameraIteration = 0; int odometryIteration = 0; printf("Press \"Space\" in the window to pause\n"); while(data.isValid() && mapBuilder.isVisible()) { if(cameraIteration++ % odomUpdate == 0) { OdometryInfo info; Transform pose = odom.process(data, &info); if(odometryIteration++ % mapUpdate == 0) { if(rtabmap.process(data, pose)) { mapBuilder.processStatistics(rtabmap.getStatistics()); if(rtabmap.getLoopClosureId() > 0) { printf("Loop closure detected!\n"); } } } mapBuilder.processOdometry(data, pose, info); } QApplication::processEvents(); while(mapBuilder.isPaused() && mapBuilder.isVisible()) { uSleep(100); QApplication::processEvents(); } data = camera.takeImage(); } if(mapBuilder.isVisible()) { printf("Processed all frames\n"); app.exec(); } } else { UERROR("Camera init failed!"); } return 0; }
int main(int argc, char * argv[]) { ULogger::setType(ULogger::kTypeConsole); ULogger::setLevel(ULogger::kWarning); ParametersMap pm = Parameters::parseArguments(argc, argv); pm.insert(ParametersPair(Parameters::kRtabmapWorkingDirectory(), ".")); int argIndex = 1; int cameraRate = atoi(argv[argIndex++]); if(cameraRate <= 0) { printf("camera_rate should be > 0\n"); showUsage(); } int odomUpdate = atoi(argv[argIndex++]); if(odomUpdate <= 0) { printf("odom_update should be > 0\n"); showUsage(); } int mapUpdate = atoi(argv[argIndex++]); if(mapUpdate <= 0) { printf("map_update should be > 0\n"); showUsage(); } printf("Camera rate = %d Hz\n", cameraRate); printf("Odometry update rate = %d Hz\n", cameraRate/odomUpdate); printf("Map update rate = %d Hz\n", (cameraRate/odomUpdate)/mapUpdate); std::string calibrationDir = argv[argIndex++]; std::string calibrationName = argv[argIndex++]; std::string pathRGBImages = argv[argIndex++]; std::string pathDepthImages = argv[argIndex++]; Transform opticalRotation(0,0,1,0, -1,0,0,0, 0,-1,0,0); //CameraStereoImages camera( // pathLeftImages, // pathRightImages, // false, // assume that images are already rectified // (float)cameraRate, // opticalRotation); // CameraFreenect2 camera(0, CameraFreenect2::Type::kTypeColor2DepthSD, 0.0, opticalRotation); CameraRGBDImages camera(pathRGBImages, pathDepthImages, 1, float(cameraRate), opticalRotation); std::ofstream stats_file; stats_file.open("statistics.txt"); stats_file << "[" << std::endl; if(camera.init(calibrationDir, calibrationName)) { OdometryF2M odom; Rtabmap rtabmap; rtabmap.init(pm); QApplication app(argc, argv); MapBuilder mapBuilder; mapBuilder.show(); QApplication::processEvents(); SensorData data = camera.takeImage(); int cameraIteration = 0; int odometryIteration = 0; printf("Press \"Space\" in the window to pause\n"); while(data.isValid() && mapBuilder.isVisible()) { if(cameraIteration++ % odomUpdate == 0) { OdometryInfo info; Transform pose = odom.process(data, &info); if(odometryIteration++ % mapUpdate == 0) { if(rtabmap.process(data, pose)) { mapBuilder.processStatistics(rtabmap.getStatistics()); if(rtabmap.getLoopClosureId() > 0) { printf("Loop closure detected!\n"); } std::map<std::string, float> statz = rtabmap.getStatistics().data(); stats_file << " {" << std::endl; for(std::map<std::string,float>::iterator it = statz.begin(); it != statz.end(); ++it) { std::string name = it->first; std::replace(name.begin(), name.end(), '/', '.'); stats_file << " \"" << name << "\": " << it->second << "," << std::endl; } stats_file << " }," << std::endl; } } mapBuilder.processOdometry(data, pose, info); } QApplication::processEvents(); while(mapBuilder.isPaused() && mapBuilder.isVisible()) { uSleep(100); QApplication::processEvents(); } data = camera.takeImage(); } if(mapBuilder.isVisible()) { printf("Processed all frames\n"); app.exec(); } } else { UERROR("Camera init failed!"); } stats_file << "]" << std::endl; stats_file.close(); return 0; }
int main(int argc, char *argv[]) { //Change le random (marche pas) //srand(time(NULL)); // Initialisation de la SDL SDL_Init(SDL_INIT_VIDEO); // Création de la surface d'affichage qui est en OpenGL SDL_WM_SetCaption("Crazy Arena", NULL); SDL_Surface* ecran = SDL_SetVideoMode(LARGEUR, HAUTEUR, 32, SDL_OPENGL); // Initialisation de l'affichage OpenGL /* Control the Projection */ glMatrixMode(GL_PROJECTION); glLoadIdentity(); glEnable(GL_DEPTH_TEST); // On prends en compte les zones cachées glEnable(GL_TEXTURE_2D); // On active les textures //glEnable(GL_FOG); /* * Explications gluPerspective(détails:http://www.siteduzero.com/tutoriel-3-421544-la-matrice-de-projection.html) * p1: angle (exemple: 70,30,100: angle de vue de la scène-> plus celui-ci est petit, plus on a l'impression de faire un zoom sur la scène * p2: ratio: largeur/hauteur * p3: near: * p4: far: pour qu'un objet puisse s'afficher sur l'écran, il faut qu'il se situe entre les zones near et far, sinon il ne sera pas affiché. */ //gluPerspective (20, (float)LARGEUR/HAUTEUR, 1, 100); gluPerspective(70, (float) LARGEUR / HAUTEUR, 1, 10); SDL_Flip(ecran); SDL_Event event; SDL_EnableKeyRepeat(10, 10); // Activation de la répétition de touches glutInit(&argc, argv); // Initialisation de glut Uint32 current_time; // Heure actuelle (frames second) Uint32 last_time = SDL_GetTicks(); Uint8 *keystate = SDL_GetKeyState(NULL); //int cameraX = 0; int cameraY = 2; //int cameraZ = 0; //GLUquadricObj * quad1 = gluNewQuadric(); //gluQuadricDrawStyle(quad1, GLU_FILL); MapBuilder* mp = new MapBuilder(); Map* map = mp->createMap(); CharacterBuilder* cb = new CharacterBuilder(); Character* character = cb->createCharacter(); Timer* timer = new Timer(); bool back = false; bool moved = false; bool continuer = true; while (continuer) { SDL_PollEvent(&event); switch (event.type) { case SDL_QUIT: continuer = false; break; } //Sauvegarde de quand la dernière touche à été pressée //cout <<"CT:"<< current_time << " LK" << lastKey << endl; //if(current_time > lastKey + KeysInterval){ if ((current_time > lastKey + KeysInterval)) { if (keystate[SDLK_RIGHT]) { //Tourner à droite //Ecart entre les 2 frappes de touches hitInterval = current_time - lastKey; cout << "INTERVAL:" << hitInterval << endl; if (lastHit == 1 && (hitInterval < 150) && (hitInterval > 160)) { if (!character->isTurningRight) character->rotateRight(); lastHit = -1; } //Couloir de droite else { lastHit = 1; Position* rightObstaclePosition = character->rightObstaclePosition(); if (map->getCube(rightObstaclePosition->getX(), rightObstaclePosition->getY(), rightObstaclePosition->getZ()) == 0) { character->right(); moved = true; } back = false; } lastKey = SDL_GetTicks(); } if (keystate[SDLK_LEFT]) { //Tourner à gauche //Ecart entre les 2 frappes de touches hitInterval = current_time - lastKey; cout << "INTERVAL:" << hitInterval << endl; if (lastHit == 3 && (hitInterval < 150) && (hitInterval > 160)) { if (!character->isTurningLeft) character->rotateLeft(); lastHit = -1; } //Couloir de gauche else { lastHit = 3; Position* leftObstaclePosition = character->leftObstaclePosition(); if (map->getCube(leftObstaclePosition->getX(), leftObstaclePosition->getY(), leftObstaclePosition->getZ()) == 0) { character->left(); moved = true; } back = false; } lastKey = SDL_GetTicks(); } if (keystate[SDLK_UP]) { lastKey = SDL_GetTicks(); lastHit = 0; Position* frontObstaclePosition = character->frontObstaclePosition(); //Test du cube sur lequel on marche //if (character->isJumping || map->getCube(frontPosition->getX(), //frontPosition->getY(), frontPosition->getZ()) != 0) { //Test d'un obstacle //cout << (map->getCube(frontObstaclePosition->getX(), frontObstaclePosition->getY(), //frontObstaclePosition->getZ()) == 0) << endl; if (map->getCube(frontObstaclePosition->getX(), frontObstaclePosition->getY(), frontObstaclePosition->getZ()) == 0) { character->front(); moved = true; } //} else { //character->down(); //} back = false; } if (keystate[SDLK_DOWN]) { lastKey = SDL_GetTicks(); lastHit = 2; if (!character->isTurningBack) character->rotateBack(); /* if (back == true) { //Position* backPosition = character->backPosition(); //if (map->getCube(backPosition->getX(), backPosition->getY(), backPosition->getZ()) != 0) { character->back(); moved = true; //} } else { back = true; } */ } if (keystate[SDLK_SPACE]) { lastKey = SDL_GetTicks(); lastHit = 4; //Début du saut if (!character->isJumping && character->isOnTheGround) character->up(); moved = true; back = false; } if (keystate[SDLK_LSHIFT]) { lastKey = SDL_GetTicks(); //Position* frontPosition = character->frontPosition(); //if (map->getCube(frontPosition->getX(), frontPosition->getY(), frontPosition->getZ()) != 0) { character->down(); moved = true; back = false; } if (keystate[SDLK_q]) { lastKey = SDL_GetTicks(); if (!character->isTurningLeft) character->rotateLeft(); } if (keystate[SDLK_s]) { lastKey = SDL_GetTicks(); if (!character->isTurningLeft) character->rotateRight(); } if (moved == true) { //cout << "x: " << character->getX() << " y:" << character->getY() << " z:"<< character->getZ() << endl; moved = false; } } // On met en pause (Frame per second) current_time = SDL_GetTicks(); while (current_time - last_time < (1000 / FRAMES_PER_SECOND)) { SDL_Delay(1000 / FRAMES_PER_SECOND - (current_time - last_time)); current_time = SDL_GetTicks(); } last_time = SDL_GetTicks(); glClearColor(0, 0, 0, 1); // Arrière plan /* Control the Model / View */ glMatrixMode(GL_MODELVIEW); // Choix de la matrice glLoadIdentity(); //Initialisation/RAZ de la matrice model/view pour ne pas garder les anciennes valeurs // On efface la fenêtre (pour la redessiner) glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); /* * Rotation du personnage */ if (character->isTurningRight) { character->smoothRight(); } if (character->isTurningLeft) { character->smoothLeft(); } if (character->isTurningBack) { character->smoothBack(); } camX = character->getX() - float(cos(character->rotAngle / 180 * 3.141592654f)); camZ = character->getZ() - float(sin(character->rotAngle / 180 * 3.141592654f)); //cout<<"camx:"<<camX<<endl; gluLookAt(camX, character->getY() + cameraY, camZ, character->getX(), character->getY() + cameraY, character->getZ(), upX, upY, upZ); /* * Affichage de la position du personnage */ cout << "Sortie 1: Currentx: " << character->getX() << " y:" << character->getY() << " z:" << character->getZ() << endl; /* * Affichage de la prochaine position du personnage */ Position* frontPosition = character->frontPosition(); //cout << "Sortie 2: NextX: " << frontPosition->getX() << " NextY:" << frontPosition->getY() << " nextZ:" << frontPosition->getZ() << endl; /* * Affichage de s'il va y avoir une collision frontale */ Position* nexObstacle = character->frontObstaclePosition(); Cube* cube = map->getCubeCol(nexObstacle->getX(), nexObstacle->getY(), nexObstacle->getZ()); if ((cube != 0) && cube->xcol == floor(frontPosition->getX())) { //cout << "front=" << frontPosition->getX() << "xmap=" << cube->xmap << endl; //cout << "OBSTACLE-------------------------------------->" << "obsX:" << cube->xmap << "obsY:" << cube->ymap << "obsZ:" << cube->ymap << endl; character->speed = 0; } else { character->front(); } Position* frontDownPosition = character->frontDownPosition(); //cout << "cube en dessous?:" << (map->getCube(frontDownPosition->getX(),frontDownPosition->getY(), frontDownPosition->getZ()) != 0) << endl; if (character->isJumping) { character->smoothUp(); } else { //faire descendre le personnage s'il ne saute pas et n'est pas sur le sol //Test pour savoir s'il y a un cube sous le personnage(dans ce cas, il faut arreter le saut if (map->getCube(frontDownPosition->getX(), frontDownPosition->getY(), frontDownPosition->getZ()) != 0) { character->isJumping = false; character->isOnTheGround = true; } if (!character->isJumping && !character->isOnTheGround) { cout << "DOWN" << endl; character->smoothDown(); } } //Test pour savoir si le personnage doit tomber (hors saut) if (!character->isJumping) { Position* frontDownPosition = character->frontDownPosition(); if (map->getCube(frontDownPosition->getX(), frontDownPosition->getY(), frontDownPosition->getZ()) == 0) { //character->down(); } } // On dessine tous les éléments map->draw(character->getX(),character->getY(),character->getZ()); character->draw(); timer->draw(); // Affichage (en float buffering) glFlush(); SDL_GL_SwapBuffers(); } // Fin du programme SDL_Quit(); return 0; }
void WorldState::OnEnter(GameGraph* game) { IVideoDriver* driver = game->GetVideoDriver(); ResourceManager* resourceManager = game->GetResourceManager(); ISceneManager* sceneManager = game->GetSceneManager(); //1) BUILD HERO heroSet = CreatureDefinitionFileManager::PopulateCreatureSet(resourceManager, "heroes.amr"); if (NULL != heroSet) { if (!heroSet->RegisterTextures(driver, resourceManager)) { LOGE("Unable to read in textures for creature set!"); } else { LOGI("A creature set with %d creatures was populated from the resource.", heroSet->GetNumberOfCreatures()); CreatureDefinition* creatureDefinition = heroSet->GetByName("hero"); if (NULL != creatureDefinition) { LOGI("The creature definition has been found and has the name %s", creatureDefinition->GetName().c_str()); hero = new PlayerCharacter(creatureDefinition, position2d<s32> (0, 0)); if (NULL != hero) { LOGI("Hero created with H x W (%d x %d)!", hero->GetWidth(), hero->GetHeight()); ITexture* heroTexture = driver->getTexture(hero->GetTextureName()); if (NULL != heroTexture) { LOGD("Hero created succesfully"); } else { LOGE("Unable to load hero texture named %s", hero->GetTextureName().c_str()); } } else { LOGE("Failed to create hero!"); } } else { LOGE( "An error occurred while attempting to pull the creature named %s from the creature set.", "hero"); } } } else { LOGE( "An error occured while attempting to populate a creature set from the supplied resource."); } //2) BUILD MONSTER SET Monster* skeleton = NULL; monsterSet = CreatureDefinitionFileManager::PopulateCreatureSet( resourceManager, "monsters.amr"); if (NULL != monsterSet) { if (!monsterSet->RegisterTextures(driver, resourceManager)) { LOGE("Unable to read in textures for monster set!"); } else { LOGI("A monster set with %d monsters was populated from the resource.", monsterSet->GetNumberOfCreatures()); CreatureDefinition* monsterDefinition = monsterSet->GetByName("skeleton"); if (NULL != monsterDefinition) { LOGI("The monster definition has been found and has the name %s", monsterDefinition->GetName().c_str()); skeleton = new Monster(monsterDefinition, vector2d<s32> (4, 4)); if (NULL != skeleton) { LOGI("Skeleton successfully created!"); } else { LOGE("Failed to create skeleton!"); } } else { LOGE("An error occurred while attempting to pull the creature named %s from the creature set.", "hero"); } } } else { LOGE("An error occured while attempting to populate a creature set from the supplied resource."); } //3) BUILD MAP tileSet = TileDefinitionFileManager::PopulateHexTileDefinitionSet( resourceManager, "latest.amr"); if (NULL != tileSet) { LOGI("The tile set contains %d tiles.", tileSet->GetNumberOfTiles()); LOGI("Tile width %f Tile height %f.", tileSet->GetTileWidth(), tileSet->GetTileHeight()); tileSet->RegisterTileTextures(driver, resourceManager); LOGI("Registered tile textures."); MapBuilder mapBuilder; LOGI("Building map..."); currentMap = mapBuilder.Construct(dimension2d<int> (10, 10), tileSet); LOGI("Adding hero..."); currentMap->SetPlayerCharacter(hero); LOGI("Adding skeleton..."); currentMap->AddMonster(skeleton); LOGI("Map completed!"); //Set global coordinate translator reference coordinateTranslator = currentMap->GetCoordinateTranslator(); driver->setTransform(ETS_WORLD, matrix4()); driver->setTransform(ETS_VIEW, matrix4()); //Build game layer and hard code wih map if (NULL != currentMap) { LOGI("Map:\nDimensions(%d, %d)\nTextureName: %s", currentMap->GetMapDimensions().Width, currentMap->GetMapDimensions().Height, currentMap->GetTextureFilename().c_str()); GameLayer* gameLayer = new GameLayer(currentMap, game->GetResourceManager(), game->GetSceneManager()->getRootSceneNode(), game->GetSceneManager(), 1234); } } else { LOGE("The TileSet could not be loaded and, accordingly, a map could not be constructed."); } }
void main_loop() { iGraph.DrawImage2D (0,0,736,448,0,0,736,448,Ganondorfs_castle); //Ganondorf.draw (&iGraph); //Ganondorf.print_pos(); sprite_list_head.insert_node (&Ganondorf, 5); int portal_y = 280; for (int i=0; i<5; i++) { portal.select_frame (i,0); portal.set_position (-107 + i*120, portal_y); //portal.draw (&iGraph); sprite_list_head.insert_node (&portal, portal.get_sheet_x() == 2 ? 4 : 5); }; //portal.select_frame (save_state.get_phase()+5, 0); portal.set_position (-109 + 5*120, portal_y); switch (save_state.get_phase()) { case 0: portal.select_frame (5, 0); sprite_list_head.insert_node (&portal, 5); break; case 1: portal.select_frame (7, 0); sprite_list_head.insert_node (&portal, 5); portal.select_frame (8, 0); sprite_list_head.insert_node (&portal, 6); break; case 2: portal.select_frame (7, 0); sprite_list_head.insert_node (&portal, 5); break; }; //portal.draw (&iGraph); for (int i=0; i<6; i++) { if (save_state.get_temple(i)) { medallion.select_frame (i, 0); medallion.set_position (38 + i*120, 220); //medallion.draw (&iGraph); sprite_list_head.insert_node (&medallion, 1); }; }; for (int i=0; i<6; i++) if (save_state.get_easter_egg(i)) { easter_egg.select_frame (i, 0); easter_egg.set_position (19 + (SCREEN_WIDTH / 2) - ((3-i) * 109) - (30 * (3-i>0)), 414); //Último x = 605 //prize_table.draw (&iGraph); sprite_list_head.insert_node (&easter_egg, 5); }; if (save_state.light()) { int i = 5; //easter_egg.set_position (605, 354); //sprite_list_head.insert_node (&easter_egg, 5); easter_egg.select_frame (i+1, 0); easter_egg.set_position (605, 352); sprite_list_head.insert_node (&easter_egg, 5); }; if (see_generated_map) { MapNode* current_node = map_builder.get_list_head()->get_ptr(); while (current_node != NULL) { forest_map.set_position (current_node->get_screen_x(), current_node->get_screen_y()); forest_map.select_frame (current_node->get_sheet_x(), current_node->get_sheet_y()); forest_map.draw (&iGraph); current_node = current_node->get_ptr(); }; }; //Epona.draw (&iGraph); //Epona.set_position ((SCREEN_WIDTH - Epona.get_frame_w()) / 2 - 12, 345); sprite_list_head.insert_node (&Epona, 5); float hearts = save_state.get_hearts(); int whole_hearts = floor (hearts); float fraction = hearts - whole_hearts; //printf ("hearts = %0.2f\twhole_hearts = %d\tfraction=%0.2f\n", hearts, whole_hearts, fraction); for (int i=0; i<20; i++) { if (i < 10) heart.set_position (22*i + 20, 20); else heart.set_position (22*(i-10) + 20, 40); if (i < whole_hearts) heart.select_frame (0, 0); else if (i == whole_hearts) { if (fraction == 0.0f) heart.select_frame (4, 0); else if (fraction == 0.25f) heart.select_frame (3, 0); else if (fraction == 0.50f) heart.select_frame (2, 0); else if (fraction == 0.75f) heart.select_frame (1, 0); } else if (i > whole_hearts) heart.select_frame (4, 0); if (i+1 <= save_state.get_heart_containers()) sprite_list_head.insert_node (&heart, 10); }; int total_rupees = save_state.get_rupees(); int single_digit_rupees = 0; char rupee_str[4]; for (int i=0; i<3; i++) { int divisor = pow ((double) 10, (int) 2-i); single_digit_rupees = total_rupees / divisor; rupee_str[i] = '0' + single_digit_rupees; total_rupees -= single_digit_rupees * divisor; }; rupee_str[3] = '\0'; rupee.set_position (20, SCREEN_HEIGHT - 10); sprite_list_head.insert_node (&rupee, 10); iGraph.SetTextFont ("Helvetica", 25, 10, 0, 0); iGraph.draw_text (45, SCREEN_HEIGHT - 13, rupee_str); //iGraph.draw_point (SCREEN_WIDTH/2, 280); sprite_list_head.draw_list (&iGraph); //sprite_list_head.print_node_line(); sprite_list_head.clear(); int mana_y = save_state.get_heart_containers() > 10 ? 45 : 30; iGraph.SetColor (0.0f, 255.0f, 127.0f); iGraph.fill_rectangle (20, mana_y, 234, mana_y + 10); iGraph.SetColor (255.0f, 255.0f, 255.0f); iGraph.draw_rectangle (20, mana_y, 234, mana_y + 10); };