Advertisement
Guest User

Untitled

a guest
Jan 17th, 2020
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 6.69 KB | None | 0 0
  1. #include "DxLib.h"
  2. #include "key.h"
  3. #pragma warning(disable: 4996)
  4.  
  5. //#include "taitolh.h"
  6. #ifndef DEF_talk_H //二重include防止
  7.  
  8. #define DEF_talk_H
  9.  
  10.  
  11.  
  12.     int RED = GetColor(255, 0, 0);      // 緑の色コードを取得
  13.    
  14.     int talk = 0;
  15.     int talkframe = 0;
  16.     int talkframecount = 0;
  17.     int start = 0;
  18.     int battle = 0;
  19.     int Seen = 0;
  20.     int countchar = 0;
  21.     int Green = GetColor(0, 255, 0);
  22.     int Yellow = GetColor(255, 255, 0);
  23.     int talkbunnkiA = 0;
  24.     //int White = GetColor(255, 255, 255);
  25.  
  26.     int t = 0;
  27.    
  28.     const char* str[3] = { "あいうabc", "0123456789", "ABCDEFG" };//ここで文字を直接書いてるので、この文字のバイト数が各posmozi[]に入るだけ
  29.     int frame[3] = { 5, 5, 40 };//次の一文字が出るまでのカウンタとして働いている、ここの数値を変えることで文字が一文字ずつ出るまでの間隔を設定できる。
  30.     int posmozi[3];//文字のバイト数が入る箱を表している。
  31.     int countS[3];//次の文字が出るまでのカウントするためのもの
  32.  
  33.     int z;//関数drawString外でも使えるように外にも定義を書いた。zの数値は関係なく、文字列が入った数列がif文により同じ変数zの時にframe[z]と同じになるまで+1されていったり、+2バイトor+1バイトされていくため、
  34.     //文字が一文字ずつ入っていく、なんでzの変数に値を入れて動かす必要がないのだ。ちなみにfor (z = 0; z < 3; ++z)で書いてしまうとキーAを押した際のif文に関係なく関数drawStringの最初のzどこかに値が入っただけで繰り返しを開始してしまうため、今回のように同じ変数zの時にフレームを利用して描画するようにした。
  35.     char c = str[z][posmozi[z]];//関数drawString外でも使えるように外にも定義を書いた。
  36.  
  37.     void syokiiti() {
  38.         int enemyX = 4, enemyY = 1;   // 敵の位置
  39.         int playerX = 1, playerY = 1;  // 俺の位置
  40.  
  41.     }
  42.     void drawString(int z, int x, int y, int color)
  43.     {
  44.         char c = str[z][posmozi[z]];//posmozi[z]
  45.         if (countS[z] == 0 && c != '\0')
  46.             posmozi[z] += IsDBCSLeadByte(c) ? 2 : 1;
  47.         if (++countS[z] == frame[z]) countS[z] = 0;
  48.         DrawFormatString(x, y, color, "%.*s", posmozi[z], str[z]);
  49.         DrawFormatString(300, 300, RED, "countS[0]は%d", countS[0]);
  50.     }
  51.  
  52.     void talkdrow() {
  53.         if (talk == 0) {
  54.             if (talk == 0 && posmozi[0] == 9) { if (Key[KEY_INPUT_A] == 1) { ++talk; } }//talkdorwの時にstr1.drawStringが呼ばれているのでこの中身のものも実行されても大丈夫なのでは?
  55.             drawString(0, 100, 500, Green);
  56.         }
  57.        
  58.         if (talk == 1) {
  59.             if (talk == 1 && posmozi[1] == 10) { if (Key[KEY_INPUT_A] == 1) { ++talk; } }
  60.             drawString(1, 100, 500, Yellow);
  61.             start = 1;
  62.         }
  63.         //if (talk == 2) { start = 1; // DrawFormatString(300, 300, RED, "battle startします"); stayhere = 1;
  64.         //}
  65.        
  66.         if (talk == 2) {
  67.            
  68.              mark = 1;//★★★talkが3の時はキーAが押せないように変数で条件を付けた。編集前は上のif (Key[KEY_INPUT_A] == 1)と被ってしまって重複したためかうまく機能しなかった。
  69.              //stayhereを使ってのプログラムもあったが、関数の外のメインにあったためかif (Key[KEY_INPUT_A] == 1)が働かなかったのか、一定のままだった。しかし出来れば関数内でまとめたいので左のように書いた。
  70.             if (start > 0 && ++start <= 150) {
  71.                 DrawFormatString(300, 300, RED, "battle startします");
  72.                 syokiiti();//
  73.                 enemymovelock = 1;//この間は敵が動かないようにenemymovelockを1にしたplayer2.hの敵の攻撃や移動の部分より
  74.                  //キーAを押してもAがtalkが増えないように書いた。Player_Update()はSeen = 1により呼ばれるのでtalkの値に関係がないように書いたのでtalkの値に関係ない。なのでtalkが上がってもif (start == 200)により戦闘画面は出てこない。
  75.             }
  76.         }
  77.         //一瞬敵が動くためスタートして戦闘画面がでてから0フレーム経ったらenemymovelock = 0になるように直した。
  78.         if (start == 150) {
  79.             start = 0; Seen = 2; stayhere = 1; mark = 0; enemymovelock = 0;//まだ解決していない init_stage();は自分と敵の初期化のための関数だが、
  80. //こいつがうまく働かないせいで敵が動き回っている状態でバトルが開始するのだろう。しかしvoid Player_Update()の中にはinit_stage()は書いている。
  81.         }
  82.        
  83.        
  84.     }
  85.     void talkdrow2() { DrawFormatString(300, 400, RED, "主人公は死んでしまった"); }
  86.  
  87.     void inotigoi() {
  88.         //DrawFormatString(100, 300, RED, "説得しますか?それともこのまま戦闘を進めますか?");
  89.         Seen = 3;
  90.    
  91.     }
  92.     void inotigoi2() {
  93.         //DrawFormatString(100, 300, RED, "説得しますか?それともこのまま戦闘を進めますか?");
  94.         Seen = 4;
  95.  
  96.     }
  97.     void inotigoi3() {
  98.         //DrawFormatString(100, 300, RED, "説得しますか?それともこのまま戦闘を進めますか?");
  99.         Seen = 5;
  100.  
  101.     }
  102.  
  103.     void settokutalk() {
  104.         DrawFormatString(100, 300, RED, "キーA:これ以上あなたを傷つけたくない");
  105.         if (Key[KEY_INPUT_A] == 1) { Seen = 6; talk = 10; }
  106.             DrawFormatString(100, 400, RED, "キーB:その程度で人殺しとは笑わせるな");
  107.         if (Key[KEY_INPUT_B] == 1){}
  108.             DrawFormatString(100, 500, RED, "キーC:あなたの母親はこんな事は望んでいない!");
  109.         if (Key[KEY_INPUT_C] == 1){}
  110.     }
  111.    
  112.     void bunnkiA() {
  113.         DrawFormatString(300, 500, RED, "talkbunnkiAは%d,markは%d,Seen=%d", talkbunnkiA, mark,Seen);
  114.         if (mark == 0) {
  115.             if (Key[KEY_INPUT_A] == 1) {
  116.                 ++talkbunnkiA;
  117.                 //この中に書くとキーAにより値が一定になっても、if文よりキーAを押した一瞬にしか描画されないので書いてはダメ。
  118.             }
  119.         }
  120.         if(talkbunnkiA == 1){ DrawFormatString(300, 300, RED, "お前のことが好きだったんだよ!"); }
  121.         if (talkbunnkiA == 2) { DrawFormatString(300, 300, RED, "結婚しよう!"); }
  122.         if (talkbunnkiA == 3) {
  123.             DrawFormatString(300, 300, RED, "嘘に決まってんだろ!(主人公は相手の足を銃で撃った!");
  124.             //mark = 1;//これ以上キーAを押しても変化しないようにmarkを1にした。
  125.         }
  126.         if (talkbunnkiA == 4) {
  127.             enemyHP = enemyHP - 7; Seen = 2;
  128.             if (Key[KEY_INPUT_A] == 1) {
  129.                 talkbunnkiA = 4;
  130.                 //この中に書くとキーAにより値が一定になっても、if文よりキーAを押した一瞬にしか描画されないので書いてはダメ。
  131.             }
  132.  
  133.         }
  134.     }
  135.  
  136.     void cleartalk1() {
  137.         Seen = 9;
  138.         DrawFormatString(70, 300, RED, "ファイルにセーブデータを書き込みました。");
  139.        
  140.     }
  141. #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement