Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "DxLib.h"
- #include "key.h"
- #pragma warning(disable: 4996)
- //#include "taitolh.h"
- #ifndef DEF_talk_H //二重include防止
- #define DEF_talk_H
- int RED = GetColor(255, 0, 0); // 緑の色コードを取得
- int talk = 0;
- int talkframe = 0;
- int talkframecount = 0;
- int start = 0;
- int battle = 0;
- int Seen = 0;
- int countchar = 0;
- int Green = GetColor(0, 255, 0);
- int Yellow = GetColor(255, 255, 0);
- int talkbunnkiA = 0;
- //int White = GetColor(255, 255, 255);
- int t = 0;
- const char* str[3] = { "あいうabc", "0123456789", "ABCDEFG" };//ここで文字を直接書いてるので、この文字のバイト数が各posmozi[]に入るだけ
- int frame[3] = { 5, 5, 40 };//次の一文字が出るまでのカウンタとして働いている、ここの数値を変えることで文字が一文字ずつ出るまでの間隔を設定できる。
- int posmozi[3];//文字のバイト数が入る箱を表している。
- int countS[3];//次の文字が出るまでのカウントするためのもの
- int z;//関数drawString外でも使えるように外にも定義を書いた。zの数値は関係なく、文字列が入った数列がif文により同じ変数zの時にframe[z]と同じになるまで+1されていったり、+2バイトor+1バイトされていくため、
- //文字が一文字ずつ入っていく、なんでzの変数に値を入れて動かす必要がないのだ。ちなみにfor (z = 0; z < 3; ++z)で書いてしまうとキーAを押した際のif文に関係なく関数drawStringの最初のzどこかに値が入っただけで繰り返しを開始してしまうため、今回のように同じ変数zの時にフレームを利用して描画するようにした。
- char c = str[z][posmozi[z]];//関数drawString外でも使えるように外にも定義を書いた。
- void syokiiti() {
- int enemyX = 4, enemyY = 1; // 敵の位置
- int playerX = 1, playerY = 1; // 俺の位置
- }
- void drawString(int z, int x, int y, int color)
- {
- char c = str[z][posmozi[z]];//posmozi[z]
- if (countS[z] == 0 && c != '\0')
- posmozi[z] += IsDBCSLeadByte(c) ? 2 : 1;
- if (++countS[z] == frame[z]) countS[z] = 0;
- DrawFormatString(x, y, color, "%.*s", posmozi[z], str[z]);
- DrawFormatString(300, 300, RED, "countS[0]は%d", countS[0]);
- }
- void talkdrow() {
- if (talk == 0) {
- if (talk == 0 && posmozi[0] == 9) { if (Key[KEY_INPUT_A] == 1) { ++talk; } }//talkdorwの時にstr1.drawStringが呼ばれているのでこの中身のものも実行されても大丈夫なのでは?
- drawString(0, 100, 500, Green);
- }
- if (talk == 1) {
- if (talk == 1 && posmozi[1] == 10) { if (Key[KEY_INPUT_A] == 1) { ++talk; } }
- drawString(1, 100, 500, Yellow);
- start = 1;
- }
- //if (talk == 2) { start = 1; // DrawFormatString(300, 300, RED, "battle startします"); stayhere = 1;
- //}
- if (talk == 2) {
- mark = 1;//★★★talkが3の時はキーAが押せないように変数で条件を付けた。編集前は上のif (Key[KEY_INPUT_A] == 1)と被ってしまって重複したためかうまく機能しなかった。
- //stayhereを使ってのプログラムもあったが、関数の外のメインにあったためかif (Key[KEY_INPUT_A] == 1)が働かなかったのか、一定のままだった。しかし出来れば関数内でまとめたいので左のように書いた。
- if (start > 0 && ++start <= 150) {
- DrawFormatString(300, 300, RED, "battle startします");
- syokiiti();//
- enemymovelock = 1;//この間は敵が動かないようにenemymovelockを1にしたplayer2.hの敵の攻撃や移動の部分より
- //キーAを押してもAがtalkが増えないように書いた。Player_Update()はSeen = 1により呼ばれるのでtalkの値に関係がないように書いたのでtalkの値に関係ない。なのでtalkが上がってもif (start == 200)により戦闘画面は出てこない。
- }
- }
- //一瞬敵が動くためスタートして戦闘画面がでてから0フレーム経ったらenemymovelock = 0になるように直した。
- if (start == 150) {
- start = 0; Seen = 2; stayhere = 1; mark = 0; enemymovelock = 0;//まだ解決していない init_stage();は自分と敵の初期化のための関数だが、
- //こいつがうまく働かないせいで敵が動き回っている状態でバトルが開始するのだろう。しかしvoid Player_Update()の中にはinit_stage()は書いている。
- }
- }
- void talkdrow2() { DrawFormatString(300, 400, RED, "主人公は死んでしまった"); }
- void inotigoi() {
- //DrawFormatString(100, 300, RED, "説得しますか?それともこのまま戦闘を進めますか?");
- Seen = 3;
- }
- void inotigoi2() {
- //DrawFormatString(100, 300, RED, "説得しますか?それともこのまま戦闘を進めますか?");
- Seen = 4;
- }
- void inotigoi3() {
- //DrawFormatString(100, 300, RED, "説得しますか?それともこのまま戦闘を進めますか?");
- Seen = 5;
- }
- void settokutalk() {
- DrawFormatString(100, 300, RED, "キーA:これ以上あなたを傷つけたくない");
- if (Key[KEY_INPUT_A] == 1) { Seen = 6; talk = 10; }
- DrawFormatString(100, 400, RED, "キーB:その程度で人殺しとは笑わせるな");
- if (Key[KEY_INPUT_B] == 1){}
- DrawFormatString(100, 500, RED, "キーC:あなたの母親はこんな事は望んでいない!");
- if (Key[KEY_INPUT_C] == 1){}
- }
- void bunnkiA() {
- DrawFormatString(300, 500, RED, "talkbunnkiAは%d,markは%d,Seen=%d", talkbunnkiA, mark,Seen);
- if (mark == 0) {
- if (Key[KEY_INPUT_A] == 1) {
- ++talkbunnkiA;
- //この中に書くとキーAにより値が一定になっても、if文よりキーAを押した一瞬にしか描画されないので書いてはダメ。
- }
- }
- if(talkbunnkiA == 1){ DrawFormatString(300, 300, RED, "お前のことが好きだったんだよ!"); }
- if (talkbunnkiA == 2) { DrawFormatString(300, 300, RED, "結婚しよう!"); }
- if (talkbunnkiA == 3) {
- DrawFormatString(300, 300, RED, "嘘に決まってんだろ!(主人公は相手の足を銃で撃った!");
- //mark = 1;//これ以上キーAを押しても変化しないようにmarkを1にした。
- }
- if (talkbunnkiA == 4) {
- enemyHP = enemyHP - 7; Seen = 2;
- if (Key[KEY_INPUT_A] == 1) {
- talkbunnkiA = 4;
- //この中に書くとキーAにより値が一定になっても、if文よりキーAを押した一瞬にしか描画されないので書いてはダメ。
- }
- }
- }
- void cleartalk1() {
- Seen = 9;
- DrawFormatString(70, 300, RED, "ファイルにセーブデータを書き込みました。");
- }
- #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement