ソラマメブログ
訪問ありがとう☆
QRコード
QRCODE

2008年06月13日

数字当てゲーム(一人用)

作品No.002【数字当てゲーム】
☆遊び方☆
1.自動で3つの数字が決まります(見えない)(例175)
2.その数字を予想して3つの数字をしゃべります(例159)
3.1は場所と数字があっているのでone strikeとなります。
4.5は数字はあっていますが場所が違うのでone ballとなります。
5.これを繰り返し数字と場所を当てます。

integer first ;
integer second ;
integer third ;
integer sfirst;
integer ssecond;
integer sthird;
integer i=1;
key toucherid;
integer handle;


reset(){
toucherid=NULL_KEY;
llListenRemove(handle);}

decision(){
first = llFloor(llFrand(9.0))+1;
second =llFloor(llFrand(9.0))+1;
third =llFloor(llFrand(9.0))+1;}

default{
state_entry(){
llSetTouchText("number baseball Game");
reset();
}

on_rez(integer r){
llResetScript();
}

touch_start(integer x){
toucherid=llDetectedKey(0);
do{
decision();}
while(first==second ||first==third || second ==third);
//llSetText((string)first+(string)second+(string)third,<1,0,0>,1);
llSay(0,"Chat three numbers");
handle=llListen(0,"",toucherid,"");}

listen(integer channel,string name,key id,string message){
sfirst =(integer)llGetSubString(message,0,0);
ssecond =(integer)llGetSubString(message,1,1);
sthird =(integer)llGetSubString(message,2,2);

integer h=0;
integer b=0;

if(first==sfirst){
h=h+1;}
if(first==ssecond){
b=b+1;}
if(first==sthird){
b=b+1;}
if(second==sfirst){
b=b+1;}
if(second==ssecond){
h=h+1;}
if(second==sthird){
b=b+1;}
if(third==sfirst){
b=b+1;}
if(third==ssecond){
b=b+1;}
if(third==sthird){
h=h+1;}
if(h==3){
llSay(0,"homerun");
llSay(0,"you say"+(string)i+"times");
llResetScript();}
if(h==2){
llSay(0,"two strikes");}
if(h==1){
llSay(0,"one strike");}
if(b==3){
llSay(0,"three balls");}
if(b==2){
llSay(0,"two balls");}
if(b==1){
llSay(0,"one ball");}
i=i+1;

state opponentturn;}}

state opponentturn{
state_entry(){
state yourturn;}}

state yourturn{
state_entry(){
llSay(0,"Chat three numbers");
handle=llListen(0,"",toucherid,"");}

listen(integer channel,string name,key id,string message){
sfirst =(integer)llGetSubString(message,0,0);
ssecond=(integer)llGetSubString(message,1,1);
sthird =(integer)llGetSubString(message,2,2);

integer h=0;
integer b=0;

if(first==sfirst){
h=h+1;}
if(first==ssecond){
b=b+1;}
if(first==sthird){
b=b+1;}
if(second==sfirst){
b=b+1;}
if(second==ssecond){
h=h+1;}
if(second==sthird){
b=b+1;}
if(third==sfirst){
b=b+1;}
if(third==ssecond){
b=b+1;}
if(third==sthird){
h=h+1;}
if(h==3){
llSay(0,"Homerun");
llSay(0,"you say"+" "+(string)i+" "+"times");
llSay(0,"Game over");
llResetScript();}
if(h==2){
llSay(0,"two strikes");}
if(h==1){
llSay(0,"one strike");}
if(b==3){
llSay(0,"three balls");}
if(b==2){
llSay(0,"two balls");}
if(b==1){
llSay(0,"one ball");}
i=i+1;
state opponentturn;}}


同じカテゴリー(ゲーム)の記事画像
囲碁
ブロック積み上げゲーム
同じカテゴリー(ゲーム)の記事
 囲碁 (2008-06-21 23:47)
 ブロック積み上げゲーム (2008-06-18 23:45)
 じゃんけんゲーム (2008-06-12 23:08)
Posted by Treva Slade at 18:35│Comments(2)ゲーム
この記事へのコメント
エラー 直ってよかったね^^
Posted by ちびた at 2008年06月14日 10:14
うん!ありがとう!
Posted by Treva SladeTreva Slade at 2008年06月14日 15:27
 
<ご注意>
書き込まれた内容は公開され、ブログの持ち主だけが削除できます。