#game.draw_collision_mode true
game.loading do |loader|
loader.add :window, :system => "window"
loader.add :gui_item, :system => "gui_item"
end
game.on_init do
set_window_image :window
set_gui_image :gui_item
scene_change :test_scene
end
##テストシーン
scene :test_scene do |sc|
sc.on_init do
CardDeckFullInit()
InitMyCard()
#DispCard()
ShuffleCard()
#DispCard()
#GetCard()
#DispMyCard()
#SearchCard(1, 1)
####
sample1()
end
end
##動作サンプル1
def sample1()
speak("トランプ全52枚から5枚を取り出す動作サンプルです")
for num in 0..4 do
GetCard()
end
DispMyCard()
speak("動作テストを終了します")
game.change_project "start_menu"
end
##表示
def DispCard()
tempPrint = ""
for num in 0..(DeckCnt - 1) do
tempPrint = tempPrint + Markings[CardDeckFull[num].mark] + Numings[CardDeckFull[num].number] + " "
end
speak(tempPrint)
end
##マイカード表示
def DispMyCard()
tempPrint = ""
for num in 0..(MyCardsCnt - 1) do
tempPrint = tempPrint + Markings[MyCards[num].mark] + Numings[MyCards[num].number] + " "
end
speak(tempPrint)
end
##シャッフル
def ShuffleCard()
for num in 0..51 do
r = rand(51)
w = CardDeckFull[num]
CardDeckFull[num] = CardDeckFull[r]
CardDeckFull[r] = w
end
end
##サーチ
def SearchCard(markTemp, numTemp)
tempPrint = ""
num = 0
for num in 0..51 do
if (CardDeckFull[num].number == numTemp)
if (CardDeckFull[num].mark == markTemp)
break
end
end
end
tempPrint = tempPrint + Markings[CardDeckFull[num].mark] + Numings[CardDeckFull[num].number]
speak(tempPrint)
end
##カード取得
def GetCard()
cTemp = 0
if (DeckCnt > 0)
cTemp = CardDeckFull[0]
for num in 0..(DeckCnt - 2) do
CardDeckFull[num] = CardDeckFull[num + 1]
end
DeckCnt = DeckCnt - 1
MyCards[MyCardsCnt] = cTemp
MyCardsCnt = MyCardsCnt + 1
end
end
##大域変数関係
Markings = ["♠", "♣", "♦", "♥"]
Numings = ["", "A", "2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K"]
CardDeckFull = []
DeckCnt = 52
MyCards = []
MyCardsCnt = 0
##データベース構造体関係
class CardData
def initialize(mark, number)
@mark = mark
@number = number
end
attr_accessor :mark, :number
end
def CardDeckFullInit()
x = 0
for num1 in 1..13 do
for num2 in 0..3 do
CardDeckFull[x] = CardData.new(num2, num1)
x = x + 1
end
end
end
def InitMyCard()
MyCardsCnt = 0
end
#http://www50.atwiki.jp/mhikichi/pages/21.html