魔方游戏程序设计制作(C语言)

大家都玩过手机的小游戏吧。我是编程爱好者,喜欢动脑筋研究一些算法,编程做出小游戏程序,很有趣很有成就感。

在学习VB6编程时就编制过钻石棋和伤脑筋十二块那样的游戏,都是标准Windows图形界面的。现在有空闲时就玩手机上编译手机游戏。这里用简单的C语言编制魔方游戏,是安卓手机版图形界面的,全是用编译器绘图方法绘制的。一般的游戏图形都是方形和圆形为主,此魔方游戏图形是用伪3D的方法绘制的。此方法是用平面绘画方法画出许多菱形拼接成魔方的立体图像,给你的观感是立体的魔方。你可看到魔方的三个面,前面右面和上面。这样你能根据小方块的颜色来判断而旋转魔方。一般人玩魔方都是左手拿魔方,右手做各种旋转动作。此设计就是左手拿手机,右手转魔方。游戏的视觉效果就这样。游戏有自动演示选项,这是教你怎样玩魔方。演示套用说明书经典公式,即六步公式:上层四棱,上层四角,翻转,二层四棱,上层十字,顶面同色,六面同色。同时还提供操作记录,查看操作复盘。自动演示的记录就套用六步公式以供学习和研究用。我感觉用手机玩魔方的手感有种别样的味道。
手机魔方游戏我见过国外编的仿3D动画式的游戏,用手指滑动旋转操作,蛮酷的。我这个游戏是很小巧的,它的优点是简单和有趣,今值金虎之年奉献给同好,希望大家喜欢。

MySpringC是一个简化的C语言编译器。主要用于科学计算、个人娱乐和个性化的设备控制等场合。当前运行在Android平台上,是Android平台的一款应用。使用MySpringC可以书写简单的C语言程序,编写完成后可以编译、运行并获得 结果。还可以做出安卓手机桌面app应用。MySpringC支持的C与普通的C非常类似,程序从main开始,支持全局变量和局部变量,支持各种数据类型和常用的控制流。MySpringC它没有复杂、庞大的编程环境,只要你了解一点C或java,只需要一部手机,在家里、在公共汽车上任何方便的时候,就可以编写满足自己特定需求的小程序。
 MySpringC不仅可以编写简单的C语言程序,而且它能读取手机中各种传感器的数值,控制各种多媒体设备,从而实现让普通用户用C语言控制手机,编写出意想不到的、适合自己使用的应用。

v.2.7是目前的完善版本。下面的游戏代码就是用它在安卓手机上编写的,可制作成安卓手机桌面app应用程序。此样例可复制黏贴到编译器直接使用,亦可用 VB ,VC ,  java  改写。

游戏样例:

watermark,type_d3F5LXplbmhlaQ,shadow_50,text_Q1NETkBiYWlkdV80MTgwMTc3MA,size_18,color_FFFFFF,t_70,g_se,x_16

watermark,type_d3F5LXplbmhlaQ,shadow_50,text_Q1NETkBiYWlkdV80MTgwMTc3MA,size_18,color_FFFFFF,t_70,g_se,x_16  

以下是源码:
//  最简单的 C 语言编程
//  myspringc  v2.7  可编译安卓本机 app 应用
//  此样例可复制黏贴到 myspringc  编译
//  此文档可用 VB,VC  ,  java 改写
//***************************************
//**** 游戏程序: 魔方  Magic Cube ****
//***************************************
Canvas cs ;     //画布
string sBarDes[10];
int nBarId[10];
string sMenu[50];
int nMenu[50];
float pi=3.1415926535;
float src[4];  //ClearDraw (cls) clear screen
string s,s1,s2,s3,s4,s5,s6,s7,s8,ss1,ss2,ss3;
float sx,sy,dx,dy;
float px,py;
FileInput filebox;
string fname;  //filename
int i,j,n,t,k;    //t = times
int context,obj,id,event;   //canvasProc
int bx,by;   //button x y position 
int bn;        //button id number
int B[80]; //1 left 2 front 3 right 4 up 5 back 6 down
 int cr1,cg1,cb1;    //set color rgb
 int scolor;              // switch cube color
 int sw[9];               //switch B  color
 int donum;            //calculate do step number
 int kn,cando;
 double Rn;            //random number
 int tim[3];              //get Time
 int hh,mm,ss;        //times
 int oldhh,oldmm,oldss;
 int newhh,newmm,newss;
 int mms;               //show using time
 string hhts,mmts,ssts;     //time $
 string fs1,fs2,fs3,fs4,fs5,fs6;    //show formula
 int ms;      //using formula

main(){
  setDisplay(1);
  //cs.SetBackground(225,225,225);
  cs.Active();
  cs.SetProc (context, mycanvasProc); //getProc 触控
   sBarDes[0]="开始游戏";
   nBarId[0]=100;
   sBarDes[1]="还原魔方";
   nBarId[1]=101;
   sBarDes[2]="自动演示";
   nBarId[2]=102;
   sBarDes[3]="显示图板";
   nBarId[3]=103;
   sBarDes[4]="退出程序";
   nBarId[4]=104;
   sBarDes[5]="V.";
   nBarId[5]=105;
   setToolBarHeight(6);
   setButtonTextSize(13);
   setToolBarBackgroundColor(255,192,192,192);
   setButtonColor(255,0,0,240);
   setButtonTextColor(255,255,255,0);
setToolBar(100,myToolBarProc,sBarDes,nBarId,6);

   sMenu[0]="开始游戏";
   nMenu[0]=200;
   sMenu[1]="第一步:上层四棱";
   nMenu[1]=201;
   sMenu[2]="第二步:上层四角";
   nMenu[2]=202;
   sMenu[3]="第三步:二层四棱";
   nMenu[3]=203;
   sMenu[4]="第四步:顶层十字";
   nMenu[4]=204;
   sMenu[5]="第五步:顶面同色";
   nMenu[5]=205;
   sMenu[6]="第六步:六面同色";
   nMenu[6]=206;
   sMenu[7]="自动演示";
   nMenu[7]=207;
   sMenu[8]="查看走步记录";
   nMenu[8]=208;
   sMenu[9]="显示游戏图板";
   nMenu[9]=209;
   sMenu[10]="退出";
   nMenu[10]=210;
   setMenu(200,myMenuProc,sMenu,nMenu,11);
  setTitle("魔方 Magic Cube ");
//*****************************
      getTime (tim);   // 开始时间
      oldhh=tim[0];
      oldmm=tim[1];
      oldss=tim[2];
    kn=2;
   drawcover ();
while (){}   
  }//main ()  

mycanvasProc (int context,int obj,int id,int event,float x,float y){
        bn=0;
   if (event==0||event==2||event==10){ //get  touch
              kn=kn+1;
         if ((kn-kn/2*2)==0){    //  缓冲,测试
              cando=1;  }else{cando=0; return;  }
// print kn;
    if (x>20&&x<110){  //select button btn number 
        if (y>770&&y<840)bn=1;
        if (y>840&&y<910)bn=2;
        if (y>920&&y<980)bn=9;   }
    if (x>310&&x<400){  //select button btn number 
        if (y>760&&y<840)bn=3;
        if (y>840&&y<920)bn=4;
        if (y>920&&y<990)bn=10;   }
      if (x>120&&x<210&&y>750&&y<810)bn=5;
      if (x>210&&x<300&&y>750&&y<810)bn=6;
      if (x>120&&x<210&&y>815&&y<885)bn=7;
      if (x>210&&x<300&&y>815&&y<885)bn=8;
      if (x>120&&x<210&&y>890&&y<960)bn=11;
      if (x>210&&x<300&&y>890&&y<960)bn=12;
      if (x>430&&x<555&&y>750&&y<840)bn=13;
      if (x>560&&x<690&&y>750&&y<840)bn=14;
      if (x>490&&x<620&&y>850&&y<950)bn=15;

      cs.SetFillMode (1);
      cs.SetColor(255,255,255,255); 
      //cs.DrawCircle (160,280,5);  //L  调试
     // cs.DrawCircle (160,440,5);
      if (x>120&&x<200&&y>240&&y<320)bn=1;
      if (x>120&&x<200&&y>400&&y<480)bn=2;
      cs.DrawText ("L1",150,290);
      cs.DrawText ("L",150,450);

     // cs.DrawCircle (320,370,2);  //R
     // cs.DrawCircle (320,520,2);
      if (x>280&&x<360&&y>330&&y<410)bn=3;
      if (x>280&&x<360&&y>480&&y<560)bn=4;
      cs.DrawText ("R",310,370);
      cs.DrawText ("R1",305,530);

   // cs.DrawCircle (260,270,40);   //U
    //cs.DrawCircle (450,270,40);
      if (x>220&&x<300&&y>230&&y<310)bn=5;
      if (x>410&&x<490&&y>230&&y<310)bn=6;
      cs.DrawText ("U",270,270);
      cs.DrawText ("U1",430,270);

      //cs.DrawCircle (400,370,2);   //F
       //cs.DrawCircle (400,520,2);
      if (x>360&&x<440&&y>330&&y<410)bn=7;
      if (x>360&&x<440&&y>480&&y<560)bn=8;
      cs.DrawText ("F1",390,370);
      cs.DrawText ("F",395,530);

      //cs.DrawCircle (560,280,5);  //B
      //cs.DrawCircle (560,440,5);
      if (x>520&&x<600&&y>240&&y<320)bn=10;
      if (x>520&&x<600&&y>400&&y<480)bn=9;
      cs.DrawText ("B",550,290);
      cs.DrawText ("B1",550,450);

     //  cs.DrawCircle (230,490,4);   //D
      // cs.DrawCircle (480,490,4);
      if (x>190&&x<270&&y>450&&y<530)bn=11;
      if (x>440&&x<520&&y>450&&y<530)bn=12;
      cs.DrawText ("D1",230,490);
      cs.DrawText ("D",470,490);
      cs.DrawText ("Fm",640,710);
     // 显示50顶面同色 60 六面同色公式
     if (x>640&&x<720&&y>650&&y<720){
           fs1="51  L1  U1  L  U1  L1  U2   L "; 
           fs2="52  R    U   R1  U   R    U2  R1 ";    
           fs3="53  L2  B2  L1 F1  L   B2  L1  F  L1 "; 
           fs4="54  R2  B2  R   F   R1  B2  R  F1  R ";    
           fs5="61  F2  U1 R1  L  F2  R  L1  U1  F2 ";
           fs6="62  F2  U   R1  L  F2  R  L1   U    F2 ";   }
           else{
       fs1=" ";   fs2=" ";  fs3=" ";  fs4=" "; fs5=" "; fs6=" ";  } 
      cs.SetTextSize (18);
      cs.DrawText (fs1,440,575);
      cs.DrawText (fs2,440,595);
      cs.DrawText (fs3,440,620);
      cs.DrawText (fs4,440,640);
      cs.DrawText (fs5,440,665);
      cs.DrawText (fs6,440,685);

      cs.DrawCircle (680,220,5);   //51
      cs.DrawCircle (680,300,5);
      cs.DrawCircle (680,400,5);   //53
      cs.DrawCircle (680,480,5);
      cs.DrawCircle (680,560,5);   //61
      cs.DrawCircle (680,640,5);
      if (x>660&&x<720&&y>180&&y<260){
           ms=51;  Formula ();  }
     if (x>660&&x<720&&y>260&&y<340){
           ms=52;  Formula ();  }
     if (x>660&&x<720&&y>360&&y<440){
           ms=53;  Formula ();  }
     if (x>660&&x<720&&y>440&&y<520){
           ms=54;  Formula ();  }
     if (x>660&&x<720&&y>520&&y<600){
           ms=61;  Formula ();  }
     if (x>660&&x<720&&y>600&&y<680){
           ms=62;  Formula ();  }

  cs.SetFillMode (1);
cs.Update ();
 //********* get button position x y 
          bx=(int)(x);    
          by=(int)(y);  
      if (bn==1){
            s3="走步: 左上 L '  ";
             Leftup ();        } 
      if (bn==2){
            s3="走步: 左下 L  ";
             Leftdown ();       }
       if (bn==3){
            s3="走步: 右上 R  ";
             Rightup ();          }
      if (bn==4){
            s3="走步: 右下 R '  ";
             Rightdown ();       }
      if (bn==5){
            s3="走步: 上左 U ";
             Upleft ();            }
      if (bn==6){
            s3="走步: 上右 U '  ";
             Upright ();           }
      if (bn==7){
            s3="走步: 前左 F ' ";
             Frontleft ();          }
      if (bn==8){
            s3="走步: 前右 F  ";
             Frontright ();        }
     if (bn==9){
            s3="走步: 后左 B '  ";
             Backleft ();          }
      if (bn==10){
            s3="走步: 后右 B   ";
             Backright ();        }
      if (bn==11){
            s3="走步: 下左 D ' ";
             Downleft ();          }
      if (bn==12){
            s3="走步: 下右 D  ";
             Downright ();        }
       if (bn==13){
            s3="走步: 左旋转  ";
             Turnleft ();        }
       if (bn==14){
            s3="走步: 右旋转  ";
             Turnright ();        }
       if (bn==15){
            s3="走步: 翻转  ";
             Turnup ();        }
 }  //screen touch and select button ********

           cs.SetFillMode (1);
    cs.SetColor(255,240,240,240); 
    cs.DrawRect (0,3,700,30);  // clear print x y
    s=intToString(bn);
         s4="按钮(bn) > "+s;
    s=intToString(bx);
         s1="X= "+s;
    s=intToString(by);
         s2="Y= "+s;    
   cs.SetColor (255,50,20,120);
      cs.SetTextSize (26);
      cs.DrawText (s1,25,25);
      cs.DrawText (s2,120,25);
      cs.DrawText (s4,220,25);
      cs.DrawText (s3,445,25);
      cs.Update ();
      checkfinished ();
}//mycanvasProc ()
 //***************************************

Autoplay (){    //
      clearOutput ();
      print "User select >>>   自动演示";
      newgame ();
      Astep1 ();    //上层四棱
      sleep (3000);
      Astep2 ();    //上层四角
      sleep (3000);
          Turnup ();  Turnup ();
      sleep (1000);
      Astep3 ();    //二层四棱
      sleep (3000);
      Astep4 ();    //顶层十字
      sleep (3000);
      Astep5 ();    //顶面同色
      sleep (3000);
      Astep6 ();    //六面同色
 }//Autoplay ()

Formula (){
      if (ms==51){ goto ms51;  }
      if (ms==52){ goto ms52;  }
      if (ms==53){ goto ms53;  }
      if (ms==54){ goto ms54;  }
      if (ms==61){ goto ms61;  }
      if (ms==62){ goto ms62;  }

 ms51:   //left formula  fh49  L1  U1  L  U1  L1  U2  L
          print "s5_51 ";
          Leftup ();  Upright ();  Leftdown ();
          Upright ();   Leftup (); 
          Upleft ();  Upleft ();  Leftdown ();
           return;     //************
ms52:   //right formula  fh47 R   U  R1  U   R   U2  R1
           print "s5_52 ";
           Rightup ();  Upleft ();  Rightdown ();
           Upleft ();  Rightup ();
           Upleft ();  Upleft ();  Rightdown ();
            return;     //************
ms53:   //L2  B2  L1  F1  L  B2  L1 F  L1    sb49顺
          print "s5_53 ";
          Leftup();  Leftup ();  Backleft (); Backleft ();
          Leftup ();  Frontleft ();  Leftdown ();
          Backleft ();  Backleft ();
          Leftup ();  Frontright ();  Leftup ();
          return;   //顶面同色 ************* 
ms54: //R2 B2  R  F  R1 B2 R  F1 R     sd47 逆
          print "s5_54 ";
          Rightup ();  Rightup ();  Backleft ();  Backleft ();
          Rightup ();  Frontright ();  Rightdown ();
          Backleft ();  Backleft ();
          Rightup ();  Frontleft ();  Rightup ();
           return;     //顶面同色 *************
ms61:
//s661  F2  U1  R1  L  F2  R  L1  U1  F2      b22=b35    
         print "s6_61 ";   
         Frontleft ();  Frontleft ();  
         Upright ();  Rightdown ();   Leftdown ();  
         Frontleft ();  Frontleft ();
         Rightup ();  Leftup ();  Upright ();
         Frontleft ();  Frontleft ();   
         return;     //s661  >right 逆时针
ms62:
 //s662  F2  U    R1  L  F2  R  L1  U    F2     b32=b25      
         print "s6_62 ";   
         Frontleft ();  Frontleft ();  
         Upleft ();  Rightdown ();   Leftdown ();  
         Frontleft ();  Frontleft ();
         Rightup ();  Leftup ();  Upleft ();
         Frontleft ();  Frontleft ();  
         return;     //s662  <left 顺时针
}//Formula ()

checkfinished (){
 //**** check finished ************
    for (i=1;i<10;i++){
         if (B[10+i]==B[15]){  }else{ goto f60;  }
         if (B[20+i]==B[25]){  }else{ goto f60;  }
         if (B[30+i]==B[35]){  }else{ goto f60;  }
         if (B[40+i]==B[45]){  }else{ goto f60;  }
         if (B[50+i]==B[55]){  }else{ goto f60;  }
         if (B[60+i]==B[65]){  }else{ goto f60;  }
                 } //check >>>>>>
          goto f66;   //finished
f60:
       ms=80;  return;  //if not finished then retry 
f66:    // **** finished *************
      if (ms==99)return;
      getTime (tim);
      //print "times = ",n;
      newhh=tim[0];
      newmm=tim[1];
      newss=tim[2];
      hhts=intToString (tim[0]);
      mmts=intToString (tim[1]);
      ssts=intToString (tim[2]);
      if (newhh<10)hhts="0"+hhts;
      if (newmm<10)mmts="0"+mmts;
      if (newss<10)ssts="0"+ssts;
 mms=((newhh-oldhh)*3600)+
        ((newmm-oldmm)*60)+((newss-oldss));    
    if (mms<0) mms=mms+864000;
        hh=mms/3600;
        mm=(mms-hh*2600)/60;
        ss=mms-hh*3600-mm*60;
  ss1=intToString (mm)+" 分 "+intToString (ss)+" 秒";
  ss2=hhts+" : "+mmts+" : "+ssts;
    s7="用时:"+ss1;
   print "结束时间  "+ss2;
   print s7;
          oldhh=newhh;
          oldmm=newmm;
          oldss=newss;
 //******************
    cs.SetColor(255,240,240,240); 
    cs.DrawRect (0,2,720,30);  // clear print 
        s3="《六面同色》 已完成 ";
        print s3;
    cs.SetColor (255,250,20,120);
        cs.SetTextSize (26);
        cs.DrawText (s3,380,25);
        cs.DrawText (s7,100,25);
        s="恭喜你完成了魔方游戏!  ";
        cs.SetTextSize (60);
     cs.SetFillMode (1);
     cs.SetStrokeWidth (2);
     cs.SetColor (255,160,30,240);
         cs.DrawText (s,63,313);
     cs.SetColor (255,250,20,20);
         cs.DrawText (s,60,310);
     cs.SetFillMode (0);
     cs.SetStrokeWidth (1);
     cs.SetColor (255,240,240,20);
         cs.DrawText (s,60,310);
     cs.SetFillMode (1);
     cs.SetTextSize (26);
     cs.Update ();
      ms=99;     //if finished then cut
}//checkfinished ()

