Advertisement
bb94

フルーピュー弾幕風!!!

Feb 14th, 2015
245
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.59 KB | None | 0 0
  1. // high scores
  2.  
  3. #include "../language.dnh"
  4. #include "../system/name_entry.dnh"
  5.  
  6. let op;
  7. let data;
  8. let txt;
  9.  
  10. let SUBMIT_HIGH_SCORE = 0;
  11. let VIEW_HIGH_SCORE = 1;
  12. let scin = 268435456;
  13. let scarr = [];
  14. let scnames = [];
  15. let chara;
  16. let difficulty;
  17. let mode;
  18. let score;
  19. let stage;
  20.  
  21. #include "../itsb.dnh"
  22.  
  23. @Initialize {
  24. descent (i in 0 .. 16) {
  25. scarr = scarr ~ [[scin * (i + 1), 1]];
  26. scnames = scnames ~ ["Cen.Cyr"];
  27. }
  28. op = GetScriptArgument(0);
  29. data = GetScriptArgument(1);
  30. chara = data[0];
  31. difficulty = data[1];
  32. mode = data[2];
  33. if (op == SUBMIT_HIGH_SCORE) {
  34. stage = data[3];
  35. score = data[4];
  36. if (hasHighScore(score, chara, difficulty, mode)) {
  37. let name = enterName("HighScoreGet!");
  38. let hs = getHighScore(chara, difficulty, mode);
  39. let hsn = getHighScoreNames(chara, difficulty, mode);
  40. let i = 0;
  41. loop {
  42. if (score > hs[i][0]) {break;}
  43. i++;
  44. }
  45. ascent (j in i .. 14) {
  46. hs[j + 1] = hs[j];
  47. hsn[j + 1] = hsn[j];
  48. }
  49. hs[i] = [score, stage];
  50. hsn[i] = name;
  51. SetAreaCommonData("Cy05", "HS" ~ IntToString(chara) ~ IntToString(difficulty) ~ ["N", "H"][mode],hs);
  52. SetAreaCommonData("Cy05", "HSn" ~ IntToString(chara) ~ IntToString(difficulty) ~ ["N", "H"][mode], hsn);
  53. }
  54. }
  55. txt = ObjText_Create;
  56. ObjText_SetFontType(txt, "Consolas");
  57. ObjText_SetFontSize(txt, 16);
  58. ObjText_SetFontColorTop(txt, 128, 255, 255);
  59. ObjText_SetFontColorBottom(txt, 128, 255, 255);
  60. Obj_SetRenderPriority(txt, 0.1);
  61. ObjRender_SetPosition(txt, 64, 64, 0);
  62. update(chara, difficulty, mode);
  63. }
  64.  
  65. @Event {
  66.  
  67. }
  68.  
  69. @MainLoop {
  70. if (isPushed(VK_OK) ||
  71. isPushed(VK_CANCEL)) {
  72. Obj_Delete(txt);
  73. CloseScript(GetOwnScriptID);
  74. }
  75. if (op == VIEW_HIGH_SCORE) {
  76. if (isPushed(VK_UP)) {
  77. difficulty--;
  78. if (difficulty < 0) {difficulty = 5;}
  79. update(chara, difficulty, mode);
  80. }
  81. else if (isPushed(VK_DOWN)) {
  82. difficulty++;
  83. if (difficulty > 5) {difficulty = 0;}
  84. update(chara, difficulty, mode);
  85. }
  86. else if (isPushed(VK_LEFT)) {
  87. chara--;
  88. if (chara < 0) {chara = 3;}
  89. update(chara, difficulty, mode);
  90. }
  91. else if (isPushed(VK_RIGHT)) {
  92. chara++;
  93. if (chara > 3) {chara = 0;}
  94. update(chara, difficulty, mode);
  95. }
  96. else if (isPushed(VK_USER1)) {
  97. mode = !mode;
  98. update(chara, difficulty, mode);
  99. }
  100. }
  101. //WriteLog("hodor");
  102. yield;
  103. }
  104.  
  105. function isPushed(key) {
  106. return GetVirtualKeyState(key) == KEY_PUSH;
  107. }
  108.  
  109. function update(c, d, m) {
  110. ObjText_SetText(txt, scoreEntry(c, d, m));
  111. }
  112.  
  113. function scoreEntry(chara, diff, mode) {
  114. let entries = getInterfaceStrings(SHOTTYPES + chara) ~ " " ~
  115. getInterfaceStrings(I_DIFFICULTY + diff) ~
  116. ["", " " ~ getInterfaceStrings(HIDDEN_MODE)][mode] ~ "[r]";
  117. let hs = getHighScore(chara, diff, mode);
  118. let hsn = getHighScoreNames(chara, diff, mode);
  119. let base = GetCommonData("Base", 16);
  120. ascent (i in 0 .. 15) {
  121. let raw = hs[i];
  122. entries = entries ~
  123. "0123456789ABCDEF"[i .. i + 1] ~ ". " ~ vtos("-8d", hsn[i]) ~ " " ~
  124. vtos("14s", IntToStringBase(raw[0], base)) ~ " (" ~
  125. "0123456789FXC"[raw[1] .. raw[1] + 1] ~ ")[r]";
  126. }
  127. return entries;
  128. }
  129.  
  130. function getHighScore(character, difficulty, mode) {
  131. return GetAreaCommonData("Cy05", "HS" ~ IntToString(character) ~ IntToString(difficulty) ~ ["N", "H"][mode],
  132. scarr);
  133. }
  134.  
  135. function hasHighScore(score, character, difficulty, mode) {
  136. return score > getHighScore(character, difficulty, mode)[15][0];
  137. }
  138.  
  139. function getHighScoreNames(character, difficulty, mode) {
  140. return GetAreaCommonData("Cy05", "HSn" ~ IntToString(character) ~ IntToString(difficulty) ~ ["N", "H"][mode],
  141. scnames);
  142. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement