Skip to content

Commit

Permalink
エンディングを追加
Browse files Browse the repository at this point in the history
  • Loading branch information
yumetodo committed Feb 13, 2016
1 parent fd06490 commit acc5d8c
Show file tree
Hide file tree
Showing 5 changed files with 101 additions and 40 deletions.
2 changes: 2 additions & 0 deletions Don't_push/Don't_push/Don't_push.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,7 @@
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="source\ending_animation.h" />
<ClInclude Include="source\game_preprocess.h" />
<ClInclude Include="source\make_array.hpp" />
<ClInclude Include="source\char_convert.hpp" />
Expand All @@ -412,6 +413,7 @@
<ClInclude Include="source\end.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="source\ending_animation.cpp" />
<ClCompile Include="source\game_preprocess.cpp" />
<ClCompile Include="source\config.cpp" />
<ClCompile Include="source\continue.cpp" />
Expand Down
6 changes: 6 additions & 0 deletions Don't_push/Don't_push/Don't_push.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@
<ClInclude Include="source\game_preprocess.h">
<Filter>ヘッダー ファイル</Filter>
</ClInclude>
<ClInclude Include="source\ending_animation.h">
<Filter>ヘッダー ファイル</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="source\end.cpp">
Expand Down Expand Up @@ -119,5 +122,8 @@
<ClCompile Include="source\game_preprocess.cpp">
<Filter>ソース ファイル</Filter>
</ClCompile>
<ClCompile Include="source\ending_animation.cpp">
<Filter>ソース ファイル</Filter>
</ClCompile>
</ItemGroup>
</Project>
45 changes: 45 additions & 0 deletions Don't_push/Don't_push/source/ending_animation.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#include "ending_animation.h"
#include "define.h"
#include <dxlibex/Graph2D.h>
#include <chrono>
#include <thread>

//#include <fstream>
#ifdef _MSC_VER
#pragma warning (push)
#pragma warning (disable: 4706) //warning C4706: 条件式の比較値は、代入の結果になっています。
#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);//「Xキーを押してね」の奴
auto text = dxle::MakeScreen(GetDrawStringWidthToHandle(plain_text, static_cast<int>(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
3 changes: 3 additions & 0 deletions Don't_push/Don't_push/source/ending_animation.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#pragma once
#include "DxSoundHandle.h"
void ending(const DxSHandle& sound);
85 changes: 45 additions & 40 deletions Don't_push/Don't_push/source/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "continue.h"
#include "end.h"
#include "config.h"
#include "ending_animation.h"
#include <exception>
//初期化関数
int init(const config_info::lang_table_t& lang_table){
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit acc5d8c

Please sign in to comment.