Astep6 (){   //六面同色 ************
   cs.SetColor(255,240,240,240); 
    cs.DrawRect (0,3,720,30);  // clear print 
    s5="《六面同色》 do >>>>>> ";
    print s5;
    cs.SetColor (255,250,20,120);
        cs.SetTextSize (26);
        cs.DrawText (s5,120,25);
   cs.Update ();
          n=0;  
s61:  
    //**** adjust status at first *********
   if (B[12]==B[15]){  //same color edge to back
        Turnleft ();      } 
   if (B[22]==B[25]){ Turnleft ();   Turnleft ();       } 
   if (B[32]==B[35]){ Turnright ();       }        
          
s62:     // formula 六面同色     顶棱归位        
     if (B[22]==B[35]){ ms=61;  Formula();  }
             //s661  >right 逆时针
     if (B[32]==B[15]||B[22]==B[55]){ //对角
           print "CXX ";
           ms=61;  Formula();  }  //s661  >right 逆时针
   
     if (B[32]==B[25]){  ms=62;  Formula();  }
            //s662  <left 顺时针
     if (B[12]==B[25]&&B[22]==B[15]){ //邻角ok
           print "C&C 1 "; 
           ms=62;  Formula();  }  //s662  <left 顺时针
 
    n=n+1;  
    if (n>5) Autoplay ();       //retry...
     checkfinished ();
     if(ms<99){ goto s61; }
}//Astep6 ()

Astep5 (){   //顶面同色 ************
    cs.SetColor(255,240,240,240); 
    cs.DrawRect (0,2,720,30);  // clear print 
    s5="《顶面同色》 do >>>>>> ";
   print s5;
    cs.SetColor (255,250,20,120);
        cs.SetTextSize (26);
        cs.DrawText (s5,120,25);
    cs.Update ();
        n=0; 
        
s51:
   //** adjust status at first ** fish head b47 left **
  if (B[41]==B[45]){  Turnright ();     }               
  if (B[43]==B[45]){ Turnright (); Turnright ();    }              
  if (B[49]==B[45]){ Turnleft ();     }
       //double fish head ******
  if (B[43]==B[45]&&B[21]==B[55]){ 
         Upleft ();  Upleft ();    }
  if (B[43]==B[45]&&B[33]==B[15]&&B[51]==B[25]){
         Upleft ();  Upleft ();  }

s52:    // top layer in same color   ******
      if (B[47]==B[45]&&B[11]==B[45]&&
           B[51]==B[45]&&B[31]==B[45]){
           print "5_ss1";
           Upright(); 
            ms=51;  Formula();  }  //ss1  set b49
      if (B[47]==B[45]&&B[53]==B[45]&&
           B[33]==B[45]&&B[23]==B[45]){
           print "5_ss2";
            ms=52;  Formula();  }  //ss2  set b47
  
    if (B[51]==B[45]&&B[53]==B[45]){Turnleft ();    }
    if (B[21]==B[45]&&B[23]==B[45]){Turnright ();  }
    if (B[31]==B[45]&&B[33]==B[45]){
        Turnleft ();  Turnleft ();  }  // adjust edge corner

     if (B[11]==B[45]&&B[13]==B[45]&&
           B[31]==B[45]&&B[33]==B[45]){
            print "5_ss3";
            ms=51;  Formula();  
            ms=51;  Formula();  }   //ss3
     if (B[11]==B[45]&&B[13]==B[45]&&
           B[51]==B[45]&&B[23]==B[45]){
           print "5_ss4";
           ms=52;  Formula(); 
               Turnright();  
           ms=52;  Formula();  }   //ss4
      if (B[47]==B[45]&&B[43]==B[45]&&
           B[11]==B[45]&&B[23]==B[45]){
           print "5_ss5";
            ms=51;  Formula(); 
            Turnleft();  
            ms=52;  Formula();  }   //ss5
      if (B[43]==B[45]&&B[49]==B[45]&&
           B[51]==B[45]&&B[23]==B[45]){
           print "5_ss6";
           Turnright ();  Turnright (); 
            ms=52;  Formula();  
            ms=51;  Formula();  }  //ss6
      if (B[11]==B[45]&&B[13]==B[45]&&
           B[43]==B[45]&&B[49]==B[45]){
           print "5_ss7";
           ms=52;  Formula();  
           ms=51;  Formula();  
           ms=52;  Formula();  
           ms=51;  Formula();  }    //ss7
     n=n+1;  
    print "times = ",n;
    if (n>5){    //retry......
       print "retry......";
       if (B[11]==B[45]||B[51]==B[45]){
            ms=51;  Formula();  }   
       if (B[13]==B[45]||B[53]==B[45]){
            ms=52;  Formula();  }     }
 s55:    //**** check finished ************
     if (B[41]==B[45]&&B[42]==B[45]&&
          B[43]==B[45]&&B[44]==B[45]&&
          B[46]==B[45]&&B[47]==B[45]&&
          B[48]==B[45]&&B[49]==B[45]) {
             goto s57;  }  //to next execute 
             goto s51;  //if not finished then retry
     return;
//*********************
s57:    //do 4 corner to order seat 顶角归位
   //1 - 4  面如已成同色 有可能已完成游戏
    n=0;
   //****** adjust status at first < needles > ****
   if (B[31]==B[25]||B[11]==B[55]){ Upleft ();    }
   if (B[11]==B[25]||B[31]==B[55]){ Upright ();    }

   if (B[33]==B[15]&&B[51]==B[25]){
       Turnleft ();  Turnleft ();    }  //set b47
   if (B[53]==B[15]&&B[11]==B[25]){ Turnright ();    }
   if (B[23]==B[15]&&B[31]==B[25]){  Turnleft ();     }

  if (B[31]==B[15]&&B[11]==B[55]&&B[51]==B[35]){ 
         Turnright ();  
          ms=53;  Formula();  }   //顺时针b49

  if (B[31]==B[55]&&B[51]==B[15]&&B[11]==B[35]){ 
           ms=54;  Formula();  }  //逆时针b47
       
  if (B[23]==B[35]||B[33]==B[25]){      //邻角ok
           print "C--C 1 ";
           ms=54;  Formula();  }
   if (B[11]==B[55]||B[23]==B[55]){     //邻角ok
           print "C--C 2 ";
           ms=53;  Formula();  }
   if (B[11]==B[25]||B[21]==B[55]){     //邻角ok
           print "C--C 3 ";
           ms=54;  Formula();  }
  if (B[13]==B[25]&&B[23]==B[15]){     //邻角ok
           print "C--C 4 ";
           ms=54;  Formula();  }

  if (B[21]==B[55]||B[51]==B[25]){      //对角ok
          print "CXC 1 ";
          ms=53;  Formula(); 
           Upleft ();   }
  if (B[13]==B[35]||B[21]==B[55]){ 
          print "CXC 2 ";
          ms=53;  Formula();  }

     n=n+1;    
    print "times = ",n;
    if (n>9){print "retry......"; ms=53;  Formula();  }   
 s58:   //**** check finished ************
     if (B[41]==B[45]&&B[42]==B[45]&&
          B[43]==B[45]&&B[44]==B[45]&&
          B[46]==B[45]&&B[47]==B[45]&&
          B[48]==B[45]&&B[49]==B[45]&&
          B[11]==B[15]&&B[21]==B[25]&&
          B[31]==B[35]&&B[51]==B[55]) {
             goto s59;  }  //finished game 
             goto s57;  //if not finished then retry
s59:
//**** check finished ************
   if (B[11]==B[15]&&B[12]==B[15]&&B[13]==B[15]){
   if (B[21]==B[25]&&B[22]==B[25]&&B[23]==B[25]){
   if (B[31]==B[35]&&B[32]==B[35]&&B[33]==B[35]){
   if (B[51]==B[55]&&B[52]==B[55]&&B[53]==B[55]){
           goto s60;  }  }  }  }  //六面同色已完成
  
    cs.SetColor(255,240,240,240); 
    cs.DrawRect (0,3,720,30);  // clear print 
        s3="《顶面同色》 已完成 ";
        print s3;
    cs.SetColor (255,250,20,120);
        cs.SetTextSize (26);
        cs.DrawText (s3,380,25);
    cs.Update ();
    print "times = ",n;
    return;

s60: //if finished magic cube some times ****
       checkfinished ();
       print "Well done ! magic cube is finished. ";
}//Astep5 ()

Astep4 (){   //顶层十字 ************
   cs.SetColor(255,240,240,240); 
    cs.DrawRect (0,2,720,30);  // clear print 
    s5="《顶层十字》 do >>>>>> ";
    print s5;
    cs.SetColor (255,250,20,120);
        cs.SetTextSize (26);
        cs.DrawText (s5,120,25);
    cs.Update ();
      n=0;  goto s45;   //check finished
s41:    //run 4 times when finished *******
      //adjust status ***********
    if (B[44]==B[45]&&B[48]==B[45]){
         Upleft ();   }
    if (B[46]==B[45]&&B[48]==B[45]){
         Upleft ();  Upleft ();    }
    if (B[42]==B[45]&&B[46]==B[45]){
         Upright ();    }
    if (B[44]==B[45]&&B[46]==B[45]){
         Upleft ();    }
     //use  formula  execute  R' U' F' U F R *****
         print "s4_41 ";
         Rightdown ();  Upright ();  Frontleft ();
         Upleft ();  Frontright ();  Rightup ();
   n=n+1;
    if (n>18) goto s46;       
s45:    //**** check finished ************
     if (B[42]==B[45]&&B[44]==B[45]&&
          B[46]==B[45]&&B[48]==B[45]){
                 goto s46;  } else { goto s41;  } 
     return;
s46:
    cs.SetColor(255,240,240,240); 
    cs.DrawRect (0,3,720,30);  // clear print 
        s3="《顶层十字》 已完成 ";
        print s3;
    cs.SetColor (255,250,20,120);
        cs.SetTextSize (26);
        cs.DrawText (s3,380,25);
    cs.Update ();
  print "times = ",n;
}//Astep4 ()

