- fprintf(fi,";SuperTux level made using the built-in leveleditor\n");
- fprintf(fi,"(supertux-level\n");
-
- fprintf(fi," (version %d)\n", 1);
- fprintf(fi," (name \"%s\")\n", name.c_str());
- fprintf(fi," (author \"%s\")\n", author.c_str());
- fprintf(fi," (music \"%s\")\n", song_title.c_str());
- fprintf(fi," (background \"%s\")\n", bkgd_image.c_str());
- fprintf(fi," (particle_system \"%s\")\n", particle_system.c_str());
- fprintf(fi," (bkgd_speed %d)\n", bkgd_speed);
- fprintf(fi," (bkgd_red_top %d)\n", bkgd_top.red);
- fprintf(fi," (bkgd_green_top %d)\n", bkgd_top.green);
- fprintf(fi," (bkgd_blue_top %d)\n", bkgd_top.blue);
- fprintf(fi," (bkgd_red_bottom %d)\n", bkgd_bottom.red);
- fprintf(fi," (bkgd_green_bottom %d)\n", bkgd_bottom.green);
- fprintf(fi," (bkgd_blue_bottom %d)\n", bkgd_bottom.blue);
- fprintf(fi," (time %d)\n", time_left);
- fprintf(fi," (width %d)\n", width);
- fprintf(fi," (height %d)\n", height);
- if(back_scrolling)
- fprintf(fi," (back_scrolling #t)\n");
- else
- fprintf(fi," (back_scrolling #f)\n");
- fprintf(fi," (hor_autoscroll_speed %2.1f)\n", hor_autoscroll_speed);
- fprintf(fi," (gravity %2.1f)\n", gravity);
- fprintf(fi," (background-tm ");
-
- for(int y = 0; y < height; ++y)
- {
- for(int i = 0; i < width; ++i)
- fprintf(fi," %d ", bg_tiles[y][i]);
- fprintf(fi,"\n");
- }
-
- fprintf( fi,")\n");
- fprintf(fi," (interactive-tm ");
-
- for(int y = 0; y < height; ++y)
- {
- for(int i = 0; i < width; ++i)
- fprintf(fi," %d ", ia_tiles[y][i]);
- fprintf(fi,"\n");
- }
-
- fprintf( fi,")\n");
- fprintf(fi," (foreground-tm ");
-
- for(int y = 0; y < height; ++y)
- {
- for(int i = 0; i < width; ++i)
- fprintf(fi," %d ", fg_tiles[y][i]);
- fprintf(fi,"\n");
- }
-
- fprintf( fi,")\n");
-
- fprintf( fi,"(reset-points\n");
+ writer.write_comment("SuperTux level made using the built-in leveleditor");
+ writer.start_list("supertux-level");
+
+ writer.write_int("version", 1);
+ writer.write_string("name", name);
+ writer.write_string("author", author);
+ writer.write_string("music", song_title);
+ writer.write_string("background", bkgd_image);
+ writer.write_string("particle_system", particle_system);
+ writer.write_int("bkgd_speed", bkgd_speed);
+ writer.write_int("bkgd_red_top", bkgd_top.red);
+ writer.write_int("bkgd_green_top", bkgd_top.green);
+ writer.write_int("bkgd_blue_top", bkgd_top.blue);
+ writer.write_int("bkgd_red_bottom", bkgd_bottom.red);
+ writer.write_int("bkgd_green_bottom", bkgd_bottom.green);
+ writer.write_int("bkgd_blue_bottom", bkgd_bottom.blue);
+ writer.write_int("time", time_left);
+ writer.write_int("width", width);
+ writer.write_int("height", height);
+ writer.write_bool("back_scrolling", back_scrolling);
+ writer.write_float("hor_autoscroll_speed", hor_autoscroll_speed);
+ writer.write_float("gravity", gravity);
+
+ writer.write_int_vector("background-tm", bg_tiles);
+ writer.write_int_vector("interactive-tm", ia_tiles);
+ writer.write_int_vector("foreground-tm", fg_tiles);
+
+ writer.start_list("reset-points");