現在僕はDXライブラリでポーカーゲームを作っています。トランプカードのpngを52枚LoadGraphし、card_Gtaphic[52]として定義しました。
次はその52枚の中からランダムに5枚ずつ、計10枚画像を表示させたいのですがどのようにすればいいですか?
DXライブラリのリファレンスで調べるとGetRandという関数が出てきますがいまいち使い方がわからないです。未熟ですがソースを添付しておきます。```C++
コード
int card_Graphic[52]; void load() { card_Graphic[0] = LoadGraph("Card\A-1.png"); card_Graphic[1] = LoadGraph("Card\A-2.png"); card_Graphic[2] = LoadGraph("Card\A-3.png"); card_Graphic[3] = LoadGraph("Card\A-4.png"); card_Graphic[4] = LoadGraph("Card\A-5.png"); card_Graphic[5] = LoadGraph("Card\A-6.png"); card_Graphic[6] = LoadGraph("Card\A-7.png"); card_Graphic[7] = LoadGraph("Card\A-8.png"); card_Graphic[8] = LoadGraph("Card\A-9.png"); card_Graphic[9] = LoadGraph("Card\A-10.png"); card_Graphic[10] = LoadGraph("Card\A-11.png"); card_Graphic[11] = LoadGraph("Card\A-12.png"); card_Graphic[12] = LoadGraph("Card\A-13.png"); card_Graphic[13] = LoadGraph("Card\B-1.png"); card_Graphic[14] = LoadGraph("Card\B-2.png"); card_Graphic[15] = LoadGraph("Card\B-3.png"); card_Graphic[16] = LoadGraph("Card\B-4.png"); card_Graphic[17] = LoadGraph("Card\B-5.png"); card_Graphic[18] = LoadGraph("Card\B-6.png"); card_Graphic[19] = LoadGraph("Card\B-7.png"); card_Graphic[20] = LoadGraph("Card\B-8.png"); card_Graphic[21] = LoadGraph("Card\B-9.png"); card_Graphic[22] = LoadGraph("Card\B-10.png"); card_Graphic[23] = LoadGraph("Card\B-11.png"); card_Graphic[24] = LoadGraph("Card\B-12.png"); card_Graphic[25] = LoadGraph("Card\B-13.png"); card_Graphic[26] = LoadGraph("Card\C-1.png"); card_Graphic[27] = LoadGraph("Card\C-2.png"); card_Graphic[28] = LoadGraph("Card\C-3.png"); card_Graphic[29] = LoadGraph("Card\C-4.png"); card_Graphic[30] = LoadGraph("Card\C-5.png"); card_Graphic[31] = LoadGraph("Card\C-6.png"); card_Graphic[32] = LoadGraph("Card\C-7.png"); card_Graphic[33] = LoadGraph("Card\C-8.png"); card_Graphic[34] = LoadGraph("Card\C-9.png"); card_Graphic[35] = LoadGraph("Card\C-10.png"); card_Graphic[36] = LoadGraph("Card\C-11.png"); card_Graphic[37] = LoadGraph("Card\C-12.png"); card_Graphic[38] = LoadGraph("Card\C-13.png"); card_Graphic[39] = LoadGraph("Card\D-1.png"); card_Graphic[40] = LoadGraph("Card\D-2.png"); card_Graphic[41] = LoadGraph("Card\D-3.png"); card_Graphic[42] = LoadGraph("Card\D-4.png"); card_Graphic[43] = LoadGraph("Card\D-5.png"); card_Graphic[44] = LoadGraph("Card\D-6.png"); card_Graphic[45] = LoadGraph("Card\D-7.png"); card_Graphic[46] = LoadGraph("Card\D-8.png"); card_Graphic[47] = LoadGraph("Card\D-9.png"); card_Graphic[48] = LoadGraph("Card\D-10.png"); card_Graphic[49] = LoadGraph("Card\D-11.png"); card_Graphic[50] = LoadGraph("Card\D-12.png"); card_Graphic[51] = LoadGraph("Card\D-13.png"); } int WINAPI WinMain(HINSTANCE hI, HINSTANCE hP, LPSTR lpC, int nC) { ChangeWindowMode(true); DxLib_Init(); int haikei, Mouse, mozi; haikei = LoadGraph("haikei.jpg"); DrawRotaGraph(320, 240, 0.5, 0.0, haikei, TRUE); mozi = CreateFontToHandle("MS ゴシック", 50, 9, DX_FONTTYPE_NORMAL); while (1) { ProcessMessage(); DrawStringToHandle(100, 70, "ポーカーゲーム開始。", GetColor(255, 255, 255), mozi); Mouse = GetMouseInput(); if (Mouse & MOUSE_INPUT_LEFT) { break; } WaitKey(); } DxLib_End(); return 0; }
回答2件
あなたの回答
tips
プレビュー