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