Astep3 (){   //二层四棱 *************
     s3="Autoplay >> 二层四棱 ";
    cs.SetColor(255,240,240,240); 
    cs.DrawRect (0,2,720,30);  // clear print 
    s5="《二层四棱》 do >>>>>> ";
    print s5;
    cs.SetColor (255,250,20,120);
        cs.SetTextSize (26);
        cs.DrawText (s5,120,25);
     cs.Update ();
      n=0;   goto s35;   //check finished
s31:
 //****** adjust status ************
   if (B[26]==B[35]||B[34]==B[25]){ 
   if (B[26]==B[15]||B[34]==B[55]){ 
       print "s3_31 ";   
          Rightdown ();  Upright (); Rightdown();
          Upright ();  Rightdown ();
          Upleft ();  Rightup ();  Upleft ();
          Rightup (); }    }       // s3_31
   if (B[36]==B[25]||B[54]==B[35]){ 
   if (B[36]==B[55]||B[54]==B[15]){ 
         print "s3_32 ";
          Rightup ();  Upleft (); Rightup();
          Upleft ();  Rightup ();
          Upright ();  Rightdown ();  Upright ();
          Rightdown (); }   }   //  s3_32
//**** adjust status *******************
    if (B[44]==B[25]&&B[12]==B[35]){
          Upright ();  Upright ();  }  
    if (B[44]==B[55]&&B[12]==B[35]){
          Upright ();  Upright ();  }  
    if (B[42]==B[25]&&B[52]==B[35]){
          Upleft ();   }   
    if (B[42]==B[55]&&B[52]==B[35]){
          Upleft ();   }   
    if (B[48]==B[25]&&B[22]==B[35]){
          Upright ();   }   
    if (B[48]==B[55]&&B[22]==B[35]){
          Upright ();   }   

s32:    //do medium layer edges ******
     if (B[46]==B[25]&&B[32]==B[35]){ //s3_31  left
          print "s3_31 ";
          Rightdown ();  Upright (); Rightdown();
          Upright ();  Rightdown ();
          Upleft ();  Rightup ();  Upleft ();
          Rightup ();    }  //Turnleft ();  }
     if (B[46]==B[55]&&B[32]==B[35]){ //s3_32  right
          print "s3_32 ";
          Rightup ();  Upleft (); Rightup();
          Upleft ();  Rightup ();
          Upright ();  Rightdown ();  Upright ();
          Rightdown ();    }  //  Turnright ();    }
    Turnright ();    // adjust  status ******
     n=n+1;  
     if (n>30) goto s36;       
 s35:    //**** check finished ************
     if (B[24]==B[25]&&B[26]==B[25]&&
          B[34]==B[35]&&B[36]==B[35]&&
          B[14]==B[15]&&B[16]==B[15]&&
          B[54]==B[55]&&B[56]==B[55]) {
             goto s36;  } else { Upright();  goto s31;  } 
     return;
s36:
    cs.SetColor(255,240,240,240); 
    cs.DrawRect (0,3,720,30);  // clear print 
        s3="《二层四棱》 已完成 ";
        print s3;
    cs.SetColor (255,250,20,120);
        cs.SetTextSize (26);
        cs.DrawText (s3,380,25);
    cs.Update ();
print "times = ",n;
}//Astep3 ()

Astep2 (){   //上层四角 *************
    cs.SetColor(255,240,240,240); 
    cs.DrawRect (0,2,720,30);  // clear print 
    s5="《上层四角》 do >>>>>> ";
    print s5;
    cs.SetColor (255,250,20,120);
        cs.SetTextSize (26);
        cs.DrawText (s5,120,25);
    cs.Update ();
    n=0;      goto s25;   //check finished
s21:  //**** top 4 corner to under layer *******
   for (i=0;i<4;i++){
      if (B[49]==B[45]||B[23]==B[45] ||B[31]==B[45]){
         Rightdown (); Downleft ();  Rightup ();  }
     if (B[43]==B[45]||B[33]==B[45] ||B[51]==B[45]){
         Backleft (); Downleft ();  Backright ();  }
     if (B[41]==B[45]||B[53]==B[45] ||B[11]==B[45]){
         Leftup (); Downleft ();  Leftdown ();  }
     if (B[47]==B[45]||B[13]==B[45] ||B[21]==B[45]){
         Frontleft (); Downleft ();  Frontright ();  }
                }
s22:  //**** under 4 corner to top layer *****
     if (B[23]==B[45]||B[31]==B[45]||B[49]==B[45]){
          Downleft ();    Rightdown ();
          Downright ();  Rightup ();  } //adjust

    if (B[39]==B[45]||B[57]==B[45]||B[69]==B[45]){
    if (B[39]==B[25]||B[57]==B[25]||B[69]==B[25]){
    if (B[39]==B[35]||B[57]==B[35]||B[69]==B[35]){
             Downleft ();  }  }  }
     if (B[19]==B[45]||B[27]==B[45]||B[61]==B[45]){
     if (B[19]==B[25]||B[27]==B[25]||B[61]==B[25]){
     if (B[19]==B[35]||B[27]==B[35]||B[61]==B[35]){
              Downright ();  }  }  }
     if (B[59]==B[45]||B[17]==B[45]||B[67]==B[45]){
     if (B[59]==B[25]||B[17]==B[25]||B[67]==B[25]){
     if (B[59]==B[35]||B[17]==B[35]||B[67]==B[35]){
              Downleft ();  Downleft ();   }  }  }
 //**** under 4 corner to top layer ********
      if (B[29]==B[45]&&B[37]==B[35]&&B[63]==B[25]){
          print "s2_21";
          Downleft ();    Rightdown ();
          Downright ();  Rightup ();  } //s2_21
      if (B[37]==B[45]&&B[29]==B[25]&&B[63]==B[35]){
          print " s2_22 ";
          Rightdown ();  Downleft ();  
          Rightup ();           }               //s2_22
       if (B[63]==B[45]&&B[29]==B[35]&&B[37]==B[25]){
          print "s2_23 ";
          Rightdown ();  Downleft ();  Downleft ();
          Rightup ();     Downright ();  Rightdown ();   
          Downleft ();   Rightup ();     }  //s2_23
               Turnleft ();
               Downleft ();   
  n=n+1;  
 // if (n>20) goto s26;       
s25:    //**** check finished ************
     if (B[41]==B[45]&&B[43]==B[45]&&
          B[47]==B[45]&&B[49]==B[45]){
              goto s26;  } else { goto s22;  } 
     return;
s26:
    cs.SetColor(255,240,240,240); 
    cs.DrawRect (0,3,720,30);  // clear print 
        s3="《上层四角》 已完成 ";
        print s3;
    cs.SetColor (255,250,20,120);
        cs.SetTextSize (26);
        cs.DrawText (s3,380,25);
    cs.Update ();
    print "times = ",n;
}//Astep2 ()

Astep1 (){  //上层四棱  ***********
    cs.SetColor(255,240,240,240); 
    cs.DrawRect (0,2,720,30);  // clear print 
    s5="《上层四棱》 do >>>>>> ";
    print s5;
    cs.SetColor (255,250,20,120);
        cs.SetTextSize (26);
        cs.DrawText (s5,120,25);
    cs.Update ();
        n=0;
s11:       //**** top 4 edge to under
 if (B[12]==B[45]){   
         Leftdown();   Upright();   Frontleft();  }   
 if (B[22]==B[45]){
          Frontleft() ;   Upleft();  Leftdown();    }             
 if (B[32]==B[45]){
         Rightdown();   Upleft();   Frontright();  }   
 if (B[52]==B[45]){
         Backleft ();   Upleft();   Rightup();  }   
 if (B[42]==B[45]){
          Backleft ();  Backleft ();  }
 if (B[44]==B[45]){
          Leftdown ();  Leftdown ();  }
 if (B[46]==B[45]){
          Rightdown();  Rightdown ();  }
 if (B[48]==B[45]){   
          Frontleft();  Frontleft ();  }
    //return;

s12:  //**** under layer 4 edges to top ****
       if (B[66]==B[45]&&B[38]==B[35]){
            Rightup();  Rightup ();  }
       if (B[68]==B[45]&&B[58]==B[55]){
            Backleft();  Backleft ();  }   
       if (B[64]==B[45]&&B[18]==B[15]){
             Leftup ();  Leftup ();   }
       if (B[62]==B[45]&&B[28]==B[25]){
            Frontright ();  Frontright ();   }
s13:
       if (B[66]==B[45]&&B[38]==B[35]){
            Rightup();  Rightup ();   }
       if (B[66]==B[45]&&B[38]==B[25]){
            Downleft ();  Frontleft (); Frontleft ();  }
      if (B[66]==B[45]&&B[38]==B[15]){
          Downleft (); Downleft (); Leftup (); Leftup (); }
      if (B[66]==B[45]&&B[38]==B[55]){
          Downright ();  Backright (); Backright (); }
                Downleft ();
  
s14:    //**** 2 layer 4 edges to under ****
    for (i=0;i<4;i++){
     if (B[26]==B[45]){
          Rightdown (); Downleft ();  Rightup ();  }
     if (B[34]==B[45]){
          Frontright (); Downright (); Frontleft ();  }          
      Turnleft ();    }
 
  //*** under 4 edges b45 color ****
    if (B[38]==B[45]){
         Downleft (); Frontleft ();  Rightdown ();    
         Frontright ();   }
    if (B[58]==B[45]){
         Downleft ();  Downleft ();
         Frontleft ();  Rightdown ();  Frontright ();   }    
    if (B[28]==B[45]){
         Frontleft ();  Rightdown ();  Frontright ();   }
    if (B[18]==B[45]){
         Downright (); Frontleft ();  Rightdown ();   
         Frontright ();     }
    if (B[32]==B[45]){
         Rightdown (); Frontright (); Downright ();  
         Frontleft ();     }

     n=n+1;   
     if (n>20) goto s16;       
s15:    //**** check finished ************
     if (B[42]==B[45]&&B[44]==B[45]&&
          B[46]==B[45]&&B[48]==B[45]){
              goto s16;  } else { goto s12;  }
     return;
s16:
    cs.SetColor(255,240,240,240); 
    cs.DrawRect (0,3,720,30);  // clear print 
        s3="《上层四棱》 已完成 ";
        print s3;
    cs.SetColor (255,250,20,120);
        cs.SetTextSize (26);
        cs.DrawText (s3,380,25);
    cs.Update ();
    print "times = ",n;
}//Astep1()

drawbox (){  //draw out show user cube ****
     setDisplay (1);
     cs.SetStrokeWidth(1);       
  cs.SetColor(255,80,80,80); 
  cs.DrawRect (10,30,710,730);  // box backcolor 
      cs.SetColor(255,150,150,150); 
      cs.DrawLine(360,50,360,700);  //center
      cs.DrawLine(20,340,700,340);  //center
      cs.SetStrokeWidth(2);       
  for (j=0;j<80;j++){  //draw up cube ****
        scolor=B[41];
        switchcolor ();
   cs.SetColor(255,cr1,cg1,cb1);   //u1
  cs.DrawLine (280+j,140+j/2,360+j,100+j/2);  
        scolor=B[42];
        switchcolor ();
   cs.SetColor(255,cr1,cg1,cb1);   //u2
  cs.DrawLine (360+j,180+j/2,440+j,140+j/2);  
        scolor=B[43];
        switchcolor ();
   cs.SetColor(255,cr1,cg1,cb1);   //u3
  cs.DrawLine (440+j,220+j/2,520+j,180+j/2);  
        scolor=B[44];
        switchcolor ();
   cs.SetColor(255,cr1,cg1,cb1);   //u4
  cs.DrawLine (200+j,180+j/2,280+j,140+j/2);  
        scolor=B[45];
        switchcolor ();
   cs.SetColor(255,cr1,cg1,cb1);   //u5
  cs.DrawLine (280+j,220+j/2,360+j,180+j/2);  
 // cs.SetColor (255,250,250,0);
 // cs.DrawOval (360,220,15,30,90);  
       scolor=B[46];
        switchcolor ();
   cs.SetColor(255,cr1,cg1,cb1);   //u6
  cs.DrawLine (360+j,260+j/2,440+j,220+j/2);  
        scolor=B[47];
        switchcolor ();
   cs.SetColor(255,cr1,cg1,cb1);   //u7
  cs.DrawLine (120+j,220+j/2,200+j,180+j/2);  
       scolor=B[48];
        switchcolor ();
   cs.SetColor(255,cr1,cg1,cb1);   //u8
  cs.DrawLine (200+j,260+j/2,280+j,220+j/2);  
       scolor=B[49];
        switchcolor ();
   cs.SetColor(255,cr1,cg1,cb1);   //u9
  cs.DrawLine (280+j,300+j/2,360+j,260+j/2);  
        }  

 //draw right cube ******
  for (j=0;j<80;j++){  //draw right cube ****
        scolor=B[31];
        switchcolor ();
     cs.SetColor(255,cr1,cg1,cb1);   //r1
  cs.DrawLine (360+j,340-j/2,360+j,420-j/2);  
        scolor=B[32];
        switchcolor ();
   cs.SetColor(255,cr1,cg1,cb1);   //r2
  cs.DrawLine (440+j,300-j/2,440+j,380-j/2);  
        scolor=B[33];
        switchcolor ();
  cs.SetColor(255,cr1,cg1,cb1);   //r3
  cs.DrawLine (520+j,260-j/2,520+j,340-j/2);  
        scolor=B[34];
        switchcolor ();
   cs.SetColor(255,cr1,cg1,cb1);   //r4
  cs.DrawLine (360+j,420-j/2,360+j,500-j/2);  
        scolor=B[35];
        switchcolor ();
 cs.SetColor(255,cr1,cg1,cb1);   //r5
  cs.DrawLine (440+j,380-j/2,440+j,460-j/2);  
        scolor=B[36];
        switchcolor ();
   cs.SetColor(255,cr1,cg1,cb1);   //r6
  cs.DrawLine (520+j,340-j/2,520+j,420-j/2);  
        scolor=B[37];
        switchcolor ();
   cs.SetColor(255,cr1,cg1,cb1);   //r7
  cs.DrawLine (360+j,500-j/2,360+j,580-j/2);  
         scolor=B[38];
        switchcolor ();
   cs.SetColor(255,cr1,cg1,cb1);   //r8
  cs.DrawLine (440+j,460-j/2,440+j,540-j/2);  
       scolor=B[39];
        switchcolor ();
   cs.SetColor(255,cr1,cg1,cb1);   //r9
   cs.DrawLine (520+j,420-j/2,520+j,500-j/2);  
       }

   //draw front cube ******
       for (j=0;j<80;j++){  //draw front cube
       scolor=B[21];
        switchcolor ();
   cs.SetColor(255,cr1,cg1,cb1); //f1
  cs.DrawLine (120+j,220+j/2,120+j,300+j/2);
       scolor=B[22];
        switchcolor ();
   cs.SetColor(255,cr1,cg1,cb1);   //f2
  cs.DrawLine (200+j,260+j/2,200+j,340+j/2);
        scolor=B[23];
        switchcolor ();
   cs.SetColor(255,cr1,cg1,cb1);   //f3
  cs.DrawLine (280+j,300+j/2,280+j,380+j/2);
        scolor=B[24];
        switchcolor ();
   cs.SetColor(255,cr1,cg1,cb1);   //f4
  cs.DrawLine (120+j,300+j/2,120+j,380+j/2);
        scolor=B[25];
        switchcolor ();
   cs.SetColor(255,cr1,cg1,cb1);   //f5
  cs.DrawLine (200+j,340+j/2,200+j,420+j/2);
        scolor=B[26];
        switchcolor ();
   cs.SetColor(255,cr1,cg1,cb1);   //f6
   cs.DrawLine (280+j,380+j/2,280+j,460+j/2); 
        scolor=B[27];
        switchcolor ();
   cs.SetColor(255,cr1,cg1,cb1);   //f7
   cs.DrawLine (120+j,380+j/2,120+j,460+j/2);
        scolor=B[28];
        switchcolor ();
   cs.SetColor(255,cr1,cg1,cb1);   //f8
  cs.DrawLine (200+j,420+j/2,200+j,500+j/2);
        scolor=B[29];
        switchcolor ();
   cs.SetColor(255,cr1,cg1,cb1);   //f9
  cs.DrawLine (280+j,460+j/2,280+j,540+j/2);
           } 
    cs.SetStrokeWidth (9);
//square divide lines *********
        cs.SetColor(255,250,250,250); 
      for (i=0;i<4;i++){
 cs.DrawLine(360+i*80,339-i*40,360+i*80,581-i*40);
 cs.DrawLine(360-i*80,339-i*40,360-i*80,581-i*40);
 cs.DrawLine(120+i*80,220+i*40,360+i*80,100+i*40);
 cs.DrawLine(360-i*80,100+i*40,600-i*80,220+i*40);
 cs.DrawLine(120,220+i*80,360,340+i*80);
 cs.DrawLine(360,340+i*80,600,220+i*80);
     }
    cs.SetStrokeWidth (1);
//square divide lines *********
        cs.SetColor(255,0,0,0); 
      for (i=1;i<3;i++){
 cs.DrawLine(360+i*80,341-i*40,360+i*80,584-i*40);
 cs.DrawLine(360-i*80,341-i*40,360-i*80,584-i*40);
 cs.DrawLine(121+i*80,219+i*40,360+i*80,100+i*40);
 cs.DrawLine(361-i*80,100+i*40,600-i*80,220+i*40);
 cs.DrawLine(120,220+i*80,359,340+i*80);
 cs.DrawLine(361,340+i*80,600,220+i*80);
     }
       cs.SetColor(255,250,250,250); 
       cs.DrawCircle (121,221,5);
       cs.DrawCircle (121,460,5);
       cs.DrawCircle (600,221,5);
       cs.DrawCircle (600,459,5);
       cs.DrawCircle (360,101,5);
       cs.DrawCircle (360,579,5);

//draw left  back down cube ********
       cs.SetTextSize (32);
   cs.SetColor (255,250,250,20);
   cs.DrawText ("Left ",185,150);
   cs.DrawText ("Back ",470,150);
   cs.DrawText ("Down ",175,555);
   cs.DrawText ("Right ",612,350);
   cs.DrawText ("Front ",30,350);
   cs.DrawText ("Up ",340,80);

   cs.SetColor (255,250,250,250);
   cs.DrawRect (18,38,170,190);
        scolor=B[11];
        switchcolor ();
   cs.SetColor(255,cr1,cg1,cb1);   //L1
  cs.DrawRect (20,40,68,88);
        scolor=B[12];
        switchcolor ();
   cs.SetColor(255,cr1,cg1,cb1);   //L2
  cs.DrawRect (70,40,118,88);
        scolor=B[13];
        switchcolor ();
   cs.SetColor(255,cr1,cg1,cb1);   //L3
  cs.DrawRect (120,40,168,88);
        scolor=B[14];
        switchcolor ();
   cs.SetColor(255,cr1,cg1,cb1);   //L4
  cs.DrawRect (20,90,68,138);
        scolor=B[15];
        switchcolor ();
   cs.SetColor(255,cr1,cg1,cb1);   //L5
  cs.DrawRect (70,90,118,138);
        scolor=B[16];
        switchcolor ();
   cs.SetColor(255,cr1,cg1,cb1);   //L6
  cs.DrawRect (120,90,168,138);
        scolor=B[17];
        switchcolor ();
   cs.SetColor(255,cr1,cg1,cb1);   //L7
  cs.DrawRect (20,140,68,188);
        scolor=B[18];
        switchcolor ();
   cs.SetColor(255,cr1,cg1,cb1);   //L8
  cs.DrawRect (70,140,118,188);
        scolor=B[19];
        switchcolor ();
   cs.SetColor(255,cr1,cg1,cb1);   //L9
   cs.DrawRect (120,140,168,188);

   cs.SetColor (255,250,250,250); //back cube 
   cs.DrawRect (548,38,700,190);
        scolor=B[51];
        switchcolor ();
   cs.SetColor(255,cr1,cg1,cb1);   //b1
   cs.DrawRect (550,40,598,88);
        scolor=B[52];
        switchcolor ();
   cs.SetColor(255,cr1,cg1,cb1);   //b2
   cs.DrawRect (600,40,648,88);
        scolor=B[53];
        switchcolor ();
   cs.SetColor(255,cr1,cg1,cb1);   //b3
   cs.DrawRect (650,40,698,88);
        scolor=B[54];
        switchcolor ();
   cs.SetColor(255,cr1,cg1,cb1);   //b4
   cs.DrawRect (550,90,598,138);
        scolor=B[55];
        switchcolor ();
   cs.SetColor(255,cr1,cg1,cb1);   //b5
   cs.DrawRect (600,90,648,138);
        scolor=B[56];
        switchcolor ();
   cs.SetColor(255,cr1,cg1,cb1);   //b6
   cs.DrawRect (650,90,698,138);
        scolor=B[57];
        switchcolor ();
   cs.SetColor(255,cr1,cg1,cb1);   //b7
  cs.DrawRect (550,140,598,188);
        scolor=B[58];
        switchcolor ();
   cs.SetColor(255,cr1,cg1,cb1);   //b8
  cs.DrawRect (600,140,648,188);
        scolor=B[59];
        switchcolor ();
   cs.SetColor(255,cr1,cg1,cb1);   //b9
   cs.DrawRect (650,140,698,188);

   cs.SetColor (255,250,250,250); //down cube 
   cs.DrawRect (138,563,290,715);
       scolor=B[61];
        switchcolor ();
   cs.SetColor(255,cr1,cg1,cb1);   //d1
  cs.DrawRect (140,565,188,613);
       scolor=B[62];
        switchcolor ();
   cs.SetColor(255,cr1,cg1,cb1);   //d2
  cs.DrawRect (190,565,238,613);
       scolor=B[63];
        switchcolor ();
   cs.SetColor(255,cr1,cg1,cb1);   //d3
  cs.DrawRect (240,565,288,613);
       scolor=B[64];
        switchcolor ();
   cs.SetColor(255,cr1,cg1,cb1);   //d4
  cs.DrawRect (140,615,188,663);
       scolor=B[65];
        switchcolor ();
   cs.SetColor(255,cr1,cg1,cb1);   //d5
  cs.DrawRect (190,615,238,663);
       scolor=B[66];
        switchcolor ();
   cs.SetColor(255,cr1,cg1,cb1);   //d6
  cs.DrawRect (240,615,288,663);
       scolor=B[67];
        switchcolor ();
   cs.SetColor(255,cr1,cg1,cb1);   //d7
  cs.DrawRect (140,665,188,713);
       scolor=B[68];
        switchcolor ();
   cs.SetColor(255,cr1,cg1,cb1);   //d8
  cs.DrawRect (190,665,238,713);
       scolor=B[69];
        switchcolor ();
   cs.SetColor(255,cr1,cg1,cb1);   //d9
  cs.DrawRect (240,665,288,713);

       scolor=B[63];  //show under cube color
        switchcolor ();
   cs.SetColor(255,cr1,cg1,cb1);   //d3
   cs.DrawCircle (360,600,11);
       scolor=B[66];
        switchcolor ();
   cs.SetColor(255,cr1,cg1,cb1);   //d6
   cs.DrawCircle (380,620,11);
       scolor=B[69];
        switchcolor ();
   cs.SetColor(255,cr1,cg1,cb1);   //d9
   cs.DrawCircle (400,640,11);
       scolor=B[62];
        switchcolor ();
   cs.SetColor(255,cr1,cg1,cb1);   //d2
   cs.DrawCircle (340,620,11);
      scolor=B[65];
        switchcolor ();
   cs.SetColor(255,cr1,cg1,cb1);   //d5
   cs.DrawCircle (360,640,11);
      scolor=B[68];
        switchcolor ();
   cs.SetColor(255,cr1,cg1,cb1);   //d8
   cs.DrawCircle (380,660,11);
      scolor=B[61];
        switchcolor ();
   cs.SetColor(255,cr1,cg1,cb1);   //d1
   cs.DrawCircle (320,640,11);
      scolor=B[64];
        switchcolor ();
   cs.SetColor(255,cr1,cg1,cb1);   //d4
   cs.DrawCircle (340,660,11);
      scolor=B[67];
        switchcolor ();
   cs.SetColor(255,cr1,cg1,cb1);   //d7
   cs.DrawCircle (360,680,11);

       cs.Update ();     
}//drawbox () show cube box

