//Update() is where the magic happens, //It Draws everything to the screen void update(vector<character> *objects) { drawRect(0, 0, camera.size.x, camera.size.y, 0,150,0); //drawRect(loc.x, loc.y, size.x, size.y, r, g, b); SDL_Rect square; //SDL_Rect* clip = NULL; for(unsigned int i = 0; i < objects->size(); i++) { if(collide(camera, objects->at(i))) { //dim size = objects->at(i).size;; dim loc = objects->at(i).loc; loc.x-=camera.loc.x; loc.y-=camera.loc.y; square.x = loc.x; square.y = loc.y; int index = 0; if (objects->at(i).type == green) index = 1; if (objects->at(i).type == blue) index = 3; if (objects->at(i).type == purple) index = 5; if (objects->at(i).selected) index--; if (objects->at(i).type == red) index = 6; if (objects->at(i).type == rock) index = 7; if (objects->at(i).type == rock2) index = 8; SDL_BlitSurface(images[index], NULL, mainframe, &square); } } if (dragBox.on && (dragBox.size.x <= camera.size.x && dragBox.size.y <= camera.size.y)) drawRect(dragBox.loc.x, dragBox.loc.y, dragBox.size.x, dragBox.size.y, 0, 255, 255); drawRect(bottomMenu.getLoc().x, bottomMenu.getLoc().y, bottomMenu.getSize().x, bottomMenu.getSize().y, 100, 100, 100); SDL_Flip(mainframe); return; }
void moveCamera(dim move) { while(camera.loc.x+camera.size.x>currentMap->length-move.x) move.x--; while(camera.loc.y+camera.size.y>currentMap->length-move.y+bottomMenu.getSize().y) move.y--; while(camera.loc.x+move.x<0) move.x++; while(camera.loc.y+move.y<0) move.y++; camera.loc.x += move.x; camera.loc.y += move.y; }
void autoRestore(menu m) { //This still needs user input. for(unsigned i = 0; i < m.getSize(); i++) { FS_Archive saveArch; if(m.optSelected(i) && openSaveArch(&saveArch, sdTitle[i], false)) restoreData(sdTitle[i], saveArch, MODE_SAVE); FSUSER_CloseArchive(&saveArch); FS_Archive extArch; if(m.optSelected(i) && openExtdata(&extArch, sdTitle[i], false)) restoreData(sdTitle[i], extArch, MODE_EXTDATA); FSUSER_CloseArchive(&extArch); } }
void autoBackup(menu m) { showMessage("This can take a few minutes depending on how many titles are selected."); progressBar autoDump((float)m.getSelectCount(), "Copying saves..."); //Keep track of what's done float dumpCount = 0; for(unsigned i = 0; i < m.getSize(); i++) { //This is for titles with no save archive ex. Fantasy Life bool dumped = false; FS_Archive saveArch; if(m.optSelected(i) && openSaveArch(&saveArch, sdTitle[i], false))//if it's selected and we can open save archive { createTitleDir(sdTitle[i], MODE_SAVE); backupData(sdTitle[i], saveArch, MODE_SAVE, true); dumpCount++; dumped = true; } FSUSER_CloseArchive(&saveArch); FS_Archive extArch; if(m.optSelected(i) && openExtdata(&extArch, sdTitle[i], false)) { createTitleDir(sdTitle[i], MODE_EXTDATA); backupData(sdTitle[i], extArch, MODE_EXTDATA, true); //check first to make sure we don't count it twice because no save arch if(!dumped) dumpCount++; } FSUSER_CloseArchive(&extArch); sf2d_start_frame(GFX_BOTTOM, GFX_LEFT); autoDump.draw(i); sf2d_end_frame(); sf2d_swapbuffers(); } showMessage("Complete!"); }