よろしくお願いします。
今回初めてC言語でゲーム作成を行っており、まずゲームプログラミングの館を
参考にし、使う画像を作成したのですが、一つのプログラムにする方法がわからず作業が止まっています。
if文などを使い、試行錯誤したのですがわかりませんでした。繋げたいプログラムを以下に書かせていただきます。
ご指導ご鞭撻のほどよろしくお願いします。
「表紙」
#include "DxLib.h" #define PI 3.1415926 char Key[256]; int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,LPSTR lpCmdLine, int nCmdShow ){ if( ChangeWindowMode(TRUE) != DX_CHANGESCREEN_OK || DxLib_Init() == -1 ) return -1; DrawString(0,0,"a",GetColor(255,255,255)); SetFontSize( 45 ) ; SetFontThickness( 8 ) ; ChangeFont( "HGS創英角ポップ体" ) ; ChangeFontType( DX_FONTTYPE_ANTIALIASING ); DrawString(50,180,"b",GetColor(255,255,255)); SetFontSize( 30 ) ; SetFontThickness( 1 ) ; ChangeFont( "HGS創英角ポップ体" ) ; ChangeFontType( DX_FONTTYPE_ANTIALIASING_EDGE DrawString(50,230," ~c~",GetColor(255,255,255)); SetFontSize( 20 ) ; SetFontThickness( 1 ) ; ChangeFont( "MS 明朝" ) ; ChangeFontType( DX_FONTTYPE_ANTIALIASING_EDGE DrawString(130,430," d",GetColor(255,255,255)); WaitKey(); DxLib_End(); return 0; }「選択画面1」
#include "DxLib.h" 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; } void char_disp(int White,int y){ DrawString( 150 , y , "■" , White ); DrawString( 170 , 250 , "level1 障壁一つ" , White ); DrawString( 170 , 270 , "level2 障壁二つ" , White ); } int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,LPSTR lpCmdLine, int nCmdShow ){ int Key[256]; int White , y=250; ChangeWindowMode(TRUE); if(DxLib_Init() == -1 || SetDrawScreen( DX_SCREEN_BACK )!=0) return -1; PlayMusic( "ドラ.wav" , DX_PLAYTYPE_BACK ) ; White = GetColor( 255 , 255 , 255 ) ; while(ProcessMessage()==0 && ClearDrawScreen()==0 && GetHitKeyStateAll_2(Key)==0 && Key[KEY_INPUT_ESCAPE]==0){ char_disp(White,y); if( Key[KEY_INPUT_DOWN]==1 ||( Key[KEY_INPUT_DOWN]%5==0 && Key[KEY_INPUT_DOWN]>30)){ y+=20; if(y==290) y=250; } ScreenFlip(); } DxLib_End(); return 0; }
「選択1から選択2-1(level1)へ」
#include "DxLib.h" 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; } void char_disp(int White,int y){ DrawString( 170 , 120 , "x" , White ); DrawString( 150 , y , "■" , White ); DrawString( 170 , 140 , "0.125" , White ); DrawString( 170 , 160 , "0.72" , White ); DrawString( 170 , 180 , "1.445" , White ); } int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,LPSTR lpCmdLine, int nCmdShow ){ int Key[256]; int White , y=140; ChangeWindowMode(TRUE); if(DxLib_Init() == -1 || SetDrawScreen( DX_SCREEN_BACK )!=0) return -1; White = GetColor( 255 , 255 , 255 ) ; while(ProcessMessage()==0 && ClearDrawScreen()==0 && GetHitKeyStateAll_2(Key)==0 && Key[KEY_INPUT_ESCAPE]==0){ char_disp(White,y); if( Key[KEY_INPUT_DOWN]==1 ||( Key[KEY_INPUT_DOWN]%5==0 && Key[KEY_INPUT_DOWN]>30)){ y+=20; if(y==200) y=140; } ScreenFlip(); } DxLib_End(); return 0; }
ゲーム作成2に続く