1.Voice2の音が再生されない
2.2キーと3キーを押しても反応がない
どうしたら改善されますか?
以下ソース
#include "DxLib.h"
int WINAPI WinMain(HINSTANCE,HINSTANCE,LPSTR,int )
{
ChangeWindowMode(TRUE), DxLib_Init(), SetDrawScreen( DX_SCREEN_BACK ); //ウィンドウモード変更と初期化と裏画面設定
int PC = 0; //PCの初期化
int b = 0; //bの初期化
int Handle0,Handle1,Handle2,Handle3,Handle4;
int Voice0,Voice1,Voice2,Voice3,Voice4,Voice5,Voice6,Voice7,Voice8;
Handle0 = LoadGraph( "画像/ゆっくり霊夢.png" );
Handle1 = LoadGraph("画像/しょぼん.png");
Handle2 = LoadGraph( "画像/グー.png" );
Handle3 = LoadGraph( "画像/チョキ.png" );
Handle4 = LoadGraph( "画像/パー.png" );
Voice0 = LoadSoundMem("サウンド/勝ち1.wav"); // サウンドをロードし、識別番号をVoice0に格納
Voice3 = LoadSoundMem("サウンド/勝ち2.wav");
Voice6 = LoadSoundMem("サウンド/勝ち3.wav");
Voice1 = LoadSoundMem("サウンド/あいこ1.wav");
Voice4 = LoadSoundMem("サウンド/あいこ2.wav");
Voice7 = LoadSoundMem("サウンド/あいこ3.wav");
Voice2 = LoadSoundMem("サウンド/負け1,wav");
Voice5 = LoadSoundMem("サウンド/負け2.wav");
Voice8 = LoadSoundMem("サウンド/負け3.wav");
SRand(GetNowCount()); // 乱数初期化
while( ScreenFlip()==0 && ProcessMessage()==0 && ClearDrawScreen()==0 )
{
int a = GetRand( 2 ); //乱数0,1,2
int Col = GetColor( 255,255,255 );
if( b == 0 )
{
b = 1;
}
if( b == 1 )
{
DrawFormatString( 0, 0, GetColor(255,255,255), "「ジャンケン!」");
DrawFormatString( 0,20, GetColor(255,255,255), "あなたの手を入力して下さい(グー:1 チョキ:2 パー:3)");
DrawGraph( 395, 250, Handle0, TRUE ); // データハンドルを使って画像を描画
DrawGraph( 1, 335, Handle1, TRUE );
DrawFormatString( 445,460, GetColor(255,255,255), "[ゆっくり霊夢]");
DrawFormatString( 110,460, GetColor(255,255,255), "[あなた]");
if( CheckHitKey(KEY_INPUT_1) == 1 )
{
b = 2;
if( b == 2 )
{
if( a == 0 )
{
PC=1;
b=1;
}
else if( a == 1 )
{
PC=2;
b=1;
}
else if( a == 2 )
{
PC=3;
b=1;
}
}
}
}
else if( CheckHitKey(KEY_INPUT_2) == 1 )
{
b = 3;
if( b == 3 )
{
if( a == 0 )
{
PC=4;
b=1;
}
else if( a == 1 )
{
PC=5;
b=1;
}
else if( a == 2 )
{
PC=6;
b=1;
}
}
}
else if( CheckHitKey(KEY_INPUT_3) == 1 )
{
b = 4;
if( b == 4 )
{
if( a == 0 )
{
PC=7;
b=1;
}
else if( a == 1 )
{
PC=8;
b=1;
}
else if( a == 2 )
{
PC=9;
b=1;
}
}
}
if( PC == 1 )
{
DrawGraph( 155, 88, Handle2, TRUE );
DrawGraph( 330, 88, Handle2, TRUE );
if( CheckHitKey(KEY_INPUT_1) == 0 && CheckHitKey(KEY_INPUT_2) == 0 && CheckHitKey(KEY_INPUT_1) == 0)
{
DrawFormatString( 0, 40, GetColor(255,255,255), "「ポン!」");
PlaySoundMem( Voice1, DX_PLAYTYPE_NORMAL ); // 効果音を再生する
PC = 10;
}
}
else if( PC == 10)
{
DrawFormatString( 0, 40, GetColor(255,255,255), "「ポン!」");
DrawFormatString( 0, 60, GetColor(255,255,255),"あなた:グー");
DrawFormatString( 0, 80, GetColor(255,255,255),"あいて:グー");
DrawFormatString( 0, 100, GetColor(255, 255,255),"結果:あいこです。");
DrawFormatString(0, 120, GetColor(255, 255, 0), "ESCキーで終了します。");
if( CheckHitKey( KEY_INPUT_ESCAPE ) == 1 )
{
break;
}
}
else if( PC == 2 )
{
DrawGraph( 155, 88, Handle2, TRUE );
DrawGraph( 330, 88, Handle3, TRUE );
if( CheckHitKey(KEY_INPUT_1) == 0 && CheckHitKey(KEY_INPUT_2) == 0 && CheckHitKey(KEY_INPUT_1) == 0)
{
DrawFormatString( 0, 40, GetColor(255,255,255), "「ポン!」");
PlaySoundMem( Voice0, DX_PLAYTYPE_NORMAL );
PC = 11;
}
}
else if( PC == 11 )
{
DrawFormatString( 0, 40, GetColor(255,255,255), "「ポン!」");
DrawFormatString( 0, 60, GetColor(255,255,255),"あなた:グー");
DrawFormatString( 0, 80, GetColor(255,255,255),"あいて:チョキ");
DrawFormatString( 0, 100, GetColor(255, 255,255),"結果:あなたの勝ちです!");
DrawFormatString(0, 120, GetColor(255, 255, 0), "ESCキーで終了します。");
if( CheckHitKey( KEY_INPUT_ESCAPE ) == 1 )
{
break;
}
}
else if( PC == 3 )
{
DrawGraph( 155, 88, Handle2, TRUE );
DrawGraph( 330, 88, Handle4, TRUE );
if( CheckHitKey(KEY_INPUT_1) == 0 && CheckHitKey(KEY_INPUT_2) == 0 && CheckHitKey(KEY_INPUT_1) == 0)
{
DrawFormatString( 0, 40, GetColor(255,255,255), "「ポン!」");
PlaySoundMem( Voice2, DX_PLAYTYPE_NORMAL );
PC = 12;
}
}
else if( PC == 12 )
{
DrawFormatString( 0, 40, GetColor(255,255,255), "「ポン!」");
DrawFormatString( 0, 60, GetColor(255,255,255),"あなた:グー");
DrawFormatString( 0, 80, GetColor(255,255,255),"あいて:パー");
DrawFormatString( 0, 100, GetColor(255, 255,255),"結果:あなたの負けです・・・");
DrawFormatString( 0, 120, GetColor(255, 255, 0), "ESCキーで終了します。");
if( CheckHitKey( KEY_INPUT_ESCAPE ) == 1 )
{
break;
}
}
else if( PC == 4 )
{
DrawGraph( 155, 88, Handle3, TRUE );
DrawGraph( 330, 88, Handle2, TRUE );
if( CheckHitKey(KEY_INPUT_1) == 0 && CheckHitKey(KEY_INPUT_2) == 0 && CheckHitKey(KEY_INPUT_1) == 0)
{
PlaySoundMem( Voice5, DX_PLAYTYPE_NORMAL );
PC = 13;
}
}
else if(PC == 13)
{
DrawFormatString( 0, 40, GetColor(255,255,255), "「ポン!」");
DrawFormatString( 0, 60, GetColor(255,255,255),"あなた:チョキ");
DrawFormatString( 0, 80, GetColor(255,255,255),"あいて:グー");
DrawFormatString( 0, 100, GetColor(255, 255,255),"結果:あなたの負けです・・・");
DrawFormatString(0, 120, GetColor(255, 255, 0), "ESCキーで終了します。");
if( CheckHitKey( KEY_INPUT_ESCAPE ) == 1 )
{
break;
}
}
else if( PC == 5 )
{
DrawGraph( 155, 88, Handle3, TRUE );
DrawGraph( 330, 88, Handle3, TRUE );
if( CheckHitKey(KEY_INPUT_1) == 0 && CheckHitKey(KEY_INPUT_2) == 0 && CheckHitKey(KEY_INPUT_1) == 0)
{
PlaySoundMem( Voice4, DX_PLAYTYPE_NORMAL );
PC = 14;
}
else if( PC == 14)
{
DrawFormatString( 0, 40, GetColor(255,255,255), "「ポン!」");
DrawFormatString( 0, 60, GetColor(255,255,255),"あなた:チョキ");
DrawFormatString( 0, 80, GetColor(255,255,255),"あいて:チョキ");
DrawFormatString( 0, 100, GetColor(255, 255,255),"結果:あいこです。");
DrawFormatString(0, 120, GetColor(255, 255, 0), "ESCキーで終了します。");
if( CheckHitKey( KEY_INPUT_ESCAPE ) == 1 )
{
break;
}
}
else if( PC == 6 )
{
DrawGraph( 155, 88, Handle3, TRUE );
DrawGraph( 330, 88, Handle4, TRUE );
if( CheckHitKey(KEY_INPUT_1) == 0 && CheckHitKey(KEY_INPUT_2) == 0 && CheckHitKey(KEY_INPUT_1) == 0)
{
PlaySoundMem( Voice3, DX_PLAYTYPE_NORMAL );
PC = 15;
}
}
else if( PC == 15 )
{
DrawFormatString( 0, 40, GetColor(255,255,255), "「ポン!」");
DrawFormatString( 0, 60, GetColor(255,255,255),"あなた:チョキ");
DrawFormatString( 0, 80, GetColor(255,255,255),"あいて:パー");
DrawFormatString( 0, 100, GetColor(255, 255,255),"結果:あなたの勝ちです!");
DrawFormatString(0, 120, GetColor(255, 255, 0), "ESCキーで終了します。");
if( CheckHitKey( KEY_INPUT_ESCAPE ) == 1 )
{
break;
}
}
else if( PC == 7 )
{
DrawGraph( 155, 88, Handle4, TRUE );
DrawGraph( 330, 88, Handle2, TRUE );
if( CheckHitKey(KEY_INPUT_1) == 0 && CheckHitKey(KEY_INPUT_2) == 0 && CheckHitKey(KEY_INPUT_1) == 0)
{
PlaySoundMem( Voice6, DX_PLAYTYPE_NORMAL );
PC = 16;
}
else if( PC == 16 )
DrawFormatString( 0, 40, GetColor(255,255,255), "「ポン!」");
DrawFormatString( 0, 60, GetColor(255,255,255),"あなた:パー");
DrawFormatString( 0, 80, GetColor(255,255,255),"あいて:グー");
DrawFormatString( 0, 100, GetColor(255, 255,255),"結果:あなたの勝ちです!");
DrawFormatString(0, 120, GetColor(255, 255, 0), "ESCキーで終了します。");
if( CheckHitKey( KEY_INPUT_ESCAPE ) == 1 )
{
break;
}
}
else if( PC == 8 )
{
DrawGraph( 155, 88, Handle4, TRUE );
DrawGraph( 330, 88, Handle3, TRUE );
if( CheckHitKey(KEY_INPUT_1) == 0 && CheckHitKey(KEY_INPUT_2) == 0 && CheckHitKey(KEY_INPUT_1) == 0)
{
PlaySoundMem( Voice8, DX_PLAYTYPE_NORMAL );
PC = 17;
}
else if( PC == 17 )
DrawFormatString( 0, 40, GetColor(255,255,255), "「ポン!」");
DrawFormatString( 0, 60, GetColor(255,255,255),"あなた:パー");
DrawFormatString( 0, 80, GetColor(255,255,255),"あいて:チョキ");
DrawFormatString( 0, 100, GetColor(255, 255,255),"結果:あなたの負けです・・・");
DrawFormatString(0, 120, GetColor(255, 255, 0), "ESCキーで終了します。");
if( CheckHitKey( KEY_INPUT_ESCAPE ) == 1 )
{
break;
}
}
else if( PC == 9 )
{
DrawGraph( 155, 88, Handle4, TRUE );
DrawGraph( 330, 88, Handle4, TRUE );
if( CheckHitKey(KEY_INPUT_1) == 0 && CheckHitKey(KEY_INPUT_2) == 0 && CheckHitKey(KEY_INPUT_1) == 0)
{
PlaySoundMem( Voice7, DX_PLAYTYPE_NORMAL );
PC = 18;
}
else if( PC == 18 )
{
DrawFormatString( 0, 40, GetColor(255,255,255), "「ポン!」");
DrawFormatString( 0, 60, GetColor(255,255,255),"あなた:パー");
DrawFormatString( 0, 80, GetColor(255,255,255),"あいて:パー");
DrawFormatString( 0, 100, GetColor(255, 255,255),"結果:あいこです。");
DrawFormatString(0, 120, GetColor(255, 255, 0), "ESCキーで終了します。");
if( CheckHitKey( KEY_INPUT_ESCAPE ) == 1 )
{
break;
}
}
}
}
}
DxLib_End(); // DXライブラリ終了処理
return 0;
}