パスワードを入力して、それが正しいなら次の画面へ、間違っているならもう一度入力する、というようにしたいのですが、合っていても次の画面に進まないのです。
考えたコードは、
パスワードの部分が
#include "DxLib.h"
#include "Keyboard.h"
#include "Title.h"
const char PASSWORD[41] = "パスワード" ;
static int KeyHandle;
static char Password[41];
int Password_Check(){
if(Password == PASSWORD)
return 1;
else
return 0;
}
void Title_load(){
KeyHandle = MakeKeyInput(40,FALSE,FALSE,FALSE);
SetActiveKeyInput(KeyHandle);
}
int Title_main(){
while(!ProcessMessage()){
if(CheckKeyInput(KeyHandle) != 0) break;
DrawKeyInputModeString(0,465);
DrawKeyInputString(0,0,KeyHandle);
ScreenFlip();
}
GetKeyInputString(Password,KeyHandle);
if(Keyboard_Get(KEY_INPUT_RETURN)==1){
if(Password_Check()==1){
printfDx("ログイン成功\n");
return 1;
}else{
printfDx("ログイン失敗\n");
return 0;
}
}else{
return 0;
}
}
void Title_end(){
DeleteKeyInput(KeyHandle);
}
#include "DxLib.h"
#include "Keyboard.h"
#include "Title.h"
int func_state = 0;
int WINAPI WinMain(HINSTANCE,HINSTANCE,LPSTR,int){
ChangeWindowMode(TRUE),DxLib_Init(),SetDrawScreen( DX_SCREEN_BACK );
while( ScreenFlip()==0 && ProcessMessage()==0 && ClearDrawScreen()==0 ){
Keyboard_Update();
switch(func_state){
case 0:
Title_load();
func_state = 1;
break;
case 1:
if(Title_main()==1)
func_state = 2;
break;
case 2:
Title_end();
break;
}
}
DxLib_End();
return 0;
}
Windows Vista
VC++ 2008 EE
DXライブラリ
です。
また、キーの状態を得る関数は、DixqさんのKeyboard_Update関数とKeyboard_Get関数をそのまま使用しました。
よろしくお願いします。