Advertisement
Guest User

Untitled

a guest
Jun 20th, 2020
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 8.85 KB | None | 0 0
  1. #include "DxLib.h"
  2. #include <string>
  3.  
  4. int konnnitiwasound = 0;
  5. int situreisimasitasound = 0;
  6. char String[256];
  7. char StringA[256];
  8. int InputHandle;
  9. int InputHandleA;
  10. int modoru = 0;
  11. std::string input;
  12. std::string message;
  13. std::string messageA;
  14.  
  15. char deta1[] = { "私" };
  16. char deta2[] = { "は" };
  17. char deta3[] = { "映画" };
  18. char deta4[] = { "が" };
  19. char deta5[] = { "好き" };
  20.  
  21.  
  22. int i;
  23.  
  24. int a[3] = { 3, 4, 5 };
  25.  
  26. int duration = 0;
  27. int konnnitiwa = 0;
  28. int sitaidou = 0;
  29. int sitaidouA = 0;
  30. int mozicount = 0;
  31. int mozicount2 = 0;
  32. int mozicount3 = 0;
  33.  
  34. int rireki = 0;
  35. int rireki2 = 0;
  36. int   LEFTmark = 0;
  37. const char* str[2] = { "どんな映画が好きなんですか?","申し訳ございません! "};//ここで文字を直接書いてるので、この文字のバイト数が各posmozi[]に入るだけ
  38. int frame[2] = { 10,10};//次の一文字が出るまでのカウンタとして働いている、ここの数値を変えることで文字が一文字ずつ出るまでの間隔を設定できる。
  39. int posmozi[20];//文字のバイト数が入る箱を表している。
  40. int countS[2];//次の文字が出るまでのカウントするためのもの
  41. int z;//関数drawString外でも使えるように外にも定義を書いた。zの数値は関係なく、文字列が入った数列がif文により同じ変数zの時にframe[z]と同じになるまで+1されていったり、+2バイトor+1バイトされていくため、
  42. //文字が一文字ずつ入っていく、なんでzの変数に値を入れて動かす必要がないのだ。ちなみにfor (z = 0; z < 3; ++z)で書いてしまうとキーAを押した際のif文に関係なく関数drawStringの最初のzどこかに値が入っただけで繰り返しを開始してしまうため、今回のように同じ変数zの時にフレームを利用して描画するようにした。
  43. char c = str[z][posmozi[z]];//関数drawString外でも使えるように外にも定義を書いた。
  44.  
  45.  
  46. void drawString(int z, int x, int y, int color)
  47. {
  48.     c = str[z][posmozi[z]];//posmozi[z]
  49.     if (countS[z] == 0 && c != '\0')
  50.         posmozi[z] += IsDBCSLeadByte(c) ? 2 : 1;
  51.     if (++countS[z] == frame[z]) countS[z] = 0;
  52.     DrawFormatString(x, y, color, "%.*s", posmozi[z], str[z]);
  53.     DrawFormatString(300, 300, (0,0,255), "countS[0]は%d", countS[0]);
  54. }
  55.  
  56. const char* str2[2] = { "どんな映画が好きなんですか?","申し訳ございません! " };//ここで文字を直接書いてるので、この文字のバイト数が各posmozi[]に入るだけ
  57. int frame2[2] = { 10,10 };//次の一文字が出るまでのカウンタとして働いている、ここの数値を変えることで文字が一文字ずつ出るまでの間隔を設定できる。
  58. int posmozi2[20];//文字のバイト数が入る箱を表している。
  59. int countS2[2];//次の文字が出るまでのカウントするためのもの
  60. int z2;//関数drawString外でも使えるように外にも定義を書いた。zの数値は関係なく、文字列が入った数列がif文により同じ変数zの時にframe[z]と同じになるまで+1されていったり、+2バイトor+1バイトされていくため、
  61. //文字が一文字ずつ入っていく、なんでzの変数に値を入れて動かす必要がないのだ。ちなみにfor (z = 0; z < 3; ++z)で書いてしまうとキーAを押した際のif文に関係なく関数drawStringの最初のzどこかに値が入っただけで繰り返しを開始してしまうため、今回のように同じ変数zの時にフレームを利用して描画するようにした。
  62. char c2 = str[z2][posmozi[z2]];//関数drawString外でも使えるように外にも定義を書いた。
  63.  
  64. void drawString2(int z2, int x, int y, int color)
  65. {
  66.     c = str2[z2][posmozi2[z2]];//posmozi[z2]
  67.     if (countS2[z2] == 0 && c2 != '\0')
  68.         posmozi2[z2] += IsDBCSLeadByte(c2) ? 2 : 1;
  69.     if (++countS2[z2] == frame2[z2]) countS2[z2] = 0;
  70.     DrawFormatString(x, y, color, "%.*s", posmozi2[z2], str2[z2]);
  71.     DrawFormatString(300, 400, (0, 0, 255), "countS2[0]は%d", countS2[0]);
  72. }
  73.  
  74.  
  75. int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
  76. {
  77.    
  78.  
  79.     SetGraphMode(1500, 780, 32);         // ウィンドウの大きさを指定
  80.     ChangeWindowMode(TRUE);             // 全画面ではなくウインドウを使用
  81.     // DXライブラリの初期化
  82.     if (DxLib_Init() == -1) return -1;
  83.     SetFontSize(42);                             //サイズを42に変更
  84.     // 描画先を裏にする
  85.     SetDrawScreen(DX_SCREEN_BACK);
  86.  
  87.     // キー入力ハンドルを作る(キャンセルなし全角文字有り数値入力じゃなし)
  88.     //MakeKeyInputは開発者の方が一回呼び出せば使えるように作ったのでループ内には書かない。
  89.     InputHandle = MakeKeyInput(50, FALSE, FALSE, FALSE);
  90.  
  91.     // 作成したキー入力ハンドルをアクティブにする
  92.     SetActiveKeyInput(InputHandle);
  93.  
  94.     // キー入力終了待ちループ
  95.     // (ProcessMessageをループごとに行う)
  96.    
  97.         while (ProcessMessage() == 0)
  98.         {
  99.  
  100.             // 画面の初期化
  101.             ClearDrawScreen();
  102.  
  103.  
  104.             //まずは描画する部分から作る。
  105.             // 入力モードを描画
  106.             DrawKeyInputModeString(640, 480);
  107.             // 入力途中の文字列を描画
  108.             DrawKeyInputString(0, 0, InputHandle);
  109.  
  110.  
  111.           //その後にif文での分岐を考える。
  112.             // 入力が終了している場合は終了
  113.             //ループ内とは言えエンターキー一回でCheckKeyInputが呼べればいい。
  114.            //エンターキーが押されていないとき?の部分。
  115.             if (CheckKeyInput(InputHandle) != 0) {
  116.                
  117.                 // 入力された文字列を取得
  118.                char buffer[256];//
  119.  
  120.                // 入力された文字列を取得
  121.                GetKeyInputString(buffer, InputHandle);
  122.                input = buffer;
  123.            
  124.                
  125.                 DrawString(0, 0, input.c_str(), GetColor(255, 255, 255));
  126.  
  127.  
  128.  
  129.                
  130.                  
  131.                     /* 配列の要素を出力 */
  132.                     for (i = 0; i < 3; ++i) {
  133.                         if (strcmp(input.c_str(), "3") == 0) {
  134.                           //  message = "どんな映画が好きなんですか?";
  135.                             konnnitiwasound = LoadSoundMem("line-girl1-konnichiha1.mp3");
  136.                             PlaySoundMem(konnnitiwasound, DX_PLAYTYPE_BACK);
  137.  
  138.                             ++mozicount;
  139.                         }
  140.                     }
  141.  
  142.  
  143.                
  144.                
  145.                 //duration = 1;
  146.                 // 再度インプットハンドルをアクティブにする
  147.                 SetActiveKeyInput(InputHandle);
  148.                 // 入力文字列を初期化する
  149.                 SetKeyInputString("", InputHandle);
  150.              
  151.             }
  152.          
  153.           //  DrawFormatString(100, 150, GetColor(255, 255, 0), "ProcessMessage()は%d,modoruは%d", ProcessMessage(), modoru);
  154.             DrawFormatString(0, 150, GetColor(255, 255, 0), "zは%d,z2は%d,konnnitiwaは%d,sitaidouは%d,mozicountは%d",z, z2,konnnitiwa, sitaidou, mozicount);
  155.             DrawFormatString(0, 250, GetColor(255, 255, 0), "mozicount2は%d,input.c_str()は%d,  LEFTmarkは%d", mozicount2, input.c_str(), LEFTmark);
  156.  
  157.             //新しい言葉の処理
  158.             if (rireki == 0) {
  159.                 //文字カウントが1の時
  160.                 if (mozicount > 0 && mozicount < 2) {
  161.                     drawString(z, 10, 100, GetColor(5, 255, 255));
  162.  
  163.                 }
  164.             }
  165.             if (rireki == 0) {
  166.                 //文字カウントが2の時
  167.                 if (mozicount > 1 && mozicount < 3) {
  168.                     drawString2(z2, 10, 100, GetColor(255, 255, 255));
  169.                  
  170.                     drawString(z, 10, 100+50, GetColor(5, 255, 255));
  171.  
  172.                 }
  173.             }
  174.             //文字カウントが3の時
  175.             if (mozicount > 2&&mozicount < 4) {
  176.                 drawString2(z2, 10, 150+50, GetColor(255, 255, 255));
  177.                 rireki = 1;
  178.  
  179.             }
  180.             // 裏画面の内容を表画面に反映させる
  181.             ScreenFlip();
  182.  
  183.  
  184.  
  185.  
  186.  
  187.         }
  188.        
  189.     // 用済みのインプットハンドルを削除する
  190.     DeleteKeyInput(InputHandle);
  191.  
  192.     // 画面の初期化
  193.     ClearDrawScreen();
  194.    
  195.     // 裏画面の内容を表画面に反映させる
  196.     ScreenFlip();
  197.  
  198.     // キー入力待ち
  199.    // WaitKey();
  200.  
  201.     //ループないやループから出た後で何かしらの問題が発生したら終了する。
  202.     // DXライブラリの使用終了
  203.     DxLib_End();
  204.  
  205.     // 終了
  206.     return 0;
  207. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement