HSP講座シリーズ
簡単なポーカーゲームを作る講座です。
リンク先はニコニコ動画です。

第1回 2008/4/6投稿
第2回 2008/4/8投稿
第3回 2008/4/27投稿
第4回 2008/5/6投稿
第5回 2008/5/17投稿
第6回 2008/6/15投稿
第7回 2009/3/28投稿
第8回 2009/11/17投稿
第9回 2010/6/28投稿
第10回 2012/3/17投稿
第11回 2013/1/21投稿




ここから下は講義に使用したプログラムです。
動画の通りに作っても
エラーが出て動かせないという方が居られる様なので
載せておきます。(動画の更新毎に追加していきます)

単なる説明不足か、あるいは動画作成中の手違いか。
いずれにせよ、視聴者様を混乱させた事をお詫びいたします。


ここから---------------------------

*window_stanby
;画面用意!
buffer 1,400,400
picload "taitoru.jpg"
screen 0,400,400
pos 0,0
gcopy 1,0,0,400,400
dim card,52,2

*title_part
pos 50,50
button "Start",*card_stanby
stop

*card_stanby
;カード用意!
clrobj
repeat 4
a=0
b=cnt
repeat 13
a+
c=b*13+(a-1)
card.c.0=a
card.c.1=b
loop
loop

*card_mazemaze
;カードを混ぜる
randomize
repeat 100
rn1=rnd(52)
rn2=rnd(52)
change0=card.rn1.0
change1=card.rn1.1
card.rn1.0=card.rn2.0
card.rn1.1=card.rn2.1
card.rn2.0=change0
card.rn2.1=change1
loop

*card_hyouji
;カードの表示
dim changesw,5
*koukan_return
repeat 5

color 255,255,255
boxf cnt*75+15,100,cnt*75+85,200

pos cnt*75+17,103
color 0,0,0
mes card.cnt.0

pos cnt*75+70,180
if card.cnt.1=0 :mes "S"
if card.cnt.1=1 :mes "H"
if card.cnt.1=2 :mes "C"
if card.cnt.1=3 :mes "D"

loop

pos 0*75+20,210
if changesw.0=0 :button " ",*koukan0 :else :button "変",*koukan0
pos 1*75+20,210
if changesw.1=0 :button " ",*koukan1 :else :button "変",*koukan1
pos 2*75+20,210
if changesw.2=0 :button " ",*koukan2 :else :button "変",*koukan2
pos 3*75+20,210
if changesw.3=0 :button " ",*koukan3 :else :button "変",*koukan3
pos 4*75+20,210
if changesw.4=0 :button " ",*koukan4 :else :button "変",*koukan4

pos 300,300
button "G O !!",*go

stop

*koukan0
if changesw.0=0 :changesw.0=1 :else :changesw.0=0
clrobj
goto *koukan_return
*koukan1
if changesw.1=0 :changesw.1=1 :else :changesw.1=0
clrobj
goto *koukan_return
*koukan2
if changesw.2=0 :changesw.2=1 :else :changesw.2=0
clrobj
goto *koukan_return
*koukan3
if changesw.3=0 :changesw.3=1 :else :changesw.3=0
clrobj
goto *koukan_return
*koukan4
if changesw.4=0 :changesw.4=1 :else :changesw.4=0
clrobj
goto *koukan_return

*go
;変カードを交換
clrobj
repeat 5
if changesw.cnt=1 :{
change2=card.cnt.0
card.cnt.0=card.(cnt+5).0
card.(cnt+5).0=change2

change3=card.cnt.1
card.cnt.1=card.(cnt+5).1
card.(cnt+5).1=change3
}

color 255,255,255
boxf cnt*75+15,100,cnt*75+85,200

pos cnt*75+17,103
color 0,0,0
mes card.cnt.0

pos cnt*75+70,180
if card.cnt.1=0 :mes "S"
if card.cnt.1=1 :mes "H"
if card.cnt.1=2 :mes "C"
if card.cnt.1=3 :mes "D"
loop

*sort
;役判定準備(昇順バブルソート)
dim yaku,5,2

repeat 5
yaku.cnt.0=card.cnt.0
yaku.cnt.1=card.cnt.1
loop

repeat 4
repeat 4
if yaku.cnt.0>yaku.(cnt+1).0 :{
change4=yaku.cnt.0
yaku.cnt.0=yaku.(cnt+1).0
yaku.(cnt+1).0=change4

change5=yaku.cnt.1
yaku.cnt.1=yaku.(cnt+1).1
yaku.(cnt+1).1=change5
}
loop
loop

repeat 5
color 255,255,255
boxf cnt*75+15,100,cnt*75+85,200

pos cnt*75+17,103
color 0,0,0
mes yaku.cnt.0

pos cnt*75+70,180
if yaku.cnt.1=0 :mes "S"
if yaku.cnt.1=1 :mes "H"
if yaku.cnt.1=2 :mes "C"
if yaku.cnt.1=3 :mes "D"
loop

*yaku_check
;役判定
check=0
straight=0
flush=0

;ワンペア
repeat 4
if yaku.cnt.0=yaku.(cnt+1) :check=1
loop

;ツーペア
repeat 2
if yaku.cnt.0=yaku.(cnt+1).0 and yaku.(cnt+2).0=yaku.(cnt+3).0 :check=2
loop

;スリーカード
repeat 3
if yaku.cnt.0=yaku.(cnt+1).0 and yaku.cnt.0=yaku.cnt.0+(cnt+2) :check=3
loop

;ストレート
if yaku.0.0+1=yaku.1.0 and yaku.1.0+1=yaku.2.0 and yaku.2.0+1=yaku.3.0 and yaku.3.0+1=yaku.4.0 :{
straight=1
check=4
}

;フラッシュ
if yaku.0.1=yaku.1.1 and yaku.1.1=yaku.2.1 and yaku.2.1=yaku.3.1 and yaku.3.1=yaku.4.1 :{
flush=1
check=5
}

;フルハウス
if yaku.0.0=yaku.1.0 and yaku.1.0=yaku.2.0 and yaku.3.0=yaku.4.0 :{
check=6
}
if yaku.0.0=yaku.1.0 and yaku.2.0=yaku.3.0 and yaku.3.0=yaku.4.0 :{
check=6
}

;フォーカード
repeat 2
if yaku.cnt.0=yaku.(cnt+1).0 and yaku.cnt.0=yaku.cnt.0+(cnt+2) and yaku.cnt.0=yaku.(cnt+3).0 :check=7
loop

;ストレートフラッシュ
if straight=1 and flush=1 :check=8

;ロイヤルストレートフラッシュ
if flush=1 and yaku.cnt.0=1 and yaku.cnt.0=10 and yaku.cnt.0=11 and yaku.cnt.0=12 and yaku.cnt.0=13 :{
check=9
}

---------------------------------ここまで
2013/5/1更新

inserted by FC2 system