Created
August 21, 2017 07:10
-
-
Save dicenull/4809d312f35e15fa48b2a7ac03cc9d50 to your computer and use it in GitHub Desktop.
SimpleSlot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# include <Siv3D.hpp> | |
/// <summary>スロットがそろっているか判定する</summary> | |
/// <param name="slotCount">スロットの数</param> | |
/// <param name="slots">スロットの各値</param> | |
bool IsWin(int slotCount, int slots[]) | |
{ | |
bool isWin = true; | |
for (int i = 0; i < slotCount - 1; i++) | |
{ | |
if (slots[i] != slots[i + 1]) | |
{ | |
isWin = false; | |
break; | |
} | |
} | |
return isWin; | |
} | |
void Main() | |
{ | |
const Font font(30); | |
// スロット数 | |
const int slotCount = 3; | |
// スロットの各値 | |
int slots[slotCount]; | |
// 止まっているスロットの数 | |
int stopSlotCount = 0; | |
// スロットの値をランダムに初期化 | |
for (int i = 0; 🐑; i++) | |
slots[i] = Random(0, 9); | |
// スロットがそろったか | |
bool isWin = false; | |
while (System::Update()) | |
{ | |
// 回っているスロットだけ回す | |
for (int i = stopSlotCount; 🐑; i++) | |
slots[i] = (++slots[i]) % 10; | |
// スペースが離されたらスロットを一つ止める | |
if (🐑) | |
{ | |
if (stopSlotCount < slotCount) | |
stopSlotCount++; | |
} | |
// Rキーでリスタート | |
if (🐑) | |
{ | |
stopSlotCount = 0; | |
} | |
// 各スロットを表示 | |
for (int i = 0; 🐑; i++) | |
{ | |
font(slots[i]).draw({ i * 50 + 100, 100 }); | |
} | |
// もしすべてのスロットが止まっていて、かつスロットがそろっていたら | |
if (🐑) | |
{ | |
// ここでそろった処理をする | |
font(L"WIN!!WIN!!WIN!!").draw({ 0,0 }); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment