全体的にプログラムがおかしい部分があるので、
一から作り直したほうが上手く行くかもしれませんよ。
一応簡単に作ってみたのですが、カーソルで選択するというのは、こんな感じですかね?
(分岐処理への移動はエンターキーになってます)
-----------------------------------------------------------------------------------------------
#include "DxLib.h"
int Key[256];
int GetHitKeyStateAll_2(int KeyStateBuf[/url]){
char GetHitKeyStateAll_Key[256];
GetHitKeyStateAll( GetHitKeyStateAll_Key );
for(int i=0;i<256;i++){
if(GetHitKeyStateAll_Key==1) KeyStateBuf++;
else KeyStateBuf=0;
}
return 0;
}
enum StateID{
STATE_START,
STATE_CONTINUE,
STATE_OPTION,
STATE_EXIT,
STATE_SELECT,
STATE_END
};
StateID state = STATE_SELECT;
enum ColorID{
COLOR_RED,
COLOR_BLUE,
COLOR_YELLOW,
COLOR_GREEN,
COLOR_CYAN,
COLOR_WHITE,
COLOR_MAX
};
int Color[COLOR_MAX];
typedef struct{
const int r;
const int g;
const int b;
}COLOR;
COLOR CList[COLOR_MAX] = { { 255, 0, 0},
{ 0, 0, 255},
{ 255, 255, 0},
{ 0, 255, 0},
{ 100, 255, 255},
{ 255, 255, 255}};
typedef struct{
int PtX;
int PtY;
char* str;
ColorID c;
const StateID next;
}CHOICES;
CHOICES choices[/url] = { {100, 100, "START", COLOR_WHITE, STATE_START},
{100, 120, "CONTINUE",COLOR_WHITE, STATE_CONTINUE},
{100, 140, "OPTION",COLOR_WHITE,STATE_OPTION},
{100, 160, "EXIT",COLOR_WHITE, STATE_EXIT}};
void Start(void)
{
if(Key[KEY_INPUT_Z] == 1){
state = STATE_SELECT;
}
DrawString( 100, 100 , "Start画面です。" , Color[COLOR_CYAN]);
DrawString( 100, 120 , "※Zキーで戻ります。" , Color[COLOR_WHITE]);
}
void Continue(void)
{
if(Key[KEY_INPUT_Z] == 1){
state = STATE_SELECT;
}
DrawString( 100, 100 , "Continue画面です。" , Color[COLOR_BLUE]);
DrawString( 100, 120 , "※Zキーで戻ります。" , Color[COLOR_WHITE]);
}
void Option(void)
{
if(Key[KEY_INPUT_Z] == 1){
state = STATE_SELECT;
}
DrawString( 100, 100 , "Option画面です。" , Color[COLOR_GREEN]);
DrawString( 100, 120 , "※Zキーで戻ります。" , Color[COLOR_WHITE]);
}
void Exit(void)
{
static int count = 150;
if((--count) == 0)
state = STATE_END;
DrawString( 100, 100 , "Exit画面です。" , Color[COLOR_RED]);
DrawString( 100, 120 , "※プログラムを終了します。" , Color[COLOR_WHITE]);
}
void Select(void)
{
static int NowPt = 0;
static const int ChoiceNum = sizeof(choices)/sizeof(choices[0]);
if(Key[KEY_INPUT_DOWN] == 1 || (Key[KEY_INPUT_DOWN] > 10 && Key[KEY_INPUT_DOWN] % 10 == 0)){
choices[NowPt].c = COLOR_WHITE;
NowPt = (NowPt + 1) % ChoiceNum;
}else if(Key[KEY_INPUT_UP] == 1 || (Key[KEY_INPUT_UP] > 10 && Key[KEY_INPUT_UP] % 10 == 0)){
choices[NowPt].c = COLOR_WHITE;
NowPt = (NowPt + ChoiceNum - 1) % ChoiceNum;
}
for(int i = 0; i < ChoiceNum; i++){
if(i == NowPt)
choices.c = COLOR_YELLOW;
DrawString( choices.PtX , choices.PtY , choices.str , Color[choices.c]);
}
DrawString( choices[NowPt].PtX - 20, choices[NowPt].PtY , "⇒" , Color[COLOR_CYAN]);
if(Key[KEY_INPUT_RETURN] == 1){
state = choices[NowPt].next;
choices[NowPt].c = COLOR_WHITE;
NowPt = 0;
}
}
void SetColor(void)
{
for(int i = 0, count = sizeof(CList) / sizeof(CList[0]); i < count; i++)
Color = GetColor(CList.r, CList[i].g, CList[i].b);
}
int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,LPSTR lpCmdLine, int nCmdShow ){
ChangeWindowMode( TRUE );
if(DxLib_Init() == -1 ) return -1;
SetDrawScreen( DX_SCREEN_BACK );
SetColor();
typedef void(*Func)();
Func fc[/url] = {Start, Continue, Option, Exit, Select};
while(ProcessMessage()==0 && ClearDrawScreen()==0 && GetHitKeyStateAll_2(Key)==0 && Key[KEY_INPUT_ESCAPE]==0 && state != STATE_END){
fc[state]();
ScreenFlip();
}
DxLib_End();
return 0;
}
-----------------------------------------------------------------------------------------------