#include //列挙型(数え上げ enumurate) enum human_state { IDLE, //何もしてない WALK, //歩いている JUMP, //㌧㌦ CROUCH, //しゃがみ }; void PrintMyState(human_state mystate) { switch(mystate) { case human_state::IDLE: std::cout << "なーんもしてない" << std::endl; break; case human_state::WALK: std::cout << "歩いています" << std::endl; break; case human_state::JUMP: std::cout << "空中です" << std::endl; break; case human_state::CROUCH: std::cout << "体育座り中" << std::endl; break; default: std::cout << "状態異常!" << std::endl; } } int frameCount = 0; //どこからでもアクセスできそうなフレームカウント // frameCount // 0~5 // 何もしない // 5~8 // 歩く // 9-12 // 飛ぶ // 13-16 // 何もしない // 17-20 // しゃがむ // 20- //  ひたすら歩く void ShowIdleScnene(human_state &mystate) { PrintMyState(mystate); //待ち状態の時の処理 ある条件で歩く状態に移行 if(frameCount == 5) mystate = human_state::WALK; else if(frameCount == 17) mystate = human_state::CROUCH; } void ShowWalkScnene(human_state &mystate) { PrintMyState(mystate); //歩き状態の時の処理 ある条件で飛ぶ状態に移行 if(frameCount == 8) mystate = human_state::JUMP; } void ShowJumpScnene(human_state &mystate) { PrintMyState(mystate); //ジャンプ状態の時の処理 ある条件で飛ぶ状態に移行 if(frameCount == 12) mystate = human_state::IDLE; } void ShowCrouchScnene(human_state &mystate) { PrintMyState(mystate); //しゃがみ状態の時の処理 ある条件で飛ぶ状態に移行 if(frameCount == 20) mystate = human_state::WALK; } int main() { human_state hstate = human_state::IDLE; while(true){ //状態が変化していくよ! std::cout << frameCount << std::endl; switch(hstate) { case human_state::IDLE: //アイドル状態の処理 ShowIdleScnene(hstate); break; case human_state::WALK: //歩行状態の処理 ShowWalkScnene(hstate); break; case human_state::JUMP: //ジャンプ状態の処理 ShowJumpScnene(hstate); break; case human_state::CROUCH: //しゃがみ状態の処理 ShowCrouchScnene(hstate); break; default: hstate = human_state::IDLE; } //PrintMyState(hstate); getchar(); frameCount++; } } //クリックなどの入出力 //ゲームの状態を動かす条件 //ゲームの状態がいくつあるか、何か? TITLE, PLAY, GAMEOVER // → enumで書いて, // switch文かいて //  それぞれの状態の処理を関数化してみる!