drawButton (){
    //setDisplay(1);
    cs.SetStrokeWidth(2);       
    cs.SetFillMode (1);
            cs.SetColor(255,250,250,250); 
   cs.DrawRect (0,2,720,30);  // clear print x y
         //    cs.SetColor(255,20,40,120); 
 //   cs.DrawRect (10,30,710,730);  // box backcolor
             cs.SetColor(255,80,190,180); 
    cs.DrawRect (0,740,720,995);  // btn backcolor
             cs.SetColor(255,220,0,220); 
        cs.SetTextSize (28);               
        ss1="编译人:张纯叔  ( micelu@126.com ) ";
        cs.DrawText (ss1,20,1020);
        dy=800;   //draw button bn1 - bn12
        for (i=0;i<2;i++){
               cs.SetColor(255,240,200,20);  //big 2B
           cs.DrawCircle (480+i*120,800,38); 
           cs.DrawCircle (518+i*120,800,38);  
               cs.SetColor(255,40,40,200); 
           cs.DrawCircle (482+i*120,800,35); 
           cs.DrawCircle (516+i*120,800,35);   }

        cs.SetColor(255,240,200,20);  //big B
           cs.DrawCircle (540,900,42); 
           cs.DrawCircle (574,900,42);  
               cs.SetColor(255,40,40,200); 
           cs.DrawCircle (542,900,38); 
           cs.DrawCircle (572,900,38);       

      dy=850;
      cs.SetColor(255,240,200,20);   //small B
             cs.DrawCircle (50,dy-40,27); 
          cs.DrawRect (50,dy-68,105,dy-13);     
             cs.DrawCircle (50,dy+20,27); 
          cs.DrawRect (50,dy-7,105,dy+48);     
             cs.DrawCircle (370,dy-40,27); 
          cs.DrawRect (314,dy-68,370,dy-13);     
             cs.DrawCircle (370,dy+20,27); 
          cs.DrawRect (314,dy-7,370,dy+48);     

            cs.DrawCircle (50,dy+100,27); 
          cs.DrawRect (50,dy+73,105,dy+128);     
             cs.DrawCircle (370,dy+100,27); 
          cs.DrawRect (314,dy+73,370,dy+128);     //

      cs.SetColor(255,20,20,220);   //small B center
            cs.DrawCircle (50,dy-40,25); 
          cs.DrawRect (48,dy-66,101,dy-15);     
            cs.DrawCircle (50,dy+20,25); 
          cs.DrawRect (48,dy-5,101,dy+46);     

            cs.DrawCircle (370,dy-40,25); 
         cs.DrawRect (318,dy-66,368,dy-15);     
            cs.DrawCircle (370,dy+20,25); 
          cs.DrawRect (318,dy-5,368,dy+46);     

            cs.DrawCircle (50,dy+100,25); 
          cs.DrawRect (50,dy+75,101,dy+126);     
             cs.DrawCircle (370,dy+100,25); 
          cs.DrawRect (318,dy+75,368,dy+126);     
     for (i=0;i<3;i++){     //small 6B
     cs.SetColor(255,240,200,20);   //small B
          cs.DrawCircle (150,dy-70+i*70,27); 
        cs.DrawRect (150,dy-97+i*70,205,dy-42+i*70);     
          cs.DrawCircle (270,dy-70+i*70,27); 
        cs.DrawRect (214,dy-97+i*70,270,dy-42+i*70);     
     cs.SetColor(255,20,20,200);   //small B
          cs.DrawCircle (150,dy-70+i*70,25); 
        cs.DrawRect (148,dy-95+i*70,201,dy-44+i*70);     
          cs.DrawCircle (270,dy-70+i*70,25); 
       cs.DrawRect (218,dy-95+i*70,268,dy-44+i*70);     
          }
     cs.SetColor (255,255,255,20);
           cs.SetTextSize (22);
      cs.DrawText ("左上 L'  ",32,816);
      cs.DrawText ("左下 L  ",32,877);
      cs.DrawText ("后左 B'  ",32,958);
      cs.DrawText ("右上 R  ",325,816);
      cs.DrawText ("右下 R' ",325,877);
      cs.DrawText ("后右 B  ",325,958);
      cs.DrawText ("上左 U  ",132,788);
      cs.DrawText ("上右 U'  ",224,788);
      cs.DrawText ("前左 F'  ",132,858);
      cs.DrawText ("前右 F   ",224,858);
      cs.DrawText ("下左 D'  ",132,928);
      cs.DrawText ("下右 D   ",224,928);
           cs.SetTextSize (26);
      cs.DrawText ("左旋转     ",460,808);
      cs.DrawText ("右旋转     ",582,808);
      cs.DrawText ("翻  转     ",526,908);    
  cs.Update ();
}//drawButton ()

Turnup (){
   sw[1]=B[21];
     sw[2]=B[22];
     sw[3]=B[23];
     sw[4]=B[24];
     sw[5]=B[25];
     sw[6]=B[26];
     sw[7]=B[27];
     sw[8]=B[28];
     sw[9]=B[29];
       B[21]=B[61];
       B[22]=B[62];
       B[23]=B[63];
       B[24]=B[64];
       B[25]=B[65];
       B[26]=B[66];
       B[27]=B[67];
       B[28]=B[68];
       B[29]=B[69];
          B[61]=B[59];
       B[62]=B[58];
       B[63]=B[57];
       B[64]=B[56];
       B[65]=B[55];
       B[66]=B[54];
       B[67]=B[53];
       B[68]=B[52];
       B[69]=B[51];
          B[59]=B[41];
       B[58]=B[42];
       B[57]=B[43];
       B[56]=B[44];
       B[55]=B[45];
       B[54]=B[46];
       B[53]=B[47];
       B[52]=B[48];
       B[51]=B[49];
         B[41]=sw[1];
       B[42]=sw[2];
       B[43]=sw[3];
       B[44]=sw[4];
       B[45]=sw[5];
       B[46]=sw[6];
       B[47]=sw[7];
       B[48]=sw[8];
       B[49]=sw[9];
        sw[1]=B[11];        
    B[11]=B[13];        
    B[13]=B[19];        
    B[19]=B[17];        
    B[17]=sw[1];        
       sw[2]=B[12];        
     B[12]=B[16];        
     B[16]=B[18];        
     B[18]=B[14];        
     B[14]=sw[2];        
        sw[1]=B[31];        
    B[31]=B[37];        
    B[37]=B[39];        
    B[39]=B[33];        
    B[33]=sw[1];        
       sw[2]=B[32];        
     B[32]=B[34];        
     B[34]=B[38];        
     B[38]=B[36];        
     B[36]=sw[2];        
     drawbox ();
print "do>   Turn Up ";
}//Turnup ()

