Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "DxLib.h"
- #include "key.h"
- #include "player2.h"
- #include "talk.h"
- #include "playerhennsuu.h"
- #include "taitolh.h"
- #include "countine.h"
- #pragma warning(disable: 4996)
- int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
- {
- typedef struct {
- int Seen;
- }SaveData_t;
- SetGraphMode(1770, 1580, 32); // ウィンドウの大きさを指定
- ChangeWindowMode(TRUE); // 全画面ではなくウインドウを使用
- if (DxLib_Init() == -1) return -1; // DXライブラリ初期化処理
- SetDrawScreen(DX_SCREEN_BACK); // 裏画面を使用する設定
- // ウインドウのサイズを手動ではできず、且つウインドウのサイズに合わせて拡大もしないようにする
- SetWindowSizeChangeEnableFlag(FALSE, FALSE);
- // 画面サイズは最大の780*680にしておく
- // 最初は 640x480 にしておく
- //SetWindowSize(980, 980);
- battle_Initialize();//バトルのために読み込む画像
- init_stage(); // stage, pos の初期化
- while (ProcessMessage() == 0) {
- gpUpdateKey();
- //☆会話の文字を一文字ずつ表示するためのプログラム。
- //if (++t == 60 * 9) { t = 60 * 9; } // 6秒ごとにリセット
- if (startmark >= 2 && ++startmark > 50) {//taitolh.hの関数がtaitol()が終わった後はこのwhileの部分から消えるので値が増えていかない、なのでここに直接書いた。
- Seen = 1; startmark = 0;
- if (Key[KEY_INPUT_A] == 1) {
- Seen = 0;
- }
- }
- if (++t == 6 * 60) {
- t = 0;
- }
- if (Seen == 2) {
- Player_Update();
- //init_stage();
- // if (enemyHP < 1) { Seen = 1; }//敵のHPが0になるとSeenを0にしたことから関数Player_Update()から離れる。なので画面はメインのプログラムに返ってくる。
- if (playerHP <0|| playerHP==0) { playerHP = 0; ++playerHPframe;//これでplayerHPframeが1だけ繰り上がる。固定ではないので次のif文に進める。
- }
- }
- if (playerHPframe > 0 && playerHPframe > 100) { Seen = 1; countinue = 1; playerHPframe = 0; }
- //↓多分、if (start > 0 && ++start < 200)と同じ原因で上がるべき条件の時に上がらないのと同じでうまく機能していない
- //自分と敵がある一定の時間は初期値の位置に居続けるようにするために書いた。こいつがないと開始よりも前に敵が移動してきたりする。
- //これより以下は描画するためのプログラム
- ClearDrawScreen(); // 裏画面を
- if (tai == 1 && talk >= 0 && Seen >= 0) { taitol(); }//条件はなくてもいいが条件があればセーブしてtalkやSeenの変数がどんな値でもセーブの変数とtalkやSeenの変数からタイトルが評し出来る。
- if (Seen == 1) { talkdrow();}
- if (Seen == 2) {
- gameovercolorlock = 0;//主人公が死んでしまったを消すための変数
- Player_Draw(); if (preframe > 0 && ++preframe < 9)preframe = 9;
- if (preframeA > 0 && ++preframeA < 9)preframeA = 9;
- if (preframeB > 0 && ++preframeB < 9)preframeB = 9;
- if (preframeC > 0 && ++preframeC < 9)preframeC= 9;
- }
- //if (Seen == 2) { void game_clear(); }
- DrawFormatString(1, 250, GetColor(255, 255, 0), "superは%d,lockは%d,startは%d,addattacktimelockは%d,startmarkは%d,", super,lock,countinuekeylock,start, addattacktimelock, startmark);
- //DrawFormatString(100, 150, GetColor(255, 255, 0), "yomikomiは%d,buf_r[yomikomi]は%d", yomikomi, buf_r[yomikomi]);
- //DrawFormatString(1, 50, GetColor(255, 255, 0), "fortimeframeは%d,inotigoicountは%d", fortimeframe,inotigoicount);
- DrawFormatString(300, 640, GetColor(255, 255, 0), "startは%d,preframeは%d", start, preframe);
- //DrawFormatString(300, 500, GetColor(255, 255, 0), "stayhereは%dcountinueは%d,", stayhere, countinue);
- //クリア後の画面に続く
- if (mark == 0&&enemyHP < 1) { Seen = 0;//Seenの値を初期値に戻す。
- talk = 3;enemyHP = 0; mark = 1;
- enemymovelock = 1;//これで敵は攻撃してこなくなる
- }
- //コンティニュー画面
- if(countinue == 1) {
- countinuekannsuu();
- }
- //if (enemyHP > 0 && enemyHP < 100) { Seen = 0; inotigoi();}//中断した敵のHPを基に戻して
- //if (enemyHP < 0) { enemyHP = 0; }
- //主人公が死んだ後の色の発生、ちなみに上のif (playerHP <0|| playerHP==0)の部分も主人公のHPに関してのプログラムにより関数が呼ばれる。
- if (playerHP <= 0) {
- Seen = 0;//死んだ瞬間に説得しても分岐などの文字が描画されないように
- gameovercolor = gameovercolor + 1;
- DrawBox(0, 0, 1770, 1580, GetColor(gameovercolor,0,0), TRUE);// 画面全体を希望の色で塗りつぶす}//プレイヤーが死んだ場合の描画
- if (gameovercolor > 160) { gameovercolor = 160; gameovercolorlock = 1; playerHP = 1; }
- DrawFormatString(100, 300, GetColor(255, 255, 0), "gameovercolorは%d", gameovercolor);
- }
- if (gameovercolorlock == 1) {
- gameovercolor = gameovercolor - 1;
- gameovercolor1 = gameovercolor;
- DrawBox(0, 0, 1770, 1580, GetColor(gameovercolor1, 0, 0), TRUE);
- DrawFormatString(100, 300, GetColor(255, 255, 0), "gameovercolor1は%d,gameovercolorlockは%d", gameovercolor, gameovercolorlock);
- }
- if (gameovercolor1 < 0) {
- gameovercolor1 = 0; gameovercolor = 0;
- DrawBox(0, 0, 1770, 1580, GetColor(0, 0, 0), TRUE);
- gameovercolorlock = 2;
- DrawFormatString(100, 300, GetColor(255, 255, 0), "gameovercolor1は%d", gameovercolor);
- }
- if (gameovercolorlock == 2) {
- talkdrow2();//上のif (playerHP <0|| playerHP==0)の部分も主人公のHPに関してのプログラムにより関数が呼ばれる。
- }
- //if (enemyHP2 < 1) { enemyHP2 = 0;}
- if (Seen == 3) {
- settokutalk();//ここに関数をいれる。
- //if (Key[KEY_INPUT_N] == 1) {
- // Seen = 2;
- //}
- }
- if (Seen == 4) {
- DrawFormatString(100, 400, RED, "2回目の説得失敗"); if (Key[KEY_INPUT_N] == 1) {
- Seen = 2;
- }
- }
- if (Seen == 6) { bunnkiA(); }
- //クリア後の画面
- if (mark == 1&&enemyHP == 0) { ++fortimeframe;
- }
- if (fortimeframe > 0 && fortimeframe < 100) {
- DrawFormatString(100, 200, GetColor(255, 255, 255), "GAME CLEAR");
- talk = 0;
- }
- if (fortimeframe > 100) {
- mark = 2;
- fortimeframe = 0;
- Seen = 8;
- }
- if (Seen == 8) {
- enemyHP = 1;
- mark = 0;
- DrawFormatString(100, 400, RED, "ここまでのデータをセーブしますか?");
- DrawFormatString(100, 500, RED, "キーYでセーブ");
- DrawFormatString(100, 600, RED, "キーNでこのままセーブせずに進む");
- if (Key[KEY_INPUT_Y] == 1) {
- mark = 1;
- ///FILE* fp;
- //SaveData_t Data = { 8 };
- ///fp = fopen("test.dat", "wb");
- ///fprintf(fp, "8");//ちゃんとバッチファイルに書き込めている。
- ///fclose(fp);
- // for (i = 0; i < 1; i++)
- //buf_w[1] = 8;
- //if (!(fp = fopen(filename, "wb")))
- //return 0;
- //if (fwrite(buf_w, sizeof(int), 1, fp) != 1) {
- //fclose(fp);
- //return 0;
- //}
- FILE* file; // ファイルポインタ(出力用)
- file = fopen("test.dat", "w"); // ファイルを書き込み用にオープン(開く)
- if (file == NULL) { // オープンに失敗した場合
- printf("ファイルが開けません。¥n"); // エラーメッセージを出して
- exit(1); // 異常終了
- }
- // ファイルにデータを書き込む
- fprintf(file, "Seen = 8"); // ファイルに書く
- fclose(file); // ファイルをクローズ(閉じる)
- Seen = 9;
- }
- }
- if(Seen==9){ cleartalk1(); }
- //続きのデータがない場合の描画
- if (last==1) {
- tai = 0;
- DrawFormatString(100, 400, GetColor(255, 255, 0), "セーブデータがありません。");
- DrawFormatString(100, 450, GetColor(255, 255, 0), "もう一度スペースキーを押して戻ってください");
- if (Key[KEY_INPUT_SPACE] == 1) {
- mark = 1;
- last = 0;
- tai = 1;
- }
- }
- ScreenFlip(); // 裏画面を表画面に反映
- }
- DxLib_End(); // DXライブラリ使用の終了処理
- return 0; // ソフトの終了
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement