Advertisement
Guest User

Untitled

a guest
Jan 16th, 2020
207
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 8.29 KB | None | 0 0
  1. #include "DxLib.h"
  2. #include "key.h"
  3. #include "player2.h"
  4. #include "talk.h"
  5. #include "playerhennsuu.h"
  6. #include "taitolh.h"
  7. #include "countine.h"
  8. #pragma warning(disable: 4996)
  9.  
  10. int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
  11. {
  12.     typedef struct {
  13.         int Seen;
  14.     }SaveData_t;
  15.  
  16.     SetGraphMode(1770, 1580, 32);      // ウィンドウの大きさを指定
  17.     ChangeWindowMode(TRUE);             // 全画面ではなくウインドウを使用
  18.     if (DxLib_Init() == -1) return -1;  // DXライブラリ初期化処理
  19.     SetDrawScreen(DX_SCREEN_BACK);      // 裏画面を使用する設定
  20.  
  21.     // ウインドウのサイズを手動ではできず、且つウインドウのサイズに合わせて拡大もしないようにする
  22.     SetWindowSizeChangeEnableFlag(FALSE, FALSE);
  23.  
  24.     // 画面サイズは最大の780*680にしておく
  25.    
  26.  
  27.     // 最初は 640x480 にしておく
  28.    
  29.     //SetWindowSize(980, 980);
  30.     battle_Initialize();//バトルのために読み込む画像
  31.    
  32.     init_stage(); // stage, pos の初期化
  33.    
  34.     while (ProcessMessage() == 0) {
  35.         gpUpdateKey();
  36.        
  37.         //☆会話の文字を一文字ずつ表示するためのプログラム。
  38.         //if (++t == 60 * 9) { t = 60 * 9; } // 6秒ごとにリセット
  39.  
  40.         if (startmark >= 2 && ++startmark > 50) {//taitolh.hの関数がtaitol()が終わった後はこのwhileの部分から消えるので値が増えていかない、なのでここに直接書いた。
  41.             Seen = 1; startmark = 0;
  42.             if (Key[KEY_INPUT_A] == 1) {
  43.                 Seen = 0;
  44.             }
  45.         }
  46.  
  47.         if (++t == 6 * 60) {
  48.             t = 0;
  49.         }
  50.    
  51.        
  52.        
  53.         if (Seen == 2) {
  54.             Player_Update();
  55.             //init_stage();
  56.         //  if (enemyHP < 1) { Seen = 1; }//敵のHPが0になるとSeenを0にしたことから関数Player_Update()から離れる。なので画面はメインのプログラムに返ってくる。
  57.             if (playerHP <0|| playerHP==0) { playerHP = 0;  ++playerHPframe;//これでplayerHPframeが1だけ繰り上がる。固定ではないので次のif文に進める。
  58.             }
  59.         }
  60.         if (playerHPframe > 0 && playerHPframe > 100) { Seen = 1; countinue = 1; playerHPframe = 0; }
  61.         //↓多分、if (start > 0 && ++start < 200)と同じ原因で上がるべき条件の時に上がらないのと同じでうまく機能していない
  62.         //自分と敵がある一定の時間は初期値の位置に居続けるようにするために書いた。こいつがないと開始よりも前に敵が移動してきたりする。
  63.    
  64.         //これより以下は描画するためのプログラム
  65.         ClearDrawScreen();  // 裏画面を
  66.         if (tai == 1 && talk >= 0 && Seen >= 0) { taitol(); }//条件はなくてもいいが条件があればセーブしてtalkやSeenの変数がどんな値でもセーブの変数とtalkやSeenの変数からタイトルが評し出来る。
  67.  
  68.         if (Seen == 1) { talkdrow();}
  69.         if (Seen == 2) {
  70.             gameovercolorlock = 0;//主人公が死んでしまったを消すための変数
  71.             Player_Draw(); if (preframe > 0 && ++preframe < 9)preframe = 9;
  72.             if (preframeA > 0 && ++preframeA < 9)preframeA = 9;
  73.             if (preframeB > 0 && ++preframeB < 9)preframeB = 9;
  74.         if (preframeC > 0 && ++preframeC < 9)preframeC= 9;
  75.         }
  76.         //if (Seen == 2) { void game_clear(); }
  77.         DrawFormatString(1, 250, GetColor(255, 255, 0), "superは%d,lockは%d,startは%d,addattacktimelockは%d,startmarkは%d,", super,lock,countinuekeylock,start, addattacktimelock, startmark);
  78.         //DrawFormatString(100, 150, GetColor(255, 255, 0), "yomikomiは%d,buf_r[yomikomi]は%d", yomikomi, buf_r[yomikomi]);
  79.         //DrawFormatString(1, 50, GetColor(255, 255, 0), "fortimeframeは%d,inotigoicountは%d", fortimeframe,inotigoicount);
  80.         DrawFormatString(300, 640, GetColor(255, 255, 0), "startは%d,preframeは%d", start, preframe);
  81.         //DrawFormatString(300, 500, GetColor(255, 255, 0), "stayhereは%dcountinueは%d,", stayhere, countinue);
  82.  
  83.         //クリア後の画面に続く
  84.         if (mark == 0&&enemyHP < 1) { Seen = 0;//Seenの値を初期値に戻す。
  85.         talk = 3;enemyHP = 0; mark = 1;
  86.         enemymovelock = 1;//これで敵は攻撃してこなくなる
  87.         }
  88.  
  89.         //コンティニュー画面
  90.         if(countinue == 1) {
  91.             countinuekannsuu();
  92.         }
  93.         //if (enemyHP > 0 && enemyHP < 100) { Seen = 0; inotigoi();}//中断した敵のHPを基に戻して
  94.         //if (enemyHP < 0) { enemyHP = 0; }
  95.  
  96.         //主人公が死んだ後の色の発生、ちなみに上のif (playerHP <0|| playerHP==0)の部分も主人公のHPに関してのプログラムにより関数が呼ばれる。
  97.         if (playerHP <= 0) {
  98.             Seen = 0;//死んだ瞬間に説得しても分岐などの文字が描画されないように
  99.             gameovercolor = gameovercolor + 1;
  100.             DrawBox(0, 0, 1770, 1580, GetColor(gameovercolor,0,0), TRUE);// 画面全体を希望の色で塗りつぶす}//プレイヤーが死んだ場合の描画
  101.             if (gameovercolor > 160) { gameovercolor = 160; gameovercolorlock = 1; playerHP = 1; }
  102.             DrawFormatString(100, 300, GetColor(255, 255, 0), "gameovercolorは%d", gameovercolor);
  103.         }
  104.         if (gameovercolorlock == 1) {
  105.             gameovercolor = gameovercolor - 1;
  106.             gameovercolor1 = gameovercolor;
  107.             DrawBox(0, 0, 1770, 1580, GetColor(gameovercolor1, 0, 0), TRUE);
  108.             DrawFormatString(100, 300, GetColor(255, 255, 0), "gameovercolor1は%d,gameovercolorlockは%d", gameovercolor, gameovercolorlock);
  109.         }
  110.         if (gameovercolor1 < 0) {
  111.             gameovercolor1 = 0; gameovercolor = 0;
  112.             DrawBox(0, 0, 1770, 1580, GetColor(0, 0, 0), TRUE);
  113.             gameovercolorlock = 2;
  114.             DrawFormatString(100, 300, GetColor(255, 255, 0), "gameovercolor1は%d", gameovercolor);
  115.         }
  116.         if (gameovercolorlock == 2) {
  117.             talkdrow2();//上のif (playerHP <0|| playerHP==0)の部分も主人公のHPに関してのプログラムにより関数が呼ばれる。
  118.         }
  119.         //if (enemyHP2 < 1) { enemyHP2 = 0;}
  120.         if (Seen == 3) {
  121.             settokutalk();//ここに関数をいれる。
  122.             //if (Key[KEY_INPUT_N] == 1) {
  123.             //  Seen = 2;
  124.             //}
  125.         }
  126.         if (Seen == 4) {
  127.             DrawFormatString(100, 400, RED, "2回目の説得失敗"); if (Key[KEY_INPUT_N] == 1) {
  128.                 Seen = 2;
  129.             }
  130.         }
  131.         if (Seen == 6) { bunnkiA(); }
  132.  
  133.         //クリア後の画面
  134.         if (mark == 1&&enemyHP == 0) { ++fortimeframe;
  135.         }
  136.         if (fortimeframe > 0 && fortimeframe < 100) {
  137.             DrawFormatString(100, 200, GetColor(255, 255, 255), "GAME CLEAR");
  138.             talk = 0;
  139.         }
  140.         if (fortimeframe > 100) {
  141.             mark = 2;
  142.             fortimeframe = 0;
  143.             Seen = 8;
  144.         }
  145.         if (Seen == 8) {
  146.             enemyHP = 1;
  147.             mark = 0;
  148.             DrawFormatString(100, 400, RED, "ここまでのデータをセーブしますか?");
  149.             DrawFormatString(100, 500, RED, "キーYでセーブ");
  150.             DrawFormatString(100, 600, RED, "キーNでこのままセーブせずに進む");
  151.             if (Key[KEY_INPUT_Y] == 1) {
  152.                 mark = 1;
  153.                 ///FILE* fp;
  154.                 //SaveData_t Data = { 8 };
  155.                 ///fp = fopen("test.dat", "wb");
  156.                 ///fprintf(fp, "8");//ちゃんとバッチファイルに書き込めている。
  157.                 ///fclose(fp);
  158.                 //  for (i = 0; i < 1; i++)
  159.                     //buf_w[1] = 8;
  160.                     //if (!(fp = fopen(filename, "wb")))
  161.                         //return 0;
  162.                     //if (fwrite(buf_w, sizeof(int), 1, fp) != 1) {
  163.                         //fclose(fp);
  164.                         //return 0;
  165.                     //}
  166.                 FILE* file;                                     // ファイルポインタ(出力用)
  167.                 file = fopen("test.dat", "w");      // ファイルを書き込み用にオープン(開く)
  168.                 if (file == NULL) {                             // オープンに失敗した場合
  169.                     printf("ファイルが開けません。¥n");            // エラーメッセージを出して
  170.                     exit(1);                                    // 異常終了
  171.                 }
  172.                 //  ファイルにデータを書き込む
  173.                 fprintf(file, "Seen = 8");       // ファイルに書く
  174.                 fclose(file);                       // ファイルをクローズ(閉じる)
  175.  
  176.                 Seen = 9;
  177.             }
  178.         }
  179.        
  180.  
  181.         if(Seen==9){ cleartalk1(); }
  182.         //続きのデータがない場合の描画
  183.         if (last==1) {
  184.             tai = 0;
  185.             DrawFormatString(100, 400, GetColor(255, 255, 0), "セーブデータがありません。");
  186.             DrawFormatString(100, 450, GetColor(255, 255, 0), "もう一度スペースキーを押して戻ってください");
  187.             if (Key[KEY_INPUT_SPACE] == 1) {
  188.                 mark = 1;
  189.                 last = 0;
  190.                 tai = 1;
  191.             }
  192.         }
  193.        
  194.  
  195.         ScreenFlip();  // 裏画面を表画面に反映
  196.     }
  197.  
  198.    
  199.    
  200.  
  201.     DxLib_End();  // DXライブラリ使用の終了処理
  202.     return 0;  // ソフトの終了
  203.  
  204. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement