Advertisement
JHFlauzino

pause

Sep 30th, 2018
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 4.87 KB | None | 0 0
  1. //一時停止中スクリプト
  2.  
  3. @Initialize
  4. {
  5.     SetAutoDeleteObject(true);
  6.     TBackground();
  7.     TMenu();
  8. }
  9.  
  10. @MainLoop
  11. {
  12.     yield;
  13. }
  14.  
  15. @Finalize
  16. {
  17. }
  18.  
  19.  
  20. task TBackground
  21. {
  22.     task TVertex(var index, var left, var top, var right, var bottom)
  23.     {
  24.         ObjPrim_SetVertexPosition(obj, index + 0, left, top, 0);
  25.         ObjPrim_SetVertexPosition(obj, index + 1, left, bottom, 0);
  26.         ObjPrim_SetVertexPosition(obj, index + 2, right, top, 0);
  27.         ObjPrim_SetVertexPosition(obj, index + 3, right, top, 0);
  28.         ObjPrim_SetVertexPosition(obj, index + 4, left, bottom, 0);
  29.         ObjPrim_SetVertexPosition(obj, index + 5, right, bottom, 0);
  30.  
  31.         ObjPrim_SetVertexUVT(obj, index + 0, left, top);
  32.         ObjPrim_SetVertexUVT(obj, index + 1, left, bottom);
  33.         ObjPrim_SetVertexUVT(obj, index + 2, right, top);
  34.         ObjPrim_SetVertexUVT(obj, index + 3, right, top);
  35.         ObjPrim_SetVertexUVT(obj, index + 4, left, bottom);
  36.         ObjPrim_SetVertexUVT(obj, index + 5, right, bottom);
  37.  
  38.         //STGシーン内のみアニメーション
  39.         if(left >= 165 && right <= 868 && top >=32 && bottom <= 735)
  40.         {
  41.             let alpha = 255;
  42.             while(alpha >= 128)
  43.             {
  44.                 ObjPrim_SetVertexAlpha(obj, index + 0, alpha);
  45.                 ObjPrim_SetVertexAlpha(obj, index + 1, alpha/1);
  46.                 ObjPrim_SetVertexAlpha(obj, index + 2, alpha/1);
  47.                 ObjPrim_SetVertexAlpha(obj, index + 3, alpha/1);
  48.                 ObjPrim_SetVertexAlpha(obj, index + 4, alpha/1);
  49.                 ObjPrim_SetVertexAlpha(obj, index + 5, alpha);
  50.                 alpha -= 255 / frame;
  51.  
  52.                 yield;
  53.             }
  54.         }
  55.     }
  56.  
  57.     //分割設定
  58.     let frame = 20;
  59.     let countH = 20; //分割数
  60.     let countV = 30;
  61.     let width = 1366 / countH;
  62.     let height = 768 / countV;
  63.     let target = GetTransitionRenderTargetName();
  64.     let obj = ObjPrim_Create(OBJ_PRIMITIVE_2D); //2D頂点ブジェクト生成
  65.     ObjPrim_SetPrimitiveType(obj, PRIMITIVE_TRIANGLELIST);
  66.     ObjPrim_SetVertexCount(obj, countH * countV * 6);
  67.     Obj_SetRenderPriorityI(obj, 0); //描画優先度を設定
  68.     ObjPrim_SetTexture(obj, target); //テクスチャを設定
  69.  
  70.     ascent(ix in 0.. countH)
  71.     {
  72.         ascent(iy in 0.. countV)
  73.         {
  74.             let index = (ix + iy * countH) * 6;
  75.             let left = ix * width;
  76.             let right = left + width;
  77.             let top = iy * height;
  78.             let bottom = top + height;
  79.             TVertex(index, left, top, right, bottom);
  80.         }
  81.     }
  82.  
  83. }
  84.  
  85. task TMenu
  86. {
  87.     let selectIndex = 0;//選択位置
  88.     task TMenuItem(let index, let mx, let my, let text)
  89.     {
  90.         function CreateTextObject(let mx, let my, let text)
  91.         {
  92.             let obj = ObjText_Create();
  93.             ObjText_SetText(obj, text);
  94.             ObjText_SetFontSize(obj, 20);
  95.             ObjText_SetFontBold(obj, true);
  96.             ObjText_SetFontColorTop(obj, 128, 128, 128);
  97.             ObjText_SetFontColorBottom(obj, 0, 0, 0);
  98.             ObjText_SetFontBorderType(obj, BORDER_FULL);
  99.             ObjText_SetFontBorderColor(obj,0, 0, 0);
  100.             ObjText_SetFontBorderWidth(obj, 1);
  101.             Obj_SetRenderPriorityI(obj, 10);
  102.             ObjRender_SetX(obj, mx-ObjText_GetTotalWidth(obj)/2);
  103.             ObjRender_SetY(obj, my);
  104.             return obj;
  105.         }
  106.  
  107.         let objText = CreateTextObject(mx, my, text);
  108.         let objSelect = CreateTextObject(mx, my, text);
  109.         ObjRender_SetBlendType(objSelect, BLEND_ADD_ARGB);
  110.         ObjText_SetFontColorTop(objSelect, 255, 255, 255);
  111.         ObjText_SetFontColorBottom(objSelect, 128, 128, 128);      
  112.         loop
  113.         {
  114.             Obj_SetVisible(objSelect, index == selectIndex);
  115.             yield;
  116.         }
  117.     }
  118.  
  119.     //メニュー配置
  120.     let texts = ["Continue", "Back to Menu", "Restart"];
  121.     var countMenu = length(texts);
  122.     let mx = (702/2)+165;
  123.     let my = 702/2-32*countMenu/2;
  124.     ascent(var iText in 0 .. countMenu)
  125.     {
  126.         TMenuItem(iText, mx, my, texts[iText]);
  127.         my += 32;
  128.     }
  129.  
  130.     //キー状態がリセットされるまで待機
  131.     while(GetVirtualKeyState(VK_PAUSE) != KEY_FREE){yield;}
  132.  
  133.     //メニュー選択処理
  134.     let frameKeyHold = 0;//キー押しっぱなしフレーム数
  135.     loop
  136.     {
  137.         //決定
  138.         if(GetVirtualKeyState(VK_OK) == KEY_PULL)
  139.         {
  140.             let listResult = [RESULT_CANCEL, RESULT_END, RESULT_RETRY];
  141.             SetScriptResult(listResult[selectIndex]);
  142.             CloseScript(GetOwnScriptID());
  143.             return;
  144.         }
  145.  
  146.         //キャンセル
  147.         if(GetVirtualKeyState(VK_CANCEL) == KEY_PULL || GetVirtualKeyState(VK_PAUSE) == KEY_PULL)
  148.         {
  149.             SetScriptResult(RESULT_CANCEL);
  150.             CloseScript(GetOwnScriptID());
  151.             return;
  152.         }
  153.  
  154.         //カーソル移動
  155.         if(GetVirtualKeyState(VK_UP) == KEY_PUSH)
  156.         {
  157.             selectIndex--;
  158.         }
  159.         else if(GetVirtualKeyState(VK_DOWN) == KEY_PUSH)
  160.         {
  161.             selectIndex++;
  162.         }
  163.         else if(GetVirtualKeyState(VK_UP) == KEY_HOLD)
  164.         {
  165.             frameKeyHold++;
  166.             if(frameKeyHold == 30 || (frameKeyHold > 30 && (frameKeyHold % 10 == 0)))
  167.             {
  168.                 selectIndex--;
  169.             }
  170.         }
  171.         else if(GetVirtualKeyState(VK_DOWN) == KEY_HOLD)
  172.         {
  173.             frameKeyHold++;
  174.             if(frameKeyHold == 30 || (frameKeyHold > 30 && (frameKeyHold % 10 == 0)))
  175.             {
  176.                 selectIndex++;
  177.             }
  178.         }
  179.         else
  180.         {
  181.             frameKeyHold = 0;
  182.         }
  183.  
  184.         if(selectIndex < 0)
  185.         {
  186.             selectIndex = countMenu - 1;
  187.         }
  188.         else
  189.         {
  190.             selectIndex %= countMenu;
  191.         }
  192.  
  193.         yield;
  194.     }
  195. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement