From 646fa63ff4c528a349b3f49dc6bf506f8a894980 Mon Sep 17 00:00:00 2001 From: yumetodo Date: Thu, 19 Nov 2015 20:16:39 +0900 Subject: [PATCH] =?UTF-8?q?=E4=BB=AE=E5=AE=8C=E6=88=90=E3=80=81=E3=81=9F?= =?UTF-8?q?=E3=81=A0=E4=BA=BA=E5=BD=A2=E3=81=8C=E5=8B=95=E3=81=8F=E3=81=A0?= =?UTF-8?q?=E3=81=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- GitHub/Don't_push/Don't_push/source/game.cpp | 96 ++++++++++++++++---- GitHub/Don't_push/Don't_push/source/game.h | 6 +- GitHub/Don't_push/Don't_push/source/main.cpp | 1 + 3 files changed, 84 insertions(+), 19 deletions(-) diff --git a/GitHub/Don't_push/Don't_push/source/game.cpp b/GitHub/Don't_push/Don't_push/source/game.cpp index dfce914..6e8702a 100644 --- a/GitHub/Don't_push/Don't_push/source/game.cpp +++ b/GitHub/Don't_push/Don't_push/source/game.cpp @@ -3,6 +3,31 @@ #include "DxLib.h" #include "define.h" #include "power_bar.h" +#include + +game_c::game_c(const dxle::pointi & p) : m_first_(p), m_window_s_(static_cast(WINDOW_WIDTH), static_cast(WINDOW_HEIGHT)), m_p_(p), m_state_() { + this->m_img_ = make_image_array(); + this->m_status_img_ = make_status_image_array(); + this->m_sound_ = make_sound_array(); + this->m_back_img_ = dxle::Graph2D::MakeScreen(m_window_s_.x, m_window_s_.y); + this->m_back_img_.DrawnOn([this]() {m_img_["gake"].DrawExtendGraph({}, m_window_s_, false); }); +} + +game_c::~game_c() { + for (auto& s : this->m_sound_) s.second.stop(); +} + +const sound_arr_t & game_c::get_sound() const NOEXCEPT { + return this->m_sound_; +} + +const img_arr_t & game_c::get_status_img() const NOEXCEPT { + return this->m_status_img_; +} + +const img_arr_t & game_c::get_img() const NOEXCEPT { + return this->m_img_; +} bool game_c::normal_con_f() const NOEXCEPT { return -1 != ProcessMessage() && 0 == ScreenFlip() && 0 == ClearDrawScreen(); } @@ -17,13 +42,13 @@ void game_c::move_x() NOEXCEPT{ #pragma warning (push) #pragma warning (disable: 4706) //warning C4706: 条件式の比較値は、代入の結果になっています。 #endif -Status game_c::game_main(){ - m_state_.fllush(); +Status game_c::game_main() { + this->m_state_.fllush(); this->m_sound_["flower garden"].play(DxSoundMode::LOOP); bool is_normal_state =true; while ((is_normal_state = normal_con_f()) && m_state_.update() && !m_state_[KEY_INPUT_Z] && !m_state_.esc()) { this->move_x(); - this->m_img_["gake"].DrawGraph(0, 0, false); + this->m_back_img_.DrawGraph({}, false); this->m_img_["bouninngennB"].DrawGraph(this->m_p_, true); } if (!is_normal_state) throw std::runtime_error("ProcessMessage() return -1."); @@ -33,25 +58,60 @@ Status game_c::game_main(){ #ifdef _MSC_VER #pragma warning (pop) #endif +class circular_motion +{ +public: + circular_motion() = delete; + circular_motion(const dxle::pointi& center_pos, const dxle::pointi& first_pos, double angular_v) NOEXCEPT; + circular_motion(const circular_motion&) = delete; + circular_motion(circular_motion&&) = delete; + circular_motion& operator=(const circular_motion&) = delete; + circular_motion& operator=(circular_motion&&) = delete; + bool update() NOEXCEPT; + bool draw(const DxGHandle& img) const; +private: + const dxle::pointi m_center_; + const double m_r_; + const double m_first_rad_; + double m_angular_v_;// rad./sec. Dextrorotation(右回り。yは下向き正) + dxle::pointd m_current_; + size_t m_t_; +}; -game_c::game_c(const dxle::pointi & p) : m_first_(p), m_p_(p), m_state_(){ - this->m_img_ = make_image_array(); - this->m_status_img_ = make_status_image_array(); - this->m_sound_ = make_sound_array(); -} - -game_c::~game_c(){ - for (auto& s : this->m_sound_) s.second.stop(); -} +circular_motion::circular_motion(const dxle::pointi & center_pos, const dxle::pointi& first_pos, double angular_v) NOEXCEPT + : m_center_(center_pos), m_r_(std::hypot(first_pos.x - m_center_.x, first_pos.y - m_center_.y)), + m_first_rad_(std::acos((first_pos.x - m_center_.x) / m_r_) * ((first_pos.y - m_center_.y) < 0) ? -1 : 1), + m_angular_v_(angular_v), m_current_(static_cast(first_pos)), m_t_() +{} -const sound_arr_t & game_c::get_sound() const NOEXCEPT { - return this->m_sound_; +bool circular_motion::update() NOEXCEPT { + ++this->m_t_; + this->m_current_ = dxle::pointd(this->m_r_ * std::cos(this->m_t_ * this->m_angular_v_), this->m_r_ * std::sin(this->m_t_ * this->m_angular_v_)); + return true; } -const img_arr_t & game_c::get_status_img() const NOEXCEPT { - return this->m_status_img_; +bool circular_motion::draw(const DxGHandle & img) const { + img.DrawGraph(static_cast(this->m_current_), true); + return true; } -const img_arr_t & game_c::get_img() const NOEXCEPT { - return this->m_img_; +Status game_c::helicopter_event() { + this->m_state_.fllush(); + this->m_sound_["flower garden"].play(DxSoundMode::LOOP); + bool is_normal_state = true; + circular_motion helicopter({ m_window_s_.x / 2, -300 }, { m_window_s_.x * 5 / 6, 10 }, 1.0 / 30.0); + SetDrawValidGraphCreateFlag(true); + SetDrawValidAlphaChannelGraphCreateFlag(true); + auto bouninngennB = dxle::Graph2D::MakeScreen(m_window_s_.x * 3 / 10, m_window_s_.x * 3 / 10, true); + bouninngennB.DrawnOn([this]() {this->m_img_["bouninngennB"].DrawExtendGraph({}, { m_window_s_.x * 3 / 10, m_window_s_.x * 3 / 10 }, true); }); + SetDrawValidGraphCreateFlag(false); + SetDrawValidAlphaChannelGraphCreateFlag(false); + while ((is_normal_state = normal_con_f()) && m_state_.update() && !m_state_[KEY_INPUT_Z] && !m_state_.esc()) { + this->move_x(); + this->m_back_img_.DrawGraph({}, false); + bouninngennB.DrawGraph(this->m_p_, true); + } + if (!is_normal_state) throw std::runtime_error("ProcessMessage() return -1."); + if (m_state_.esc()) throw normal_exit(); + return Status::CONTINUE; } diff --git a/GitHub/Don't_push/Don't_push/source/game.h b/GitHub/Don't_push/Don't_push/source/game.h index 43226a6..b35339c 100644 --- a/GitHub/Don't_push/Don't_push/source/game.h +++ b/GitHub/Don't_push/Don't_push/source/game.h @@ -3,6 +3,8 @@ #include "load.h" #include "Dxkeystate.h" #include +#include + class game_c { public: @@ -18,12 +20,14 @@ class game_c void move_x() NOEXCEPT; Status game_main(); - //Status helicopter(); + Status helicopter_event(); private: const dxle::pointi m_first_; + const dxle::pointi m_window_s_; dxle::pointi m_p_; keystate m_state_; img_arr_t m_img_; img_arr_t m_status_img_; sound_arr_t m_sound_; + dxle::Graph2D::Screen m_back_img_; }; diff --git a/GitHub/Don't_push/Don't_push/source/main.cpp b/GitHub/Don't_push/Don't_push/source/main.cpp index 637f68d..f58d5f1 100644 --- a/GitHub/Don't_push/Don't_push/source/main.cpp +++ b/GitHub/Don't_push/Don't_push/source/main.cpp @@ -53,6 +53,7 @@ int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int) case Status::CAR_ANIMATION: break; case Status::HELICOPTER_ANIMATION: + status_ = game.helicopter_event(); break; case Status::CONTINUE: status_ = continu(game.get_img(), game.get_sound());//ここでGAMEで流れだした音楽を止める