Advertisement
Guest User

Untitled

a guest
Nov 20th, 2019
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 3.13 KB | None | 0 0
  1. #include <DxLib.h>
  2.  
  3. const char* str[3] = { "あいうabc", "0123456789", "ABCDEFG" };
  4. int frame[3] = { 50, 30, 40 };//一文字ずつ描画する上でのカウントするためのもの。
  5. int pos[3];//文字列の3つの列に対応した文字列の一文字ずつのバイト数が入る3つの箱をここで用意した。
  6. int count[3];//一文字ずつ描画するまでの間隔を表す。
  7.  
  8. void drawString(int i, int x, int y, int color)
  9. {
  10.     char c = str[i][pos[i]];//文字列を入れている配列str[3]の文字列の最初の文字のバイト数を一文字ずつ入るpos[i]から実際の文字を表す変数cに入れる。
  11.                             //
  12.     //関数drawStringのiを引数に、そのiの数値はstr[i][pos[i]]に入り、その変数iの数値により文字列の入っているstr[i]から一文字ずつ配列pos[i]に入り、それを変数cとした。
  13.     //そのままDrawFormatStringでcを扱いたいが、描画関数DrawFormatStringはchar型は扱えないので引数にはpos[i], str[i]を取り、それがchar cになり結果的に文字が描画できるようにした。なので関数の引数の部分に
  14.     if (count[i] == 0 && c != '\0')//ここの条件文のc != '\0'により、文字列の最後でなければ
  15.         pos[i] += IsDBCSLeadByte(c) ? 2 : 1;//2バイトを加える、最後が¥0の場合は1バイトを加える。
  16.     if (++count[i] == frame[i]) count[i] = 0;
  17.     DrawFormatString(x, y, color, "%.*s", pos[i], str[i]);
  18. }
  19.  
  20. int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
  21. {
  22.     SetFontSize(25);                          //サイズを64に変更 ???
  23.     SetFontThickness(10);                     //太さを8に変更 ???
  24.     ChangeFont("MS 明朝");                  //種類をMS明朝に変更
  25.     ChangeFontType(DX_FONTTYPE_ANTIALIASING); //アンチエイリアスフォント
  26.  
  27.     SetGraphMode(780, 680, 32);         // ウィンドウの大きさを指定
  28.     ChangeWindowMode(TRUE);             // 全画面ではなくウインドウを使用
  29.     if (DxLib_Init() == -1) return -1;  // DXライブラリ初期化処理
  30.     SetDrawScreen(DX_SCREEN_BACK);      // 裏画面を使用する設定
  31.  
  32.     SetWindowSizeChangeEnableFlag(FALSE, FALSE);
  33.  
  34.     int Green = GetColor(0, 255, 0);
  35.     int Yellow = GetColor(255, 255, 0);
  36.     int White = GetColor(255, 255, 255);
  37.  
  38.     int t = 0;
  39.     while (!ScreenFlip() && !ProcessMessage() && !ClearDrawScreen()) {
  40.         drawString(0, 100, 500, Green);//箱pos[0]に一文字すつ入るため
  41.         drawString(1, 100, 530, Yellow);
  42.         drawString(2, 500, 530, White);
  43.         if (++t == 6 * 60) {
  44.             t = 0;
  45.             for (int i = 0; i < 3; i++) pos[i] = count[i] = 0;//6秒経ったら、一文字ずつ入る箱を表すpos[i]3つと一文字ずつ描画するための間隔を表すcount[i]を0にする。
  46.         }
  47.         for (int i = 0; i < 3; i++) {
  48.             DrawFormatString(300+i*50, 400, Green, "%d", pos[i]);//ここに追加、関数の中の変数pos[]の中身を描画した。
  49.         }
  50.             for (int i = 0; i < 3; i++) {
  51.                 DrawFormatString(300 + i * 50, 500, Green, "%d", frame[i]);//ここに追加、関数の中の変数pos[]の中身を描画した。
  52.             }
  53.     }
  54.  
  55.     DxLib_End(); // DXライブラリ終了処理
  56.     return 0;
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement