Advertisement
tyrz939

Untitled

Feb 2nd, 2017
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. if file_exists(working_directory + string(rpl)){
  2.     file_delete(working_directory + string(rpl));
  3. }
  4. file = file_bin_open(working_directory + string(rpl), 1);
  5.  
  6. // Difficulty, Character
  7. file_bin_write_byte(file, global.difficulty);
  8. file_bin_write_byte(file, global.char);
  9.  
  10. // Write Date
  11. var date_string = string(string(current_day) + "/" + string (current_month) + "/" + string(current_year));
  12. file_bin_write_byte(file, string_byte_length(date_string));
  13. for(var i = 0; i <= string_byte_length(date_string); i++){
  14.     file_bin_write_byte(file, string_byte_at(date_string, i));
  15. }
  16.  
  17. // Write Time
  18. var time_string = string(string(current_hour) + ":" + string(current_minute));
  19. file_bin_write_byte(file, string_byte_length(time_string));
  20. for(var i = 0; i <= string_byte_length(time_string); i++){
  21.     file_bin_write_byte(file, string_byte_at(time_string, i));
  22. }
  23.  
  24. file_bin_write_byte(file, level); // Starting Level
  25. file_bin_write_byte(file, levelpos); // Level start position (mainly for demo play)
  26.  
  27. // What points you can load from
  28. var states0 = 0;
  29. states0 += save_points[0] *128;
  30. states0 += save_points[1] *64;
  31. states0 += save_points[2] *32;
  32. states0 += save_points[3] *16;
  33. states0 += save_points[4] *8;
  34. states0 += save_points[5] *4;
  35. states0 += save_points[6] *2;
  36. states0 += save_points[7];
  37. file_bin_write_byte(file, states0);
  38. var states1 = 0;
  39. states1 += save_points[8] *32;
  40. states1 += save_points[9] *16;
  41. states1 += save_points[10] *8;
  42. states1 += save_points[11] *4;
  43. states1 += save_points[12] *2;
  44. states1 += save_points[13];
  45. file_bin_write_byte(file, states1);
  46.  
  47. // How long in frames
  48. var fc = global.frame;
  49. var ef0 = floor(fc/65536);
  50. fc -= ef0 * 65536;
  51. var ef1 = floor(fc/256);
  52. fc -= ef1 * 256;
  53. var ef2 = fc;
  54. file_bin_write_byte(file, ef0);
  55. file_bin_write_byte(file, ef1);
  56. file_bin_write_byte(file, ef2);
  57.  
  58. // Start lives, bombs and power
  59. file_bin_write_byte(file, life);
  60. file_bin_write_byte(file, bombs);
  61. file_bin_write_byte(file, pow);
  62.  
  63. // Starting Score
  64. var s0 = floor(s_score/16777216);
  65. s_score -= s0 * 16777216;
  66. var s1 = floor(s_score/65536);
  67. s_score -= s1 * 65536;
  68. var s2 = floor(s_score/256);
  69. s_score -= s2 * 256;
  70. var s3 = s_score;
  71. file_bin_write_byte(file, s0);
  72. file_bin_write_byte(file, s1);
  73. file_bin_write_byte(file, s2);
  74. file_bin_write_byte(file, s3);
  75.  
  76. // Player Start X/Y
  77. var x0 = floor(start_x / 256);
  78. var x1 = start_x - (x0 * 256);
  79. file_bin_write_byte(file, x0);
  80. file_bin_write_byte(file, x1);
  81. var y0 = floor(start_y / 256);
  82. var y1 = start_y - (y0 * 256);
  83. file_bin_write_byte(file, y0);
  84. file_bin_write_byte(file, y1);
  85.  
  86. // Save States loop
  87. var t0, t1, t2, t3;
  88. for(var i = 0; i < states_saved; i++){
  89.     // Player X, Y
  90.     t0 = floor(state[0, i] / 256);
  91.     t1 = state[0, i] - (t0 * 256);
  92.     file_bin_write_byte(file, t0);
  93.     file_bin_write_byte(file, t1);
  94.     t0 = floor(state[1, i] / 256);
  95.     t1 = state[1, i] - (t0 * 256);
  96.     file_bin_write_byte(file, t0);
  97.     file_bin_write_byte(file, t1);
  98.     // Lifes
  99.     file_bin_write_byte(file, state[2, i]);
  100.     // Bombs
  101.     file_bin_write_byte(file, state[3, i]);
  102.     // Power
  103.     t0 = floor(state[4,i]);
  104.     t1 = frac(state[4,i]) * 100;
  105.     file_bin_write_byte(file, t0);
  106.     file_bin_write_byte(file, t1);
  107.     // Frame
  108.     t0 = floor(state[5,i]/65536);
  109.     state[5,i] -= t0 * 65536;
  110.     t1 = floor(state[5,i]/256);
  111.     state[5,i] -= t1 * 256;
  112.     t2 = state[5,i];
  113.     file_bin_write_byte(file, t0);
  114.     file_bin_write_byte(file, t1);
  115.     file_bin_write_byte(file, t2);
  116.     // Seconds
  117.     t0 = floor(state[6,i]);
  118.     t1 = frac(state[6,i]) * 100;
  119.     file_bin_write_byte(file, t0);
  120.     file_bin_write_byte(file, t1);
  121.     // Level
  122.     file_bin_write_byte(file, state[7,i]);
  123.     // Level Position
  124.     file_bin_write_byte(file, state[8,i]);
  125.     // Score
  126.     t0 = floor(state[9,i]/16777216);
  127.     state[9,i] -= t0 * 16777216;
  128.     t1 = floor(state[9,i]/65536);
  129.     state[9,i] -= t1 * 65536;
  130.     t2 = floor(state[9,i]/256);
  131.     state[9,i] -= t2 * 256;
  132.     t3 = state[9,i];
  133.     file_bin_write_byte(file, t0);
  134.     file_bin_write_byte(file, t1);
  135.     file_bin_write_byte(file, t2);
  136.     file_bin_write_byte(file, t3);
  137.     // Shot GCD
  138.     file_bin_write_byte(file, state[10, i]);
  139.     // Graze count
  140.     t0 = floor(state[11, i] / 256);
  141.     t1 = state[11, i] - (t0 * 256);
  142.     file_bin_write_byte(file, t0);
  143.     file_bin_write_byte(file, t1);
  144.     // Point items collected
  145.     t0 = floor(state[12, i] / 256);
  146.     t1 = state[12, i] - (t0 * 256);
  147.     file_bin_write_byte(file, t0);
  148.     file_bin_write_byte(file, t1);
  149. }
  150.  
  151. // Frame & Input save loop
  152. var inp, f0, f1, f2;
  153. for(var i = 0; i < pos; i++){
  154.     // Frame Count
  155.     f0 = floor(replay[timer,i]/65536);
  156.     replay[timer,i] -= f0 * 65536;
  157.     f1 = floor(replay[timer,i]/256);
  158.     replay[timer,i] -= f1 * 256;
  159.     f2 = replay[timer,i];
  160.     file_bin_write_byte(file, f0);
  161.     file_bin_write_byte(file, f1);
  162.     file_bin_write_byte(file, f2);
  163.    
  164.     // Input
  165.     inp = 0;
  166.     inp += replay[up, i] <<6;
  167.     inp += replay[down, i] <<5;
  168.     inp += replay[left, i] <<4;
  169.     inp += replay[right, i] <<3;
  170.     inp += replay[focus, i] <<2;
  171.     inp += replay[shoot, i] <<1;
  172.     inp += replay[bomb, i];
  173.     file_bin_write_byte(file, inp);
  174. }
  175.  
  176. file_bin_close(file);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement