エラー
Posted: 2010年3月12日(金) 23:06
このソースで実行してみると、
1>c:\documents and settings\yoshimi\my documents\visual studio 2008\projects\test\test.cpp(23) : error C2086: 'int Key[256]' : 再定義されました。
1> c:\documents and settings\yoshimi\my documents\visual studio 2008\projects\test\test.cpp(3) : 'Key' の宣言を確認してください。
とエラーが起きてしまいます・・・どうしたら実行できますか?
#include "DxLib.h"
int Key[256];
int GetHitKeyStateAll_2(int GetHitKeyStateAll_InputKey[/url]){
char GetHitKeyStateAll_Key[256];
GetHitKeyStateAll( GetHitKeyStateAll_Key );
for(int i=0;i<256;i++){
if(GetHitKeyStateAll_Key==1) GetHitKeyStateAll_InputKey++;
else GetHitKeyStateAll_InputKey=0;
}
return 0;
}
void menu ( int white, int a)
{
DrawString( 150 , a , "◆" , white );
DrawString( 170 , 100 , "1" , white );
DrawString( 170 , 130 , "2" , white );
DrawString( 170 , 160 , "終了" , white );
}
int Key[256];
int white , a = 100;
int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,LPSTR lpCmdLine, int nCmdShow ){
ChangeWindowMode(TRUE);//ウィンドウモード
if(DxLib_Init() == -1 || SetDrawScreen( DX_SCREEN_BACK )!=0) return -1;//初期化と裏画面化
while(ProcessMessage()==0 && ClearDrawScreen()==0 && GetHitKeyStateAll_2(Key)==0 && Key[KEY_INPUT_ESCAPE]==0){
//↑メッセージ処理 ↑画面をクリア ↑入力状態を保存 ↑ESCが押されていない
int Key[256];
int white , a = 100;
white = GetColor( 255 , 255 , 255 ) ;
menu(white,a);
if( Key[KEY_INPUT_DOWN]==1 ||( Key[KEY_INPUT_DOWN]%5==0 && Key[KEY_INPUT_DOWN]>30)){
// たった今押したか、30カウンター以上押しっぱなしかつ5回に一度
a+=30;
if(a==160) // y座標が260なら(選択が一番下なら)
a=100; // 選択座標を一番上に
}
ScreenFlip();
}
DxLib_End();
return 0;
}
1>c:\documents and settings\yoshimi\my documents\visual studio 2008\projects\test\test.cpp(23) : error C2086: 'int Key[256]' : 再定義されました。
1> c:\documents and settings\yoshimi\my documents\visual studio 2008\projects\test\test.cpp(3) : 'Key' の宣言を確認してください。
とエラーが起きてしまいます・・・どうしたら実行できますか?
#include "DxLib.h"
int Key[256];
int GetHitKeyStateAll_2(int GetHitKeyStateAll_InputKey[/url]){
char GetHitKeyStateAll_Key[256];
GetHitKeyStateAll( GetHitKeyStateAll_Key );
for(int i=0;i<256;i++){
if(GetHitKeyStateAll_Key==1) GetHitKeyStateAll_InputKey++;
else GetHitKeyStateAll_InputKey=0;
}
return 0;
}
void menu ( int white, int a)
{
DrawString( 150 , a , "◆" , white );
DrawString( 170 , 100 , "1" , white );
DrawString( 170 , 130 , "2" , white );
DrawString( 170 , 160 , "終了" , white );
}
int Key[256];
int white , a = 100;
int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,LPSTR lpCmdLine, int nCmdShow ){
ChangeWindowMode(TRUE);//ウィンドウモード
if(DxLib_Init() == -1 || SetDrawScreen( DX_SCREEN_BACK )!=0) return -1;//初期化と裏画面化
while(ProcessMessage()==0 && ClearDrawScreen()==0 && GetHitKeyStateAll_2(Key)==0 && Key[KEY_INPUT_ESCAPE]==0){
//↑メッセージ処理 ↑画面をクリア ↑入力状態を保存 ↑ESCが押されていない
int Key[256];
int white , a = 100;
white = GetColor( 255 , 255 , 255 ) ;
menu(white,a);
if( Key[KEY_INPUT_DOWN]==1 ||( Key[KEY_INPUT_DOWN]%5==0 && Key[KEY_INPUT_DOWN]>30)){
// たった今押したか、30カウンター以上押しっぱなしかつ5回に一度
a+=30;
if(a==160) // y座標が260なら(選択が一番下なら)
a=100; // 選択座標を一番上に
}
ScreenFlip();
}
DxLib_End();
return 0;
}