Turnright (){
    sw[1]=B[21];
     sw[2]=B[22];
     sw[3]=B[23];
     sw[4]=B[24];
     sw[5]=B[25];
     sw[6]=B[26];
     sw[7]=B[27];
     sw[8]=B[28];
     sw[9]=B[29];
       B[21]=B[11];
       B[22]=B[12];
       B[23]=B[13];
       B[24]=B[14];
       B[25]=B[15];
       B[26]=B[16];
       B[27]=B[17];
       B[28]=B[18];
       B[29]=B[19];
          B[11]=B[51];
       B[12]=B[52];
       B[13]=B[53];
       B[14]=B[54];
       B[15]=B[55];
       B[16]=B[56];
       B[17]=B[57];
       B[18]=B[58];
       B[19]=B[59];
          B[51]=B[31];
       B[52]=B[32];
       B[53]=B[33];
       B[54]=B[34];
       B[55]=B[35];
       B[56]=B[36];
       B[57]=B[37];
       B[58]=B[38];
       B[59]=B[39];
         B[31]=sw[1];
       B[32]=sw[2];
       B[33]=sw[3];
       B[34]=sw[4];
       B[35]=sw[5];
       B[36]=sw[6];
       B[37]=sw[7];
       B[38]=sw[8];
       B[39]=sw[9];
        sw[1]=B[41];        
    B[41]=B[43];        
    B[43]=B[49];        
    B[49]=B[47];        
    B[47]=sw[1];        
       sw[2]=B[42];        
     B[42]=B[46];        
     B[46]=B[48];        
     B[48]=B[44];        
     B[44]=sw[2];        
        sw[1]=B[61];        
    B[61]=B[67];        
    B[67]=B[69];        
    B[69]=B[63];        
    B[63]=sw[1];        
       sw[2]=B[62];        
     B[62]=B[64];        
     B[64]=B[68];        
     B[68]=B[66];        
     B[66]=sw[2];        
     drawbox ();
print "do>   Turn right ";
}//Turnright ()

Turnleft (){
     sw[1]=B[21];
     sw[2]=B[22];
     sw[3]=B[23];
     sw[4]=B[24];
     sw[5]=B[25];
     sw[6]=B[26];
     sw[7]=B[27];
     sw[8]=B[28];
     sw[9]=B[29];
       B[21]=B[31];
       B[22]=B[32];
       B[23]=B[33];
       B[24]=B[34];
       B[25]=B[35];
       B[26]=B[36];
       B[27]=B[37];
       B[28]=B[38];
       B[29]=B[39];
          B[31]=B[51];
       B[32]=B[52];
       B[33]=B[53];
       B[34]=B[54];
       B[35]=B[55];
       B[36]=B[56];
       B[37]=B[57];
       B[38]=B[58];
       B[39]=B[59];
          B[51]=B[11];
       B[52]=B[12];
       B[53]=B[13];
       B[54]=B[14];
       B[55]=B[15];
       B[56]=B[16];
       B[57]=B[17];
       B[58]=B[18];
       B[59]=B[19];
         B[11]=sw[1];
       B[12]=sw[2];
       B[13]=sw[3];
       B[14]=sw[4];
       B[15]=sw[5];
       B[16]=sw[6];
       B[17]=sw[7];
       B[18]=sw[8];
       B[19]=sw[9];
        sw[1]=B[41];        
    B[41]=B[47];        
    B[47]=B[49];        
    B[49]=B[43];        
    B[43]=sw[1];        
       sw[2]=B[42];        
     B[42]=B[44];        
     B[44]=B[48];        
     B[48]=B[46];        
     B[46]=sw[2];        
        sw[1]=B[61];        
    B[61]=B[63];        
    B[63]=B[69];        
    B[69]=B[67];        
    B[67]=sw[1];        
       sw[2]=B[62];        
     B[62]=B[66];        
     B[66]=B[68];        
     B[68]=B[64];        
     B[64]=sw[2];        
     drawbox ();
print "do>   Turn left ";
}//Turnleft ()

Downleft (){
     sw[1]=B[27];
     sw[2]=B[28];
     sw[3]=B[29];
     B[27]=B[37];
     B[28]=B[38];
     B[29]=B[39];
     B[37]=B[57];
     B[38]=B[58];
     B[39]=B[59];
     B[57]=B[17];
     B[58]=B[18];
     B[59]=B[19];
     B[17]=sw[1];
     B[18]=sw[2];
     B[19]=sw[3];
        sw[1]=B[61];        
    B[61]=B[63];        
    B[63]=B[69];        
    B[69]=B[67];        
    B[67]=sw[1];        
       sw[2]=B[62];        
     B[62]=B[66];        
     B[66]=B[68];        
     B[68]=B[64];        
     B[64]=sw[2];        
     drawbox ();
print "do>  D'    Down left ";
}//Downleft()

Downright (){
     sw[1]=B[27];
     sw[2]=B[28];
     sw[3]=B[29];
     B[27]=B[17];
     B[28]=B[18];
     B[29]=B[19];
     B[17]=B[57];
     B[18]=B[58];
     B[19]=B[59];
     B[57]=B[37];
     B[58]=B[38];
     B[59]=B[39];
     B[37]=sw[1];
     B[38]=sw[2];
     B[39]=sw[3];
        sw[1]=B[61];        
    B[61]=B[67];        
    B[67]=B[69];        
    B[69]=B[63];        
    B[63]=sw[1];        
       sw[2]=B[62];        
     B[62]=B[64];        
     B[64]=B[68];        
     B[68]=B[66];        
     B[66]=sw[2];        
     drawbox ();
print "do>  D    Down right ";
}//Downright()

Backleft (){
     sw[1]=B[41];
     sw[2]=B[42];
     sw[3]=B[43];
     B[41]=B[17];
     B[42]=B[14];
     B[43]=B[11];
     B[17]=B[69];
     B[14]=B[68];
     B[11]=B[67];
     B[69]=B[33];
     B[68]=B[36];
     B[67]=B[39];
     B[33]=sw[1];
     B[36]=sw[2];
     B[39]=sw[3];
        sw[1]=B[51];        
    B[51]=B[53];        
    B[53]=B[59];        
    B[59]=B[57];        
    B[57]=sw[1];        
       sw[2]=B[52];        
     B[52]=B[56];        
     B[56]=B[58];        
     B[58]=B[54];        
     B[54]=sw[2];        
     drawbox ();
print "do>  B'    Back left ";
}//Backleft()

Backright (){
     sw[1]=B[41];
     sw[2]=B[42];
     sw[3]=B[43];
     B[41]=B[33];
     B[42]=B[36];
     B[43]=B[39];
     B[33]=B[69];
     B[36]=B[68];
     B[39]=B[67];
     B[69]=B[17];
     B[68]=B[14];
     B[67]=B[11];
     B[17]=sw[1];
     B[14]=sw[2];
     B[11]=sw[3];
        sw[1]=B[51];        
    B[51]=B[57];        
    B[57]=B[59];        
    B[59]=B[53];        
    B[53]=sw[1];        
       sw[2]=B[52];        
     B[52]=B[54];        
     B[54]=B[58];        
     B[58]=B[56];        
     B[56]=sw[2];        
     drawbox ();
print "do>  B    Back right ";
}//Backright()

Frontleft (){
     sw[1]=B[47];
     sw[2]=B[48];
     sw[3]=B[49];
     B[47]=B[31];
     B[48]=B[34];
     B[49]=B[37];
     B[31]=B[63];
     B[34]=B[62];
     B[37]=B[61];
     B[63]=B[19];
     B[62]=B[16];
     B[61]=B[13];
     B[19]=sw[1];
     B[16]=sw[2];
     B[13]=sw[3];
        sw[1]=B[21];        
    B[21]=B[23];        
    B[23]=B[29];        
    B[29]=B[27];        
    B[27]=sw[1];        
       sw[2]=B[22];        
     B[22]=B[26];        
     B[26]=B[28];        
     B[28]=B[24];        
     B[24]=sw[2];        
     drawbox ();
print "do>  F'    Front left ";
}//Frontleft()

Frontright (){
     sw[1]=B[47];
     sw[2]=B[48];
     sw[3]=B[49];
     B[47]=B[19];
     B[48]=B[16];
     B[49]=B[13];
     B[19]=B[63];
     B[16]=B[62];
     B[13]=B[61];
     B[63]=B[31];
     B[62]=B[34];
     B[61]=B[37];
     B[31]=sw[1];
     B[34]=sw[2];
     B[37]=sw[3];
        sw[1]=B[21];        
    B[21]=B[27];        
    B[27]=B[29];        
    B[29]=B[23];        
    B[23]=sw[1];        
       sw[2]=B[22];        
     B[22]=B[24];        
     B[24]=B[28];        
     B[28]=B[26];        
     B[26]=sw[2];        
     drawbox ();
print "do>  F    Front right ";
}//Frontright()

