多くのタッチエリアを設定しています。
画面表示の関係上、iPadの縦画面専用です。
//--------------------------------------------------------------------------------
/* BINGO
// for X-BASIC for iOS v2.0
//--------------------------------------------------------------------------------
if deviceType()<>DEVICE_IPAD and deviceType()<>DEVICE_IPAD_SIMULATOR then {
print localizedString("このプログラムはiPad専用です","This program only for iPad.")
end
}
dim int A(5,11),B(12,2)
dim int keyAreaNo(5,5)
int d,L,T,E,F
int WX,WY
int sx,sy,ex,ey
int OPEND=100:// 定数
/*
srand2()
width(64)
getWidth(WX,WY)
setUpScroll(NO):// テキスト画面の上スクロールを止める (V2.0)
apage(GPAGE0)
vpage(B_TPAGE or B_GPAGE0 or B_GPAGE1,YES)
//display_title()
d=0
dim str menues(1)
str title
int e
repeat
cls()
apage(GPAGE1):wipe()
apage(GPAGE0):wipe()
gcolor(-TWHITE,0,0,255)
symbol(128,2,"BINGO GAME","IPAGothic",48)
gcolor(-THWHITE,0,0,255)
symbol(129,3,"BINGO GAME","IPAGothic",48)
gcolor(-THRED,0,0,255)
box(13,64,748,614)
tcolor(-THWHITE,0,0,255)
shuffle():// 数字の設定
field_print():// 数字表示&タッチエリア設定
print_number(NO)
/*
if isLocalizeJapan() then {
menues={"先手","後手"}
title="順番選択"
} else {
menues={"First move","Passive move"}
title="Moving order"
}
repeat
L=selectMenu2(title,menues):// -1,0,1
until L>=0:// -1=BREAK/outside menu touch
L=L+1:// 0,1->1,2
sub_cls()
/*
for e=0 to 12
B(e,0)=0
B(e,1)=0
B(e,2)=0
next
E=0:F=0:T=0
repeat
T=T+1
tcolor(-THWHITE,0,0,255)
locate(6,17)
if isLocalizeJapan() then {
print"第";T;"手"
} else {
print"The";T;" hand"
}
repeat
switch L
case 1:
locate(11,19)
print localizedString("あなた:","You : ");
d=input_num()
L=2
break
case 2:
locate(38,19)
print localizedString("コンピューター:","Computer : ");
d=com_num()
//beep()
L=1
break
endswitch
int cx=pos()
int cy=csrlin()
int ffind=check_num(d)
if not ffind then {
// 見つからなかった
// 人間側のみありえる
L=1
beep()
// 選択しなおし
}
until ffind
locate(cx,cy):print d
until (F>=5) or (E>=5)
resetALlKeys():// タッチエリアの解除
sub_cls()
print_number(YES)
hantei(E,F)
locate(11,24)
if isLocalizeJapan() then {
print "御苦労さまでした"
menues={"はい","いいえ"}
title="もう一度しますか?"
} else {
print "Cheers for hard work was."
menues={"YES","NO"}
title="Try again ?"
}
L=selectMenu2(title,menues):// -1=stop,0=YES,1=NO
until L=1 or L=-1
end
//--------------------------------------------------------------------------------
// functions
//--------------------------------------------------------------------------------
func hantei(E;int,F;int)
/* 勝ち負け判定
tcolor(-THYELLOW,0,0,255)
locate(10,23)
if isLocalizeJapan() then {
print E;" 対";F;"で ";
}
if F<E then {
print localizedString("あなたの勝ち","You win");
} else {
if E<F then {
print localizedString("コンピューターの勝ち","Computer win");
} else {
print localizedString("引き分け","Draw");
}
}
if not isLocalizeJapan() then {
print " in the";E;"-for-";F
}
endfunc
/*
func int input_num()
/* 人間の数字選択
int num
// kbclr()
// キー入力待ち
while not kbhit()
endwhile
// エリアをタッチすると、数字がキーコードとして返ってくる
num=inkey()
return(num)
endfunc
/*
func int check_num(d;int)
/* 番号チェック&マスオープン
int h,x,y,ac,bb,i,j
for h=1 to 2:// 両方を調べる
// 数字からマス座標を得る
int ffind=NO
for i=1 to 5
for j=1 to 5
ac=A(i,j+(h-1)*6)
if ac=d then {
x=i:y=j
ffind=YES
break
}
next
if ffind then break
next
if not ffind then {
// 見つからない
locate(0,5):print "見つからない"
return (NO)
}
//
apage(GPAGE1)
switch h
case 1:gcolor(-THMAGENTA,0,0,200):break
case 2:gcolor(-THGREEN ,0,0,200):break
endswitch
calc_grid_gxy(x,y,h-1):// ->sx,sy,ex,ey
fill(sx,sy,ex,ey)
apage(GPAGE0)
//
A(x,y+(h-1)*6)=ac+OPEND:/* 開いたの印
bb=0
if x=y then bb=B(12,h):B(12,h)=bb+1
if x=6-y then bb=B(11,h):B(11,h)=bb+1
bb=B(x,h) :B(x ,h)=bb+1
bb=B(y+5,h):B(y+5,h)=bb+1
x=0
for i=1 to 12
x=x+B(i,h)\5
next
if (h=1) and (E<x) then {
locate(11,15)
if isLocalizeJapan() then {
print "あなた:";x;"列"
} else {
print "You :";x;" lines"
}
E=x
beep2(7)
} else {
if (h=2)*(F<x) then {
locate(38,15)
if isLocalizeJapan() then {
print "コンピューター:";x;"列"
} else {
print "Computer :";x;" lines"
}
F=x
beep2(8)
}
}
next
// 見つかって処理した
return (YES)
endfunc
/*
func int com_num()
/* コンピューターの番号考え
int i,j,m,bb,c
m=0
for i=1 to 5
for j=1 to 5
bb=0
if A(i,j+6)<OPEND then {
if i=j then bb= 1+B(12,2)
if i=6-j then bb=bb+1+B(11,2)
bb=bb+2+B(i,2)+B(j+5,2)
if bb>m then c=A(i,j+6):m=bb
}
next
next
// locate(0,26):print "com=";c
return(c)
endfunc
/*
func sub_cls()
/* 画面一部クリア
int y
for y=16 to WY
locate(0,y):print space$(WX);
next
endfunc
/*
func shuffle()
/* マス内数字シャッフル
int i,j,l,h
int c,x,y
for l=0 to 1:/* l=0:あなた , 1=コンピューター
/* まずはマス内に順番に数字を入れる
/* A(i,j) : j=1〜5:あなた , 6〜11:コンピューター
h=0
for i=1 to 5
for j=1 to 5
h=h+1
A(i,j+l*6)=h
next
next
/* マスを入れ替える
for i=1 to 5
for j=1 to 5
x=rand() mod 5+1
y=rand() mod 5+1+l*6
c=A(i,j+l*6)
A(i,j+l*6)=A(x,y)
A(x,y)=c
next
next
next
endfunc
/*
func print_number(mode;int)
/* マス内番号表示
// mode : NO=人側のみ開く , YES=コンピューター側を開く
int i,j,c
int x,y
tcolor(-THWHITE,0,0,255)
for i=1 to 5
x=(i-1)*5
for j=1 to 5
y=j*2+2
if not mode then {
// 人側(Human)のみ開く
c=A(i,j)
if c>OPEND then c=c-OPEND:/* すでに開いているマスの時
locate(x+ 7,y):print using "##";c
locate(x+36,y):print "??"
} else {
// コンピューター側(Computer)を開く
c=A(i,j+6)
if c>OPEND then c=c-OPEND:/* すでに開いているマスの時
locate(x+36,y):print using "##";c
}
next
next
endfunc
/*
func field_print()
/* フィールド描画
// 先にshuffle()で数字を確定しておくこと
int l,i,j
for l=0 to 1:/* l=0:あなた , 1=コンピューター
if l=0 then {
tcolor(-THCYAN,0,0,255)
locate(11,14)
print localizedString("あなたのマス目","Your grid")
} else {
tcolor(-THYELLOW,0,0,255)
locate(36,14)
print localizedString("コンピューターのマス目"," Computer grid ")
}
// ます線描画
gcolor(-THMAGENTA,0,0,255)
for i=1 to 5
for j=1 to 5
calc_grid_gxy(i,j,l):// ->sx,sy,ex,ey
box(sx,sy,ex,ey)
if l=0 then {
// タッチエリアの設定
// 人間側のみ
// キーコードに数字を入れておく
keyAreaNo(i,j)=setTouchArea(sx,sy,(ex-sx),(ey-sy),A(i,j),YES)
// save touch area No into keyAreaNo()
}
next
next
next
tcolor(-THWHITE,0,0,255)
endfunc
/*
func resetALlKeys()
// 全タッチアリアの解除(重要)
int i,j
for i=1 to 5
for j=1 to 5
removeTouchArea(keyAreaNo(i,j))
next
next
endfunc
/*
func calc_grid_gxy(i;int,j;int,l;int)
// マス目座標からグラフィック表示座標を得る
int x,y
x=textX2Gx((i-1)*5+7)+l*340
y=textY2Gy(j*2+2)
// 以下リターン値(グローバル変数)
ex=textX2Gx((i-1+1)*5+7)+l*340-12
ey=textY2Gy((j+1)*2+2)-12
sx=x-12
sy=y-12
endfunc
/*
func display_title()
/* タイトル描画
int i,x
str s,s1
wipe()
lineWidth(2)
gcolor(-THRED,0,0,255)
box(61,4,448,128)
gcolor(-THMAGENTA,0,0,200)
fill(63,6,446,126)
s="BINGO"
for i=0 to 4
x=i*70+90
s1=utf8Mid$(s,i+1,1)
gcolor(-TWHITE,0,0,255)
symbol(x-11,16,s1,"Times New Roman",64)
gcolor(-THWHITE,0,0,255)
symbol(x-9 ,18,s1,"Times New Roman",64)
next
/*
gcolor(-TGREEN,0,0,255) :fill(112,180,400,320)
//
str copyright="Presented by AIG-SOFT"
str forMachine="for X-BASIC or iOS"
gcolor(-TWHITE,0,0,255)
symbol(170,201,copyright,"IPAGothic",16)
symbol(180,231,forMachine,"IPAGothic",16)
gcolor(-THWHITE,0,0,255)
symbol(169,200,copyright,"IPAGothic",16)
symbol(179,230,forMachine,"IPAGothic",16)
//
gcolor(-THRED,0,0,255)
box(109,178,403,324)
hitKey()
endfunc
/*
func srand2()
/* 乱数初期化
int t
t=val(right$(time$,2))+val(mid$(time$,4,2))
srand(t*16)
endfunc
/*
func hitKey()
setFunctionKey(0,localizedString("ここを押してください","Hit This Button"),'!')
displayFunctionKey(YES,0,0)
while inkey()=0
endwhile
cls()
displayFunctionKey(NO,0,0)
endfunc
func str localizedString(js;str,es;str)
if isLocalizeJapan() then return(js)
return (es)
endfunc
//--------------------------------------------------------------------------------
Zipファイル :XBbingo.zip
0 件のコメント:
コメントを投稿