Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "DxLib.h"
- #include <string>
- int konnnitiwasound = 0;
- int situreisimasitasound = 0;
- char String[256];
- char StringA[256];
- int InputHandle;
- int InputHandleA;
- int modoru = 0;
- std::string input;
- std::string message;
- std::string messageA;
- char deta1[] = { "私" };
- char deta2[] = { "は" };
- char deta3[] = { "映画" };
- char deta4[] = { "が" };
- char deta5[] = { "好き" };
- int i;
- int a[3] = { 3, 4, 5 };
- int duration = 0;
- int konnnitiwa = 0;
- int sitaidou = 0;
- int sitaidouA = 0;
- int mozicount = 0;
- int mozicount2 = 0;
- int mozicount3 = 0;
- int rireki = 0;
- int rireki2 = 0;
- int LEFTmark = 0;
- const char* str[2] = { "どんな映画が好きなんですか?","申し訳ございません! "};//ここで文字を直接書いてるので、この文字のバイト数が各posmozi[]に入るだけ
- int frame[2] = { 10,10};//次の一文字が出るまでのカウンタとして働いている、ここの数値を変えることで文字が一文字ずつ出るまでの間隔を設定できる。
- int posmozi[20];//文字のバイト数が入る箱を表している。
- int countS[2];//次の文字が出るまでのカウントするためのもの
- int z;//関数drawString外でも使えるように外にも定義を書いた。zの数値は関係なく、文字列が入った数列がif文により同じ変数zの時にframe[z]と同じになるまで+1されていったり、+2バイトor+1バイトされていくため、
- //文字が一文字ずつ入っていく、なんでzの変数に値を入れて動かす必要がないのだ。ちなみにfor (z = 0; z < 3; ++z)で書いてしまうとキーAを押した際のif文に関係なく関数drawStringの最初のzどこかに値が入っただけで繰り返しを開始してしまうため、今回のように同じ変数zの時にフレームを利用して描画するようにした。
- char c = str[z][posmozi[z]];//関数drawString外でも使えるように外にも定義を書いた。
- void drawString(int z, int x, int y, int color)
- {
- c = str[z][posmozi[z]];//posmozi[z]
- if (countS[z] == 0 && c != '\0')
- posmozi[z] += IsDBCSLeadByte(c) ? 2 : 1;
- if (++countS[z] == frame[z]) countS[z] = 0;
- DrawFormatString(x, y, color, "%.*s", posmozi[z], str[z]);
- DrawFormatString(300, 300, (0,0,255), "countS[0]は%d", countS[0]);
- }
- const char* str2[2] = { "どんな映画が好きなんですか?","申し訳ございません! " };//ここで文字を直接書いてるので、この文字のバイト数が各posmozi[]に入るだけ
- int frame2[2] = { 10,10 };//次の一文字が出るまでのカウンタとして働いている、ここの数値を変えることで文字が一文字ずつ出るまでの間隔を設定できる。
- int posmozi2[20];//文字のバイト数が入る箱を表している。
- int countS2[2];//次の文字が出るまでのカウントするためのもの
- int z2;//関数drawString外でも使えるように外にも定義を書いた。zの数値は関係なく、文字列が入った数列がif文により同じ変数zの時にframe[z]と同じになるまで+1されていったり、+2バイトor+1バイトされていくため、
- //文字が一文字ずつ入っていく、なんでzの変数に値を入れて動かす必要がないのだ。ちなみにfor (z = 0; z < 3; ++z)で書いてしまうとキーAを押した際のif文に関係なく関数drawStringの最初のzどこかに値が入っただけで繰り返しを開始してしまうため、今回のように同じ変数zの時にフレームを利用して描画するようにした。
- char c2 = str[z2][posmozi[z2]];//関数drawString外でも使えるように外にも定義を書いた。
- void drawString2(int z2, int x, int y, int color)
- {
- c = str2[z2][posmozi2[z2]];//posmozi[z2]
- if (countS2[z2] == 0 && c2 != '\0')
- posmozi2[z2] += IsDBCSLeadByte(c2) ? 2 : 1;
- if (++countS2[z2] == frame2[z2]) countS2[z2] = 0;
- DrawFormatString(x, y, color, "%.*s", posmozi2[z2], str2[z2]);
- DrawFormatString(300, 400, (0, 0, 255), "countS2[0]は%d", countS2[0]);
- }
- int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
- {
- SetGraphMode(1500, 780, 32); // ウィンドウの大きさを指定
- ChangeWindowMode(TRUE); // 全画面ではなくウインドウを使用
- // DXライブラリの初期化
- if (DxLib_Init() == -1) return -1;
- SetFontSize(42); //サイズを42に変更
- // 描画先を裏にする
- SetDrawScreen(DX_SCREEN_BACK);
- // キー入力ハンドルを作る(キャンセルなし全角文字有り数値入力じゃなし)
- //MakeKeyInputは開発者の方が一回呼び出せば使えるように作ったのでループ内には書かない。
- InputHandle = MakeKeyInput(50, FALSE, FALSE, FALSE);
- // 作成したキー入力ハンドルをアクティブにする
- SetActiveKeyInput(InputHandle);
- // キー入力終了待ちループ
- // (ProcessMessageをループごとに行う)
- while (ProcessMessage() == 0)
- {
- // 画面の初期化
- ClearDrawScreen();
- //まずは描画する部分から作る。
- // 入力モードを描画
- DrawKeyInputModeString(640, 480);
- // 入力途中の文字列を描画
- DrawKeyInputString(0, 0, InputHandle);
- //その後にif文での分岐を考える。
- // 入力が終了している場合は終了
- //ループ内とは言えエンターキー一回でCheckKeyInputが呼べればいい。
- //エンターキーが押されていないとき?の部分。
- if (CheckKeyInput(InputHandle) != 0) {
- // 入力された文字列を取得
- char buffer[256];//
- // 入力された文字列を取得
- GetKeyInputString(buffer, InputHandle);
- input = buffer;
- DrawString(0, 0, input.c_str(), GetColor(255, 255, 255));
- /* 配列の要素を出力 */
- for (i = 0; i < 3; ++i) {
- if (strcmp(input.c_str(), "3") == 0) {
- // message = "どんな映画が好きなんですか?";
- konnnitiwasound = LoadSoundMem("line-girl1-konnichiha1.mp3");
- PlaySoundMem(konnnitiwasound, DX_PLAYTYPE_BACK);
- ++mozicount;
- }
- }
- //duration = 1;
- // 再度インプットハンドルをアクティブにする
- SetActiveKeyInput(InputHandle);
- // 入力文字列を初期化する
- SetKeyInputString("", InputHandle);
- }
- // DrawFormatString(100, 150, GetColor(255, 255, 0), "ProcessMessage()は%d,modoruは%d", ProcessMessage(), modoru);
- DrawFormatString(0, 150, GetColor(255, 255, 0), "zは%d,z2は%d,konnnitiwaは%d,sitaidouは%d,mozicountは%d",z, z2,konnnitiwa, sitaidou, mozicount);
- DrawFormatString(0, 250, GetColor(255, 255, 0), "mozicount2は%d,input.c_str()は%d, LEFTmarkは%d", mozicount2, input.c_str(), LEFTmark);
- //新しい言葉の処理
- if (rireki == 0) {
- //文字カウントが1の時
- if (mozicount > 0 && mozicount < 2) {
- drawString(z, 10, 100, GetColor(5, 255, 255));
- }
- }
- if (rireki == 0) {
- //文字カウントが2の時
- if (mozicount > 1 && mozicount < 3) {
- drawString2(z2, 10, 100, GetColor(255, 255, 255));
- drawString(z, 10, 100+50, GetColor(5, 255, 255));
- }
- }
- //文字カウントが3の時
- if (mozicount > 2&&mozicount < 4) {
- drawString2(z2, 10, 150+50, GetColor(255, 255, 255));
- rireki = 1;
- }
- // 裏画面の内容を表画面に反映させる
- ScreenFlip();
- }
- // 用済みのインプットハンドルを削除する
- DeleteKeyInput(InputHandle);
- // 画面の初期化
- ClearDrawScreen();
- // 裏画面の内容を表画面に反映させる
- ScreenFlip();
- // キー入力待ち
- // WaitKey();
- //ループないやループから出た後で何かしらの問題が発生したら終了する。
- // DXライブラリの使用終了
- DxLib_End();
- // 終了
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement