麻雀ゲームを作っているのですが、牌を配るところでうまく行きません
下のswitch命令でいうところの0〜2番の人に牌を配るまではうまく表示されるのですが、3番だけうまく表示されません
それどころか3番を通過した後の人まで表示位置が崩れてしまいます
色々調べたのですが、
case 3:
Player4[Rand] ++ ;
HaiNum4[HaiCount[3]] = Rand;
HaiCount[3] ++ ;
break ;
の中で
HaiNum4[HaiCount[3]]にRandが代入されるハズなのに何故か通過するたびに1加算されているみたいです
どうか解決策をお願いします
//透過色を設定
SetTransColor( 0 , 255 , 0 ) ;
//グラフィックハンドル
int GHHai[36];
int GHMat ;
GHHai[0] = LoadGraph("img/1man.bmp");
GHHai[1] = LoadGraph("img/2man.bmp");
GHHai[2] = LoadGraph("img/3man.bmp");
GHHai[3] = LoadGraph("img/4man.bmp");
GHHai[4] = LoadGraph("img/5man.bmp");
GHHai[5] = LoadGraph("img/5man_aka.bmp");
GHHai[6] = LoadGraph("img/7man.bmp");
GHHai[7] = LoadGraph("img/8man.bmp");
GHHai[8] = LoadGraph("img/9man.bmp");
GHHai[9] = LoadGraph("img/1pin.bmp");
GHHai[10] = LoadGraph("img/2pin.bmp");
GHHai[11] = LoadGraph("img/3pin.bmp");
GHHai[12] = LoadGraph("img/4pin.bmp");
GHHai[13] = LoadGraph("img/5pin.bmp");
GHHai[14] = LoadGraph("img/5pin_aka.bmp");
GHHai[15] = LoadGraph("img/6pin.bmp");
GHHai[16] = LoadGraph("img/7pin.bmp");
GHHai[17] = LoadGraph("img/8pin.bmp");
GHHai[18] = LoadGraph("img/9pin.bmp");
GHHai[19] = LoadGraph("img/1sou.bmp");
GHHai[20] = LoadGraph("img/2sou.bmp");
GHHai[21] = LoadGraph("img/3sou.bmp");
GHHai[22] = LoadGraph("img/4sou.bmp");
GHHai[23] = LoadGraph("img/5sou.bmp");
GHHai[24] = LoadGraph("img/5sou_aka.bmp");
GHHai[25] = LoadGraph("img/6sou.bmp");
GHHai[26] = LoadGraph("img/7sou.bmp");
GHHai[27] = LoadGraph("img/8sou.bmp");
GHHai[28] = LoadGraph("img/9sou.bmp");
GHHai[29] = LoadGraph("img/ton.bmp");
GHHai[30] = LoadGraph("img/nan.bmp");
GHHai[31] = LoadGraph("img/sya.bmp");
GHHai[32] = LoadGraph("img/pei.bmp");
GHHai[33] = LoadGraph("img/haku.bmp");
GHHai[34] = LoadGraph("img/hatu.bmp");
GHHai[35] = LoadGraph("img/tyun.bmp");
GHHai[36] = LoadGraph("img/null.bmp");
GHMat = LoadGraph("img/mat.jpg");
//山の牌
int Hai[35];
for(int i = 0 ;i <= 35; i++){
Hai[i] = 4 ;
}
//赤ドラ
Hai[5] = 1 ;
Hai[14] = 2 ;
Hai[24] = 1 ;
//牌の位置格納
int Player1_HaiX = 272;
int Player1_HaiY = 647;
int Player1_HaiX_Def = 272;
int Player1_HaiY_Def = 647;
int Player2_HaiX = 799;
int Player2_HaiY = 168;
int Player2_HaiX_Def = 799;
int Player2_HaiY_Def = 168;
int Player3_HaiX = 317;
int Player3_HaiY = 66;
int Player3_HaiX_Def = 317;
int Player3_HaiY_Def = 66;
int Player4_HaiX = 190;
int Player4_HaiY = 144;
int Player4_HaiX_Def = 190;
int Player4_HaiY_Def = 144;
//もち牌
int Player1[35] ;
int Player2[35] ;
int Player3[35] ;
int Player4[35] ;
//初期化
for(int i = 0 ;i < 35; i++){
Player1[i] = 0 ;
Player2[i] = 0 ;
Player3[i] = 0 ;
Player4[i] = 0 ;
}
int HaiCount[3] ;
HaiCount[0] = 0;
HaiCount[1] = 0;
HaiCount[2] = 0;
HaiCount[3] = 0;
int HaiNum1[13] ;
int HaiNum2[13] ;
int HaiNum3[13] ;
int HaiNum4[13] ;
for(int i = 0 ; i < 13 ;i ++ ){
HaiNum1[i] = 36;
HaiNum2[i] = 36;
HaiNum3[i] = 36;
HaiNum4[i] = 36;
}
int Rand ;
int Player = 0 ;//取る順番用
int HaipaiMainLoop ;
int HaipaiSubLoop ;
SetDrawScreen( DX_SCREEN_BACK ) ;
for(HaipaiMainLoop = 0 ; HaipaiMainLoop <= 11 ; HaipaiMainLoop ++){
for(HaipaiSubLoop = 0; HaipaiSubLoop <= 3; HaipaiSubLoop ++){
Rand = GetRand( 35 ) ; //ランダムで牌番号を取得
while(Hai[Rand] == 0){ //その牌番号の牌が山にまだ残っているか判定
Rand ++;
if(Rand == 36){ //ループの結果牌番号が最大数を超えたらリセット
Rand = 0;
}
}
switch(Player){
case 0:
Player1[Rand] ++ ;
HaiNum1[HaiCount[0]] = Rand;
HaiCount[0] ++ ;
break ;
case 1:
Player2[Rand] ++ ;
HaiNum2[HaiCount[1]] = Rand;
HaiCount[1] ++ ;
break ;
case 2:
Player3[Rand] ++ ;
HaiNum3[HaiCount[2]] = Rand;
HaiCount[2] ++ ;
break ;
case 3:
Player4[Rand] ++ ;
HaiNum4[HaiCount[3]] = Rand;
HaiCount[3] ++ ;
break ;
}
Hai[Rand] -- ;//牌が確定したら残数から個数を引く
}
Player ++ ;
if(Player == 4){
Player = 0 ;
}
//一斉描画
ClearDrawScreen() ;
DrawGraph(0,0,GHMat,FALSE);
DrawGraph(Player1_HaiX,Player1_HaiY,GHHai[HaiNum1[0]],TRUE);
Player1_HaiX = Player1_HaiX + 35;
DrawGraph(Player1_HaiX,Player1_HaiY,GHHai[HaiNum1[1]],TRUE);
Player1_HaiX = Player1_HaiX + 35;
DrawGraph(Player1_HaiX,Player1_HaiY,GHHai[HaiNum1[2]],TRUE);
Player1_HaiX = Player1_HaiX + 35;
DrawGraph(Player1_HaiX,Player1_HaiY,GHHai[HaiNum1[3]],TRUE);
Player1_HaiX = Player1_HaiX + 35;
DrawGraph(Player1_HaiX,Player1_HaiY,GHHai[HaiNum1[4]],TRUE);
Player1_HaiX = Player1_HaiX + 35;
DrawGraph(Player1_HaiX,Player1_HaiY,GHHai[HaiNum1[5]],TRUE);
Player1_HaiX = Player1_HaiX + 35;
DrawGraph(Player1_HaiX,Player1_HaiY,GHHai[HaiNum1[6]],TRUE);
Player1_HaiX = Player1_HaiX + 35;
DrawGraph(Player1_HaiX,Player1_HaiY,GHHai[HaiNum1[7]],TRUE);
Player1_HaiX = Player1_HaiX + 35;
DrawGraph(Player1_HaiX,Player1_HaiY,GHHai[HaiNum1[8]],TRUE);
Player1_HaiX = Player1_HaiX + 35;
DrawGraph(Player1_HaiX,Player1_HaiY,GHHai[HaiNum1[9]],TRUE);
Player1_HaiX = Player1_HaiX + 35;
DrawGraph(Player1_HaiX,Player1_HaiY,GHHai[HaiNum1[10]],TRUE);
Player1_HaiX = Player1_HaiX + 35;
DrawGraph(Player1_HaiX,Player1_HaiY,GHHai[HaiNum1[11]],TRUE);
Player1_HaiX = Player1_HaiX + 35;
Player1_HaiX = Player1_HaiX_Def ;
DrawGraph(Player2_HaiX,Player2_HaiY,GHHai[HaiNum2[0]],TRUE);
Player2_HaiY = Player2_HaiY + 35;
DrawGraph(Player2_HaiX,Player2_HaiY,GHHai[HaiNum2[1]],TRUE);
Player2_HaiY = Player2_HaiY + 35;
DrawGraph(Player2_HaiX,Player2_HaiY,GHHai[HaiNum2[2]],TRUE);
Player2_HaiY = Player2_HaiY + 35;
DrawGraph(Player2_HaiX,Player2_HaiY,GHHai[HaiNum2[3]],TRUE);
Player2_HaiY = Player2_HaiY + 35;
DrawGraph(Player2_HaiX,Player2_HaiY,GHHai[HaiNum2[4]],TRUE);
Player2_HaiY = Player2_HaiY + 35;
DrawGraph(Player2_HaiX,Player2_HaiY,GHHai[HaiNum2[5]],TRUE);
Player2_HaiY = Player2_HaiY + 35;
DrawGraph(Player2_HaiX,Player2_HaiY,GHHai[HaiNum2[6]],TRUE);
Player2_HaiY = Player2_HaiY + 35;
DrawGraph(Player2_HaiX,Player2_HaiY,GHHai[HaiNum2[7]],TRUE);
Player2_HaiY = Player2_HaiY + 35;
DrawGraph(Player2_HaiX,Player2_HaiY,GHHai[HaiNum2[8]],TRUE);
Player2_HaiY = Player2_HaiY + 35;
DrawGraph(Player2_HaiX,Player2_HaiY,GHHai[HaiNum2[9]],TRUE);
Player2_HaiY = Player2_HaiY + 35;
DrawGraph(Player2_HaiX,Player2_HaiY,GHHai[HaiNum2[10]],TRUE);
Player2_HaiY = Player2_HaiY + 35;
DrawGraph(Player2_HaiX,Player2_HaiY,GHHai[HaiNum2[11]],TRUE);
Player2_HaiY = Player2_HaiY + 35;
Player2_HaiY = Player2_HaiY_Def ;
DrawGraph(Player3_HaiX,Player3_HaiY,GHHai[HaiNum3[0]],TRUE);
Player3_HaiX = Player3_HaiX + 35;
DrawGraph(Player3_HaiX,Player3_HaiY,GHHai[HaiNum3[1]],TRUE);
Player3_HaiX = Player3_HaiX + 35;
DrawGraph(Player3_HaiX,Player3_HaiY,GHHai[HaiNum3[2]],TRUE);
Player3_HaiX = Player3_HaiX + 35;
DrawGraph(Player3_HaiX,Player3_HaiY,GHHai[HaiNum3[3]],TRUE);
Player3_HaiX = Player3_HaiX + 35;
DrawGraph(Player3_HaiX,Player3_HaiY,GHHai[HaiNum3[4]],TRUE);
Player3_HaiX = Player3_HaiX + 35;
DrawGraph(Player3_HaiX,Player3_HaiY,GHHai[HaiNum3[5]],TRUE);
Player3_HaiX = Player3_HaiX + 35;
DrawGraph(Player3_HaiX,Player3_HaiY,GHHai[HaiNum3[6]],TRUE);
Player3_HaiX = Player3_HaiX + 35;
DrawGraph(Player3_HaiX,Player3_HaiY,GHHai[HaiNum3[7]],TRUE);
Player3_HaiX = Player3_HaiX + 35;
DrawGraph(Player3_HaiX,Player3_HaiY,GHHai[HaiNum3[8]],TRUE);
Player3_HaiX = Player3_HaiX + 35;
DrawGraph(Player3_HaiX,Player3_HaiY,GHHai[HaiNum3[9]],TRUE);
Player3_HaiX = Player3_HaiX + 35;
DrawGraph(Player3_HaiX,Player3_HaiY,GHHai[HaiNum3[10]],TRUE);
Player3_HaiX = Player3_HaiX + 35;
DrawGraph(Player3_HaiX,Player3_HaiY,GHHai[HaiNum3[11]],TRUE);
Player3_HaiX = Player3_HaiX + 35;
Player3_HaiX = Player3_HaiX_Def ;
DrawGraph(Player4_HaiX,Player4_HaiY,GHHai[HaiNum4[0]],TRUE);
Player4_HaiY = Player4_HaiY + 35;
DrawGraph(Player4_HaiX,Player4_HaiY,GHHai[HaiNum4[1]],TRUE);
Player4_HaiY = Player4_HaiY + 35;
DrawGraph(Player4_HaiX,Player4_HaiY,GHHai[HaiNum4[2]],TRUE);
Player4_HaiY = Player4_HaiY + 35;
DrawGraph(Player4_HaiX,Player4_HaiY,GHHai[HaiNum4[3]],TRUE);
Player4_HaiY = Player4_HaiY + 35;
DrawGraph(Player4_HaiX,Player4_HaiY,GHHai[HaiNum4[4]],TRUE);
Player4_HaiY = Player4_HaiY + 35;
DrawGraph(Player4_HaiX,Player4_HaiY,GHHai[HaiNum4[5]],TRUE);
Player4_HaiY = Player4_HaiY + 35;
DrawGraph(Player4_HaiX,Player4_HaiY,GHHai[HaiNum4[6]],TRUE);
Player4_HaiY = Player4_HaiY + 35;
DrawGraph(Player4_HaiX,Player4_HaiY,GHHai[HaiNum4[7]],TRUE);
Player4_HaiY = Player4_HaiY + 35;
DrawGraph(Player4_HaiX,Player4_HaiY,GHHai[HaiNum4[8]],TRUE);
Player4_HaiY = Player4_HaiY + 35;
DrawGraph(Player4_HaiX,Player4_HaiY,GHHai[HaiNum4[9]],TRUE);
Player4_HaiY = Player4_HaiY + 35;
DrawGraph(Player4_HaiX,Player4_HaiY,GHHai[HaiNum4[10]],TRUE);
Player4_HaiY = Player4_HaiY + 35;
DrawGraph(Player4_HaiX,Player4_HaiY,GHHai[HaiNum4[11]],TRUE);
Player4_HaiY = Player4_HaiY + 35;
Player4_HaiY = Player4_HaiY_Def ;
// 裏画面の内容を表画面に反映させる
ScreenFlip() ;
// Windows システムからくる情報を処理する
if( ProcessMessage() == -1 ) break ;
WaitTimer( 800 ) ;
}