/*--------------------------------------------------------------------------*/ void map_container::projection_update() { if(projection) delete projection; projection = new map_projection((char*)calibration->projection); LLXY* calibrations = (LLXY*)malloc(calibration->calibrations_amount * sizeof(LLXY)); memcpy( calibrations, calibration->calibrations, calibration->calibrations_amount * sizeof(LLXY)); for ( long i = 0; i < calibration->calibrations_amount; i++ ) { calibrations[i].x *= zoom_table[zoom_current].zoom; calibrations[i].y *= zoom_table[zoom_current].zoom; } projection->set_params(&calibration->projection_params, map_width(), map_height()); projection->bind_by_points(calibrations, calibration->calibrations_amount); free(calibrations); }
void map_save (char *filename) { // TODO // Elements qu'on doit avoir en début de fichier // height/width // nombre d'objets maximum possible sur la map // contenu de chaque case de la carte // caractéristique de chaque objet : nom du fichier, nombre de sprite, propriétés int height = map_height(), width = map_width(), nb_obj = map_objects(); int cur_obj; int file = open("save.map", O_CREAT | O_TRUNC | O_WRONLY, 0777); write(file, &height, sizeof(int)); write(file, "\n", 1); write(file, &width, sizeof(int)); write(file, "\n", 1); write(file, &nb_obj, sizeof(int)); write(file, "\n", 1); for(int i = 0; i < width; ++i) { for(int j = 0; j < height; ++j) { //do some stuff with cur_obj = map_get(i, j); write(file, &cur_obj, sizeof(int)); } } write(file, "\n", 1); int len = 0, frames, solidity, destr, collec, gen; for(int i = 0; i < nb_obj; ++i) { len = strlen(map_get_name(i)); write(file, &len, sizeof(int)); write(file, map_get_name(i), len); frames = map_get_frames(i); solidity = map_get_solidity(i); destr = map_is_destructible(i); collec = map_is_collectible(i); gen = map_is_generator(i); write(file, &frames, sizeof(int)); write(file, &solidity, sizeof(int)); write(file, &destr, sizeof(int)); write(file, &collec, sizeof(int)); write(file, &gen, sizeof(int)); write(file, "\n", 1); } close(file); }