Skip to content

Commit

Permalink
仮完成、ただ人形が動くだけ
Browse files Browse the repository at this point in the history
  • Loading branch information
yumetodo committed Nov 19, 2015
1 parent f40005a commit 646fa63
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 19 deletions.
96 changes: 78 additions & 18 deletions GitHub/Don't_push/Don't_push/source/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,31 @@
#include "DxLib.h"
#include "define.h"
#include "power_bar.h"
#include <cmath>

game_c::game_c(const dxle::pointi & p) : m_first_(p), m_window_s_(static_cast<int>(WINDOW_WIDTH), static_cast<int>(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(); }

Expand All @@ -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.");
Expand All @@ -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<dxle::pointd>(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<dxle::pointi>(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;
}
6 changes: 5 additions & 1 deletion GitHub/Don't_push/Don't_push/source/game.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
#include "load.h"
#include "Dxkeystate.h"
#include <dxlibex/basic_types.hpp>
#include <dxlibex/Graph2D.h>

class game_c
{
public:
Expand All @@ -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_;
};
1 change: 1 addition & 0 deletions GitHub/Don't_push/Don't_push/source/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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で流れだした音楽を止める
Expand Down

0 comments on commit 646fa63

Please sign in to comment.