Upleft (){
     sw[1]=B[21];
     sw[2]=B[22];
     sw[3]=B[23];
     B[21]=B[31];
     B[22]=B[32];
     B[23]=B[33];
     B[31]=B[51];
     B[32]=B[52];
     B[33]=B[53];
     B[51]=B[11];
     B[52]=B[12];
     B[53]=B[13];
     B[11]=sw[1];
     B[12]=sw[2];
     B[13]=sw[3];
        sw[1]=B[41];        
    B[41]=B[47];        
    B[47]=B[49];        
    B[49]=B[43];        
    B[43]=sw[1];        
       sw[2]=B[42];        
     B[42]=B[44];        
     B[44]=B[48];        
     B[48]=B[46];        
     B[46]=sw[2];        
     drawbox ();
 print "do>  U    Up left ";
}//Upleft()

Upright (){
     sw[1]=B[21];
     sw[2]=B[22];
     sw[3]=B[23];
     B[21]=B[11];
     B[22]=B[12];
     B[23]=B[13];
     B[11]=B[51];
     B[12]=B[52];
     B[13]=B[53];
     B[51]=B[31];
     B[52]=B[32];
     B[53]=B[33];
     B[31]=sw[1];
     B[32]=sw[2];
     B[33]=sw[3];
      sw[1]=B[41];        
    B[41]=B[43];        
    B[43]=B[49];        
    B[49]=B[47];        
    B[47]=sw[1];        
       sw[2]=B[42];        
     B[42]=B[46];        
     B[46]=B[48];        
     B[48]=B[44];        
     B[44]=sw[2];        
     drawbox ();
print "do>  U'    Up right ";
}//Upright ()

Rightdown (){
     sw[1]=B[23];
     sw[2]=B[26];
     sw[3]=B[29];
     B[23]=B[43];
     B[26]=B[46];
     B[29]=B[49];
     B[43]=B[57];
     B[46]=B[54];
     B[49]=B[51];
     B[57]=B[63];
     B[54]=B[66];
     B[51]=B[69];
     B[63]=sw[1];
     B[66]=sw[2];
     B[69]=sw[3];
         sw[1]=B[31];        
     B[31]=B[33];        
     B[33]=B[39];        
     B[39]=B[37];        
     B[37]=sw[1];        
        sw[2]=B[32];        
     B[32]=B[36];        
     B[36]=B[38];        
     B[38]=B[34];        
     B[34]=sw[2];        
     drawbox ();
print "do>  R'    Right down ";
}//Rightdown()

Rightup (){
     sw[1]=B[23];
     sw[2]=B[26];
     sw[3]=B[29];
     B[23]=B[63];
     B[26]=B[66];
     B[29]=B[69];
     B[63]=B[57];
     B[66]=B[54];
     B[69]=B[51];
     B[57]=B[43];
     B[54]=B[46];
     B[51]=B[49];
     B[43]=sw[1];
     B[46]=sw[2];
     B[49]=sw[3];
       sw[1]=B[31];        
    B[31]=B[37];        
    B[37]=B[39];        
    B[39]=B[33];        
    B[33]=sw[1];        
       sw[2]=B[32];        
     B[32]=B[34];        
     B[34]=B[38];        
     B[38]=B[36];        
     B[36]=sw[2];        
     drawbox ();
print "do>  R    Right up ";
}//Rightup()

Leftdown (){
     sw[1]=B[21];
     sw[2]=B[24];
     sw[3]=B[27];
     B[21]=B[41];
     B[24]=B[44];
     B[27]=B[47];
     B[41]=B[59];
     B[44]=B[56];
     B[47]=B[53];
     B[59]=B[61];
     B[56]=B[64];
     B[53]=B[67];
     B[61]=sw[1];
     B[64]=sw[2];
     B[67]=sw[3];
       sw[1]=B[11];        
    B[11]=B[17];        
    B[17]=B[19];        
    B[19]=B[13];        
    B[13]=sw[1];        
       sw[2]=B[12];        
     B[12]=B[14];        
     B[14]=B[18];        
     B[18]=B[16];        
     B[16]=sw[2];        
     drawbox ();
print "do>  L     Left down ";
}//Leftdown()

Leftup (){
     sw[1]=B[21];
     sw[2]=B[24];
     sw[3]=B[27];
     B[21]=B[61];
     B[24]=B[64];
     B[27]=B[67];
     B[61]=B[59];
     B[64]=B[56];
     B[67]=B[53];
     B[59]=B[41];
     B[56]=B[44];
     B[53]=B[47];
     B[41]=sw[1];
     B[44]=sw[2];
     B[47]=sw[3];
        sw[1]=B[11];        
     B[11]=B[13];        
     B[13]=B[19];        
     B[19]=B[17];        
     B[17]=sw[1];        
        sw[2]=B[12];        
     B[12]=B[16];        
     B[16]=B[18];        
     B[18]=B[14];        
     B[14]=sw[2];        
     drawbox ();
print "do>  L'     Left up ";
}//Leftup()
 
newgame (){
      s3="开始游戏 ";
   getTime (tim);
      newhh=tim[0];
      newmm=tim[1];
      newss=tim[2];
      oldhh=newhh;
      oldmm=newmm;
      oldss=newss;
   hhts=intToString (tim[0]);
   mmts=intToString (tim[1]);
   ssts=intToString (tim[2]);
   if (newhh<10)hhts="0"+hhts;
   if (newmm<10)mmts="0"+mmts;
   if (newss<10)ssts="0"+ssts;
       ss2=hhts+" : "+mmts+" : "+ssts;
       print "开始时间 "+ss2;
         kn=2;      //set canvasProc
       //  restore ();
  for (i=0;i<5;i++){
      Rn=(int)(random()*11+1);     //random bn
            if (Rn==1){Leftup ();  }
            if (Rn==2){Leftdown ();  }    
            if (Rn==3){Rightup ();  }
            if (Rn==4){Rightdown ();  }
            if (Rn==5){Upleft ();  }
            if (Rn==6){Upright ();  }
            if (Rn==7){Frontleft ();  }
            if (Rn==7){Frontright ();  }
            if (Rn==9){Backleft ();  }
            if (Rn==10){Backright ();  }
            if (Rn==11){Downleft ();  }
            if (Rn==12){Downright ();  }
                   }
     Turnup ();
     Turnup ();
}//newgame ()

restore (){
  //initlize cube color
    for (i=1;i<10;i++){
          B[10+i]=1;
          B[20+i]=2;
          B[30+i]=3;   
          B[40+i]=4;
          B[50+i]=5;
          B[60+i]=6;     }
      drawButton ();
      drawbox ();
}//restore ()

drawcover (){    //  启动页面
    restore ();  //initlize cube
         cs.SetTextStyle (1);    //正常 粗体 斜体字
     cs.SetStrokeWidth (2);
     cs.SetTextSize (78);
      s="魔方 Magic Cube ";
   cs.SetColor (255,250,20,20);
      cs.DrawText (s,74,454);
      cs.SetTextSize (76);
   cs.SetColor (255,160,30,240);
      cs.DrawText (s,80,450);
   cs.SetFillMode (0);//0不填色,1填色
   cs.SetColor (255,250,250,120);
      cs.DrawText (s,80,450);
      cs.SetTextSize (26);
   cs.SetFillMode (1);//0不填色,1填色
   //cs.SetTextStyle (1);    //正常 粗体 斜体字
      s="@Copyright  version 2.1.1 ";
   cs.SetColor (255,250,50,50);
      cs.DrawText (s,212,490);
      cs.SetTextStyle (0);                
   cs.Update ();
}//drawcover()

switchcolor (){  //set cube 1--6 color
    if (scolor==1){cr1=20;    cg1=20;    cb1=250;   }
    if (scolor==2){ cr1=20;   cg1=250;  cb1=20;     }
    if (scolor==3){cr1=20;    cg1=140;  cb1=20;     }
    if (scolor==4){cr1=250;  cg1=20;    cb1=250;   }
    if (scolor==5){cr1=250;  cg1=200;  cb1=20;     }
    if (scolor==6){cr1=250;  cg1=20;    cb1=20;     }
 }//switchcolor ()

myMenuProc(int nMen,int nContext){
   if(nMen==200){
        print "开始游戏";
       // cs.ClearDraw (0,src);    
         clearOutput ();
        newgame();  }    
   if(nMen==201){
           print "上层四棱";
           Astep1 ();      }  
   if(nMen==202){
           print "上层四角";
           Astep2 ();      }  
   if (nMen==203){//
           print "二层四棱";
           Astep3 ();         }
   if (nMen==204){//选项
           print "顶层十字";
           Astep4 ();         }
   if(nMen==205){//close canvas
          print "顶面同色";
          Astep5 ();          }  
    if(nMen==206){//show canvas
          print "六面同色";
          Astep6 ();          }
    if (nMen==207){//
           clearOutput ();
           //print "自动演示";
            Autoplay ();         }
    if (nMen==208){//show step data
        setDisplay (0);            }     
    if (nMen==209){//show canvas
        setDisplay (1);            }     
    if (nMen==210){//exit
        clearOutput();
        cs.ClearDraw (0,src);
        setDisplay (0);
        exit (0);    }     
 }//myMenu()

myToolBarProc(int nBtn,int nContext){
   if(nBtn==100){//Newgame
         clearOutput ();
          newgame();            }
   if(nBtn==101){//restore cube box
          clearOutput ();
          restore ();             }
   if(nBtn==102){//AutoPlay
         clearOutput ();
         //print "自动演示";
          Autoplay ();         }
   if(nBtn==103){//显示图板
             setDisplay (1);          }   
   if(nBtn==104){//退出程序
         clearOutput();
         cs.ClearDraw (0,src);
         setDisplay (0);
          exit (0);               }
   if(nBtn==105){//版本信息
           setDisplay (1);
          drawcover ();           }
}//my toolbar()

savepic (){
        filebox.SetTitle("保存图片(*.bmp;*.jpg;*.png)");
        filebox.SetFilter(".bmp;.jpg;.png");
        filebox.SetMode(1);
        filebox.Show();
            if(filebox.GetCount()==1){
            fname=filebox.GetFileName(0);
            cs.SaveBitmap(fname);    }

//**** End ****

 

 

 

 

  • 1
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值