diff --git a/Don't_push/Don't_push/Don't_push.vcxproj b/Don't_push/Don't_push/Don't_push.vcxproj index 82fab64..976d8a6 100644 --- a/Don't_push/Don't_push/Don't_push.vcxproj +++ b/Don't_push/Don't_push/Don't_push.vcxproj @@ -391,6 +391,7 @@ + @@ -412,6 +413,7 @@ + diff --git a/Don't_push/Don't_push/Don't_push.vcxproj.filters b/Don't_push/Don't_push/Don't_push.vcxproj.filters index 4094b06..5381ae8 100644 --- a/Don't_push/Don't_push/Don't_push.vcxproj.filters +++ b/Don't_push/Don't_push/Don't_push.vcxproj.filters @@ -72,6 +72,9 @@ ヘッダー ファイル + + ヘッダー ファイル + @@ -119,5 +122,8 @@ ソース ファイル + + ソース ファイル + \ No newline at end of file diff --git a/Don't_push/Don't_push/source/ending_animation.cpp b/Don't_push/Don't_push/source/ending_animation.cpp new file mode 100644 index 0000000..910a433 --- /dev/null +++ b/Don't_push/Don't_push/source/ending_animation.cpp @@ -0,0 +1,45 @@ +#include "ending_animation.h" +#include "define.h" +#include +#include +#include + +//#include +#ifdef _MSC_VER +#pragma warning (push) +#pragma warning (disable: 4706) //warning C4706: ̔rĺǍʂɂȂĂ܂B +#endif + +void ending(const DxSHandle& sound) +{ + sound.play(DxSoundMode::BACK); + DXLE_STATIC_CONSTEXPR int test_height = 20; + static const TCHAR* plain_text = _T("Thank you for playing"); + const int font = CreateFontToHandle(nullptr, test_height, 1, DX_FONTTYPE_ANTIALIASING);//uXL[Ăˁv̓z + auto text = dxle::MakeScreen(GetDrawStringWidthToHandle(plain_text, static_cast(dxle::tstrlen(plain_text)), font), test_height); + text.drawn_on([font]() { + DxLib::DrawStringToHandle(0, 0, plain_text, DxLib::GetColor(255, 255, 255), font); + }); + auto normal_con_f = []() -> bool { + bool re = -1 != ProcessMessage() && 0 == ScreenFlip() && 0 == ClearDrawScreen(); + if (!re) throw std::runtime_error("ProcessMessage() return -1."); + return re; + }; + bool is_normal_state; + DXLE_STATIC_CONSTEXPR int v = WINDOW.width / 170; + //std::ofstream log("log.txt"); + //log << "text.size():" << text.size() << " v:" << v << std::endl; + for (int text_pos = WINDOW.width; + (is_normal_state = normal_con_f()) && 0 <= text_pos + text.size().width + v + 1; + text_pos -= v + ) { + DxLib::DrawBox(0, 0, WINDOW.width, WINDOW.height, DxLib::GetColor(0, 0, 0), true); + text.DrawGraph(text_pos, WINDOW.height / 3, true); + //log << "text_pos:" << text_pos << " text_pos + text.size().width:" << text_pos + text.size().width << std::endl; + } + while (1 == sound.is_during_playback() && (is_normal_state = -1 != ProcessMessage())) std::this_thread::sleep_for(std::chrono::milliseconds(50)); + if(!is_normal_state) throw std::runtime_error("ProcessMessage() return -1."); +} +#ifdef _MSC_VER +#pragma warning (pop) +#endif diff --git a/Don't_push/Don't_push/source/ending_animation.h b/Don't_push/Don't_push/source/ending_animation.h new file mode 100644 index 0000000..63dd647 --- /dev/null +++ b/Don't_push/Don't_push/source/ending_animation.h @@ -0,0 +1,3 @@ +#pragma once +#include "DxSoundHandle.h" +void ending(const DxSHandle& sound); diff --git a/Don't_push/Don't_push/source/main.cpp b/Don't_push/Don't_push/source/main.cpp index 9db4c98..4d0dc92 100644 --- a/Don't_push/Don't_push/source/main.cpp +++ b/Don't_push/Don't_push/source/main.cpp @@ -9,6 +9,7 @@ #include "continue.h" #include "end.h" #include "config.h" +#include "ending_animation.h" #include //初期化関数 int init(const config_info::lang_table_t& lang_table){ @@ -38,48 +39,52 @@ int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int) auto config = load_config("assets/config.json"); init(config.lang_str); game_c game({ WINDOW.width * 57 / 256 , WINDOW.height * 2 / 7 }, { WINDOW.width * 71 / 128 , WINDOW.height * 2 / 7 }, config.lang_str);//棒人形A, 棒人形B - while (Status::EXIT != status_ && -1 != ProcessMessage()){ - switch (status_) - { - case Status::TITLE: - status_ = title(game.get_img(), game.get_sound(), config.lang_str);//title BGM流す。この中でBGM止める - break; - case Status::GAME_PREPROCESS: - status_ = game_preprocess(); - break; - case Status::GAME: - status_ = game.game_main();//BGM流し始め - break; - case Status::END: - status_ = end(game.get_img(), game.get_sound(), config.lang_str);//ここでGAMEで流れだした音楽を止める - break; - case Status::FLYING_MARE_ANIMATION: - break; - case Status::CAR_ANIMATION: - break; - case Status::HELICOPTER_ANIMATION: - status_ = game.helicopter_event(); - break; - case Status::RESULT_ECHO: - status_ = game.echo_score(); - break; - case Status::GAME_OVER: - status_ = game.echo_game_over(); - break; - case Status::CONTINUE: - status_ = continu(game.get_img(), game.get_sound(), config.lang_str);//ここでGAMEで流れだした音楽を止める - break; - case Status::EXIT: - break; - default: - DxLib_End(); - return -1; - break; + try { + while (Status::EXIT != status_ && -1 != ProcessMessage()) { + switch (status_) + { + case Status::TITLE: + status_ = title(game.get_img(), game.get_sound(), config.lang_str);//title BGM流す。この中でBGM止める + break; + case Status::GAME_PREPROCESS: + status_ = game_preprocess(); + break; + case Status::GAME: + status_ = game.game_main();//BGM流し始め + break; + case Status::END: + status_ = end(game.get_img(), game.get_sound(), config.lang_str);//ここでGAMEで流れだした音楽を止める + break; + case Status::FLYING_MARE_ANIMATION: + break; + case Status::CAR_ANIMATION: + break; + case Status::HELICOPTER_ANIMATION: + status_ = game.helicopter_event(); + break; + case Status::RESULT_ECHO: + status_ = game.echo_score(); + break; + case Status::GAME_OVER: + status_ = game.echo_game_over(); + break; + case Status::CONTINUE: + status_ = continu(game.get_img(), game.get_sound(), config.lang_str);//ここでGAMEで流れだした音楽を止める + break; + case Status::EXIT: + break; + default: + DxLib_End(); + return -1; + break; + } + ScreenFlip();//裏画面表示 } - ScreenFlip();//裏画面表示 } - } - catch (const normal_exit&) { + catch (const normal_exit&) { + } + for (auto& s : game.get_sound()) s.second.stop();//BGM全部停止 + ending(game.get_sound().at(L"Thank_you_for_playing")); } catch (const std::exception&){ DxLib_End();