image thumbnail
from Clock Bell by Krishna Lalith
Place the coins on turn basis, on the board to complete &/or to block to gain different medals.

Clock_Bell(action)
function Clock_Bell(action)

global Clock turn Score Utimehand Ctimehand Utime Ctime UUUhand CPUhand;
global Upoint Cpoint UMedal CMedal UMedalHand CMedalHand UScore CScore fig;
global win MultiP timelimit History Count UCoinHand CCoinHand Xpos Ypos;
global UXpos UYpos CXpos CYpos XPos YPos FXPos FYPos UScoreadd CScoreadd;
global PauseHand Uback Cback Player1 Player2 Level EasyHand HardHand;
global FunnyHand HH MH H M UTH CTH P1C P2C;
clc
%--------------------------------------------------------------------------
if nargin < 1, 
    action = 'initialize'; 
    turn=mod(fix(10*rand(1,1)),2); MultiP=0;%by default Play with CPU  
    Uback=0; Cback=0; Level=1;%by default Hard Level against CPU 
    P1C=[1 0.6 0.3];    P2C=[1 1 1];
end
%--------------------------------------------------------------------------
if strcmp(action,'initialize')   
    Count=1; Clock=5*ones(12,4); win=0; History=[];
    
    %time
    Utime=10*60;    Ctime=10*60;
    UScore=0;       CScore=0;
    UMedal=[];      CMedal=[];   
%--------------------------------------------------------------------------   
    fig=figure( ...
                'Name','Clock Bell', 'NumberTitle','off', ...
                'Visible','off', 'BackingStore','off');
    figure(fig);
    hold on      
    
    %Clock Hands     
    HH=fill([5 5+2*cos((H-0.3)*pi/6) 5+3*cos(H*pi/6) 5+2*cos((H+0.3)*pi/6) 5],[5 5+2*sin((H-0.3)*pi/6) 5+3*sin(H*pi/6) 5+2*sin((H+0.3)*pi/6) 5],'w');    
    MH=fill([5 5+3*cos((M-0.75)*pi/30) 5+4*cos(M*pi/30) 5+3*cos((M+0.75)*pi/30) 5],[5 5+3*sin((M-0.75)*pi/30) 5+4*sin(M*pi/30) 5+3*sin((M+0.75)*pi/30) 5],'w');
    TimeHand();
    set(HH,'facecolor',[0.8 0.8 0.7],'edgecolor',[1 0.5 0.2]);
    set(MH,'facecolor',[0.8 0.8 0.7],'edgecolor',[1 0.5 0.2]);

    %Boundary
    rectangle('Position', [1 1 8 8],'linewidth',0.25,'edgecolor',[1 0.5 0.2]);
    
    %radial lines
    for ii=1:6,   
        line([5+4*cos(ii*pi/6) 5+4*cos((6+ii)*pi/6)],[5+4*sin(ii*pi/6) 5+4*sin((6+ii)*pi/6)],'color',[1 0.5 0.2],'LineStyle','--');
    end
    
    %Minute Lines
    for ii=1:0.2:12.8,
        for jj=1:4,     
             line([5+0.9*jj*cos(ii*pi/6) 5+jj*cos(ii*pi/6)],[5+0.9*jj*sin(ii*pi/6) 5+jj*sin(ii*pi/6)],'color',[1 0.6 0.5],'LineStyle','--');
        end
    end 
    
    %center
    Xcir=5+0.2*cos(0:1/50:2*pi);
    Ycir=5+0.2*sin(0:1/50:2*pi);
    Cent=fill(Xcir,Ycir,'r');
    set(Cent,'edgecolor',[1 0.6 0.3]);
    
    %board circles
    for ii=1:4
        Xcir=5+ii*cos(0:1/50:2*pi);
        Ycir=5+ii*sin(0:1/50:2*pi);          
        plot(Xcir,Ycir,'color',[1 0.5 0.2],'linewidth',1.25);        
    end
    
    %Collecting valid Positions
    for ii=1:12
        for jj=1:4              
             XPos(ii,jj)=5+jj*cos(ii*pi/6);
             YPos(ii,jj)=5+jj*sin(ii*pi/6);
             plot(XPos(ii,jj),YPos(ii,jj),'.','color',[0.2 0.5 1],'markersize',14);
             kk=SwitchModel(ii);
             FunnyHand(ii,jj)=text(0.25+XPos(ii,jj),0.25+YPos(ii,jj),sprintf('%1d',kk),'color',[0.2 0.5 1],'fontsize',8);
             set(FunnyHand(ii,jj),'visible','off');
        end
    end   
    
    %Collecting Click Positions
    for ii=1:12
        for jj=1:4              
             FXPos(ii,jj)=290+32*jj*cos(ii*pi/6);
             FYPos(ii,jj)=218+32*jj*sin(ii*pi/6);
        end
    end 
    
    %Points
    text(5.25,0.42,'Points','color',[0.9 0.5 0.8],'fontsize',10,'fontweight','bold');
    text(5.15,0.26,'---------','color',[0.0 0.0 0.0],'fontsize',12,'fontweight','bold');
    text(3,-0.2,' Radial            Circular      Spiral','color',[0.8 1 0.3],'fontsize',8,'fontweight','bold');
    text(0.5,-0.7,'Sequential','color',[0.5 0.5 1],'fontsize',8,'fontweight','bold');
    text(0.5,-1.4,'Alternate','color',[0.5 0.5 1],'fontsize',8,'fontweight','bold');
    text(2.75,-0.7,'\rightarrow    = 10','color',[0.8 0.3 0.3],'fontsize',10,'fontweight','bold');
    text(2.75,-1.4,'\leftarrow\rightarrow = 40','color',[0.8 0.3 0.3],'fontsize',10,'fontweight','bold');
    text(5.25,-0.7,'\oslash = 20','color',[0.8 0.3 0.3],'fontsize',10,'fontweight','bold');
    text(5.25,-1.4,'O  = 50','color',[0.8 0.3 0.3],'fontsize',10,'fontweight','bold');
    text(7.25,-0.7,'\partial = 30','color',[0.8 0.3 0.3],'fontsize',10,'fontweight','bold');
    text(7.25,-1.4,'\vartheta = 60','color',[0.8 0.3 0.3],'fontsize',10,'fontweight','bold');

    %Medals
    text(-1.25,6.25,'Medals','color',[0.8 1 0.3],'fontsize',10,'fontweight','bold');
    text(-1.25,6.05,'---------','color',[0.0 0.0 0.0],'fontsize',12,'fontweight','bold');
    text(9.75,6.25,'Medals','color',[0.8 1 0.3],'fontsize',10,'fontweight','bold');
    text(9.75,6.05,'---------','color',[0.0 0.0 0.0],'fontsize',12,'fontweight','bold');
    %Medals=['\rightarrow' '\leftarrow\rightarrow' '\oslash' 'O' '\partial' '\vartheta'];
    %Medal#=[1 2 3 4 5 6];
    Score=[10 40 20 50 30 60];       
    
    %timers
    rectangle('Position', [-1.9 7.25 1.75 0.75],'linewidth',2,'edgecolor','w');
    rectangle('Position', [10.2 7.25 1.75 0.75],'linewidth',2,'edgecolor','k');
    Utimehand=text(-1.7,7.6,sprintf('%02.0f : %02.0f',floor(Utime/60),mod(Utime,60)),'color','k','fontweight','bold');
    Ctimehand=text(10.5,7.6,sprintf('%02.0f : %02.0f',floor(Ctime/60),mod(Ctime,60)),'color','w','fontweight','bold');    
%--------------------------------------------------------------------------
    %measuring lines
    line([-2 -2],[1 7],'color','k');
    line([12 12],[1 7],'color','k');

    %measuring numbers
    for ii=1:7
        text(-2.5,ii,sprintf('%3d',100*(ii-1)),'color','k','fontsize',7);
        text(12.1,ii,sprintf('%d',100*(ii-1)),'color','k','fontsize',7);
    end

    %measuring divisions
    for ii=1:0.1:7
        text(-2,ii,'-','color','w','fontsize',12);
        text(12,ii,'-','color','w','fontsize',12);
        if ii==fix(ii),
            text(-2,ii,'-','color','k','fontsize',16);
            text(12,ii,'-','color','k','fontsize',16);
        end        
    end
    
    %score pointer
    Upoint=fill([-2 -1.6 -1.6],[(1+UScore/100) (1+UScore/100)-0.25 (1+UScore/100)+0.25],'r','edgecolor','k');
    Cpoint=fill([12 11.6 11.6],[(1+CScore/100) (1+CScore/100)-0.25 (1+CScore/100)+0.25],'r','edgecolor','k');
%--------------------------------------------------------------------------
    %Medals
    UH=[-1.25 -0.25];
    UV=[5.5 4.75 4 3.25 2.5];
    CH=[9.7 10.7];
    CV=[5.5 4.75 4 3.25 2.5];
    for ii=1:10,
        UMedalHand(ii)=text(UH(1+~mod(ii,2)),UV(ceil((ii-0.1)/2)),' ','color',[0.5 0.5 1],'fontsize',10,'fontweight','bold');
        CMedalHand(ii)=text(CH(1+~mod(ii,2)),CV(ceil((ii-0.1)/2)),' ','color',[0.5 0.5 1],'fontsize',10,'fontweight','bold');
    end

    if isempty(UMedal)
        UMedalHand(11)=text(-1,5,'\ldots','color',[0.5 0.5 1]);
        set(UMedalHand(11),'fontsize',20,'fontweight','bold');
    end

    if isempty(CMedal)
        CMedalHand(11)=text(10,5,'\ldots','color',[0.5 0.5 1]);
        set(CMedalHand(11),'fontsize',20,'fontweight','bold');
    end
%--------------------------------------------------------------------------  
    %Positions on Board
    for ii=1:12,
        for jj=1:4,           
            Xpos(4*(ii-1)+jj,:)=(5+jj*cos(ii*pi/6))+0.25*cos(0:1/50:2*pi);
            Ypos(4*(ii-1)+jj,:)=(5+jj*sin(ii*pi/6))+0.25*sin(0:1/50:2*pi);
        end
    end
    
    %Coins Handles
    Urow=[-0.5 -1 -1.5];
    Ucol=2.5:-0.5:0.5;
    for ii=1:3,
        for jj=1:5,           
            Xcir=(0.5+Urow(ii))+0.2*cos(0:1/50:2*pi);
            Ycir=(0.5+Ucol(jj))+0.2*sin(0:1/50:2*pi);
            UXpos(5*(ii-1)+jj,:)=Xcir;
            UYpos(5*(ii-1)+jj,:)=Ycir;
            UCoinHand(5*(ii-1)+jj)=fill(Xcir,Ycir,'w','edgecolor','w');  
        end
    end

    Crow=[9.5 10 10.5];
    Ccol=2.5:-0.5:0.5;
    for ii=1:3
        for jj=1:5           
            Xcir=(0.5+Crow(ii))+0.2*cos(0:1/50:2*pi);
            Ycir=(0.5+Ccol(jj))+0.2*sin(0:1/50:2*pi);
            CXpos(5*(ii-1)+jj,:)=Xcir;
            CYpos(5*(ii-1)+jj,:)=Ycir;
            CCoinHand(5*(ii-1)+jj)=fill(Xcir,Ycir,'k','edgecolor','k');  
        end
    end
%--------------------------------------------------------------------------    
    %Turn Handles
    UUUhand=text(-2,9,'UUU','color','w');
    CPUhand=text(10.75,9,'CPU','color','k');
    
    Clock_Bell_Board();
    title('Clock Bell','fontsize',18,'color','b');
    axis([-2 12 0 10]);
    axis equal
    axis off;
    set(gcf,'Resize','off');
    
    %Turn Handles
    Player1 = 'UUU';
    Player1 = inputdlg({'Enter your name'},'Player',1,{Player1});
    set(UUUhand,'string',Player1);
        
    if MultiP==1,
        Player2 = 'CPU';
        Player2 = inputdlg({'Enter 2nd Player name'},'Player',1,{Player2});
        set(CPUhand,'string',Player2);
    end
    
    for ii=1:2,
        UTH(ii)=text(4.15-ii/1.2,10,'\leftarrow','color','k','fontsize',15);
        CTH(ii)=text(5.15+ii/1.2,10,'\rightarrow','color','k','fontsize',15);
    end
%--------------------------------------------------------------------------    
    %setting timelimits
    timelimit = Utime/60;
    timelimit = inputdlg({'Time limit [min]'},'Time Limit',1,{num2str(timelimit)});
    if isempty(timelimit)
        close(fig);
        return;
    end
    timelimit=str2double(timelimit);
    Utime=timelimit*60;
    Ctime=timelimit*60;
    if MultiP==0,
        msg={'Select "2P" for Multi-Player (by default it is with CPU [1P]...'};
        [namastedata namastemap]=imread('namaste.jpg');
        msgbox(msg,'Number of Players!!!','custom',namastedata,namastemap);        
        pause(3);
    end
%--------------------------------------------------------------------------
    Clock_Bell_Board();
%--------------------------------------------------------------------------
% Handling the handles

axes( ...
        'Units','normalized',  ...
        'Visible','off', 'DrawMode','fast', ...
        'NextPlot','replace');

uicontrol('units','normalized',...
          'position', [.01 .03 .06 .06],'string','New', ...
          'callback','Clock_Bell(''New'')', ...
          'interruptible','on','fontweight','bold','BackgroundColor',[1 1 1]);

uicontrol('units','normalized',...
          'position', [.09 .07 .05 .06],'string','1P', ...
          'callback','Clock_Bell(''1P'')', ...
          'interruptible','on','fontweight','bold','BackgroundColor',P1C);

uicontrol('units','normalized',...
          'position', [.09 .00 .05 .06],'string','2P', ...
          'callback','Clock_Bell(''2P'')', ...
          'interruptible','on','fontweight','bold','BackgroundColor',P2C);

uicontrol('units','normalized',...
          'position', [.155 .03 .07 .06],'string','Undo', ...
          'callback','Clock_Bell(''Undo'')', ...
          'interruptible','on','fontweight','bold','BackgroundColor',[1 1 1]);

uicontrol('units','normalized',...
          'position',[.78 .02 .06 .06],'string','Help', ...
	      'callback','Clock_Bell(''Help'')', ...
	      'interruptible','on','fontweight','bold','BackgroundColor',[1 1 1]);

PauseHand=uicontrol('units','normalized',...
          'position',[.85 .02 .08 .06],'string','Pause', ...
	      'callback','Clock_Bell(''Pause'')', ...
	      'interruptible','on','fontweight','bold','BackgroundColor',[1 1 1]);

uicontrol('units','normalized',...
          'position',[.94 .02 .06 .06],'string','Exit', ...
	      'callback','Clock_Bell(''Exit'')', ...
	      'interruptible','off','fontweight','bold','BackgroundColor',[1 1 1]);
      
EasyHand=uicontrol('units','normalized',...
          'position',[.82 .09 .06 .06],'string','Easy', ...
	      'callback','Clock_Bell(''Easy'')', ...
	      'interruptible','on','fontweight','bold','BackgroundColor',[1 1 1]);

HardHand=uicontrol('units','normalized',...
          'position',[.9 .09 .06 .06],'string','Hard', ...
	      'callback','Clock_Bell(''Hard'')', ...
	      'interruptible','on','fontweight','bold','BackgroundColor',[1 0.6 0.3]);

if mod(turn,2)==0, Clock_Bell('UUU');  end
if mod(turn,2)==1, Clock_Bell('CPU');  end
end
%--------------------------------------------------------------------------
if strcmp(action,'UUU') 
    NewClock(FunnyHand);
    for ii=1:2,
        set(UTH(ii),'color','w');
        set(CTH(ii),'color',[0.8 0.8 0.8]);
    end
    t1=clock;
    Button=1;
    while Button==1,  
          valid=[0 0];
          set(fig,'Currentpoint',[0 0]);
          while valid==zeros(1,2),
                valid = get(fig,'Currentpoint');
                t2=clock;
                set(Utimehand,'string',sprintf('%02.0f : %02.0f',floor((Utime+Uback-floor(etime(t2,t1)))/60),mod((Utime+Uback-floor(etime(t2,t1))),60)));
                pause(1);
                Xnew=valid(1); Ynew=valid(2);
                if floor((Utime+Uback-floor(etime(t2,t1)))/60)<0,  Clock_Bell('win'); end
                TimeHand();
          end          
          
          if valid==zeros(1,2), Button=1;  continue;  end
          
          FDmin=1000;
          for ii=1:12,
            for jj=1:4,     
                if FDmin>=sqrt((Xnew-FXPos(ii,jj))^2+(Ynew-FYPos(ii,jj))^2),
                    FDmin=sqrt((Xnew-FXPos(ii,jj))^2+(Ynew-FYPos(ii,jj))^2);
                    Dij=[ii jj];
                end
            end
          end
   
       if (~isempty(Dij) && Button==1),           
           if Clock(Dij(1),Dij(2))==5, 
               Clock(Dij(1),Dij(2))=1;   
               wavplay(wavread('UUU.wav')); 
               set(UCoinHand(length(find(Clock==1))),'Xdata',Xpos(4*(Dij(1)-1)+Dij(2),:),'Ydata',Ypos(4*(Dij(1)-1)+Dij(2),:));
               for ii=1:2,
                    set(UCoinHand(length(find(Clock==1))),'facecolor','b','edgecolor','b');
                    pause(0.5);
                    set(UCoinHand(length(find(Clock==1))),'facecolor','w','edgecolor','w');
                    pause(0.5);
               end
               History(Count,:)=[Dij(1) Dij(2)];
               Count=Count+1;
               Button=0;
           end
       end
    end    
   
    Utime=Utime+Uback-floor(etime(t2,t1));
    Uback=0;
    turn=turn+1;
    UMedaltmp=UMedal;
    UMedal=Check_Medal(Clock,turn); 
    Clock_Bell_Board();
    pause(0.5);
      
    UScoreadd=0;
    if length(UMedal)>length(UMedaltmp)+1,
        Uadd=0;Uaddtmp=0;
        for ii=1:length(UMedal)
            Uadd=Uadd+Score(UMedal(ii));
        end
        for ii=1:length(UMedaltmp)
            Uaddtmp=Uaddtmp+Score(UMedaltmp(ii));
        end
        UScoreadd=(length(UMedal)-length(UMedaltmp)-1)*(Uadd-Uaddtmp)/4;
    end
    
    if length(UMedal)>length(UMedaltmp),
        wavplay(wavread('alarm1.wav')); 
        Clock_Show(Clock,turn);
    end 
    
    win=Check_Status();
    if win==1,          
        Clock_Bell('win');
    end
    
    if (length(find(Clock==1))-length(find(Clock==0)))>1,
        clf;
        closereq;
        Clock_Bell('initialize'); 
    end
    
    TimeHand();
    Clock_Bell('CPU');
end
%--------------------------------------------------------------------------
if strcmp(action,'CPU')    
    NewClock(FunnyHand);    
    for ii=1:2,
        set(CTH(ii),'color','k');
        set(UTH(ii),'color',[0.8 0.8 0.8]);
    end
    t1=clock;
    %UUU
    if MultiP==1,
        Button=1;
        while Button==1,
              valid=[0 0];
              set(fig,'Currentpoint',[0 0]);
              while valid==zeros(1,2),
                    valid = get(fig,'Currentpoint');
                    t2=clock;
                    set(Ctimehand,'string',sprintf('%02.0f : %02.0f',floor((Ctime+Cback-floor(etime(t2,t1)))/60),mod((Ctime+Cback-floor(etime(t2,t1))),60)));
                    pause(1);
                    Xnew=valid(1); Ynew=valid(2);
                    if floor((Ctime+Cback-floor(etime(t2,t1)))/60)<0,  Clock_Bell('win'); end
                    TimeHand();
              end
              
              FDmin=1000;
              for ii=1:12,
                for jj=1:4,     
                    if FDmin>=sqrt((Xnew-FXPos(ii,jj))^2+(Ynew-FYPos(ii,jj))^2),
                        FDmin=sqrt((Xnew-FXPos(ii,jj))^2+(Ynew-FYPos(ii,jj))^2);
                        Dij=[ii jj];
                    end
                end
              end
    
            if (~isempty(Dij) && Button==1),           
                if Clock(Dij(1),Dij(2))==5, 
                    Clock(Dij(1),Dij(2))=0; 
                    wavplay(wavread('CPU.wav'));
                    History(Count,:)=[Dij(1) Dij(2)];
                    Count=Count+1;
                    Button=0;
                end
            end
        end 
    end
    
    %CPU
    if MultiP==0,
        [Xnew Ynew]=AI(Clock);
        Dij=[Xnew Ynew];
        %Any Valid Move
        if (Xnew==0 && Ynew==0),
            for ii=1:12,
                for jj=1:4,
                    if Clock(ii,jj)==5,
                        Xnew=ii;  Ynew=jj;
                        Dij=[ii jj];                        
                    end
                end
            end
        end          
        History(Count,:)=[Xnew Ynew];
        Count=Count+1;
        Clock(Xnew,Ynew)=0;
        wavplay(wavread('CPU.wav'));
        pause(0.5);
        t2=clock;
        Ctime=Utime;
    end
    
    set(CCoinHand(length(find(Clock==0))),'Xdata',Xpos(4*(Dij(1)-1)+Dij(2),:),'Ydata',Ypos(4*(Dij(1)-1)+Dij(2),:));
    for ii=1:2,
        set(CCoinHand(length(find(Clock==0))),'facecolor','r','edgecolor','r');
        pause(0.5);
        set(CCoinHand(length(find(Clock==0))),'facecolor','k','edgecolor','k');    
        pause(0.5);
    end
    Ctime=Ctime+Cback-floor(etime(t2,t1));
    Cback=0;
    turn=turn-1;
    CMedaltmp=CMedal;
    CMedal=Check_Medal(Clock,turn);  
    Clock_Bell_Board();    
    pause(0.5);
    
    CScoreadd=0;
    if length(CMedal)>length(CMedaltmp)+1,
        Cadd=0;Caddtmp=0;
        for ii=1:length(CMedal)
            Cadd=Cadd+Score(CMedal(ii));
        end
        for ii=1:length(CMedaltmp)
            Caddtmp=Caddtmp+Score(CMedaltmp(ii));
        end
        CScoreadd=(length(CMedal)-length(CMedaltmp)-1)*(Cadd-Caddtmp)/4;
    end
    
    if length(CMedal)>length(CMedaltmp),
        wavplay(wavread('alarm2.wav'));
        Clock_Show(Clock,turn);
    end
    
    win=Check_Status();
    if win==1, 
        Clock_Bell('win');
    end   
    
    if (length(find(Clock==0))-length(find(Clock==1)))>1,
        clf;
        closereq;
        Clock_Bell('initialize'); 
    end    
        
    Clock_Bell('UUU');
end
%--------------------------------------------------------------------------
if strcmp(action,'Undo') 
    UCoin=length(find(Clock==1));
    Clock(History(length(History)-1,1),History(length(History)-1,2))=5;
    set(UCoinHand(UCoin),'Xdata',UXpos(5*floor(UCoin/5)+mod(UCoin,5),:),'Ydata',UYpos(5*floor(UCoin/5)+mod(UCoin,5),:));
    
    CCoin=length(find(Clock==0));
    Clock(History(length(History),1),History(length(History),2))=5;    
    set(CCoinHand(CCoin),'Xdata',CXpos(5*floor(CCoin/5)+mod(CCoin,5),:),'Ydata',CYpos(5*floor(CCoin/5)+mod(CCoin,5),:));
    
    Count=Count-2;
    Clock_Bell_Board();
    if mod(turn,2)==0,
        Clock_Bell('UUU');
    end
    if mod(turn,2)==1,   
        Clock_Bell('CPU');
    end
end
%--------------------------------------------------------------------------
if strcmp(action,'New') 
    closereq;
    Clock_Bell('initialize');
end
%--------------------------------------------------------------------------
if strcmp(action,'Pause')
    set(PauseHand,'BackgroundColor',[1 0.6 0.3]);
    t1=clock;
    if ~waitforbuttonpress,  
        set(PauseHand,'BackgroundColor',[1 1 1]);        
    end        
    if mod(turn,2)==0, Uback=floor(etime(clock,t1));  end
    if mod(turn,2)==1, Cback=floor(etime(clock,t1));  end
end
%--------------------------------------------------------------------------
if strcmp(action,'Exit') 
    closereq;
end
%--------------------------------------------------------------------------
if strcmp(action,'1P'),     
    MultiP=0;
    P1C=[1 0.6 0.3];
    P2C=[1 1 1];
    closereq;
    Clock_Bell('initialize');
end
%--------------------------------------------------------------------------
if strcmp(action,'2P'),     
    MultiP=1;
    P2C=[1 0.6 0.3];
    P1C=[1 1 1];
    closereq;
    Clock_Bell('initialize');
end
%--------------------------------------------------------------------------
if strcmp(action,'Easy'),     
    Level=0;
    set(EasyHand,'BackgroundColor',[1 0.6 0.3]);
    set(HardHand,'BackgroundColor',[1 1 1]);
end
%--------------------------------------------------------------------------
if strcmp(action,'Hard'),     
    Level=1;
    set(HardHand,'BackgroundColor',[1 0.6 0.3]);
    set(EasyHand,'BackgroundColor',[1 1 1]);
end
%--------------------------------------------------------------------------
if strcmp(action,'win') 
    if UScore>CScore,
        msg=sprintf('Nice Play...%s WON the Game...',char(Player1));                       
    end
    if UScore<CScore,
        msg=sprintf('Nice Play...%s WON the Game...',char(Player2));         
    end
    if UScore==CScore,
        msg={'The Game is draw...'};
    end
    
    wavplay(wavread('Finish.wav'));
    
    %Storing n Displaying Top Scores
    TopScore(Player1,UScore,Utime,length(UMedal));
    if MultiP==1,
       TopScore(Player2,CScore,Ctime,length(CMedal)); 
    end    
    
    [namastedata namastemap]=imread('namaste.jpg');
    msg_handle=msgbox(msg,'Nice Game...!','custom',namastedata,namastemap);        
    if ~waitforbuttonpress,  close(msg_handle);  end
    
    PlayAgain='y';
    PlayAgain = inputdlg({'Want to Play Again???'},'PlayAgain',1,{PlayAgain});
    if strcmp(PlayAgain,'y'),
        Clock_Bell('initialize');
    else
        closereq;
    end    
    Clock_Bell('Exit');
end
%--------------------------------------------------------------------------
if strcmp(action,'Help')
    scrsz = get(0,'ScreenSize');
    Helpfig=figure( ...
                'Name','Help', 'NumberTitle','off', ...
                'Visible','off', 'BackingStore','off');
    figure(Helpfig);    
    if mod(fix(10*rand(1,1)),2)==0,
        image(imread('Help1.jpg'));
        set(Helpfig,'Position',[0.5 0.5 scrsz(3)/2 scrsz(4)/1.2]);
    else
        image(imread('Help2.jpg'));
        set(Helpfig,'Position',[0.5 0.5 scrsz(3)/3 scrsz(4)/1.2]);
    end        
    axis off
    msg=['DESCRIPTION:                                                                                              ';...
         '--> Inspired by the game "Rhumb Lines".                                                                   ';...
         '--> Place the coins in order to gain the medals or block opponents positions from gaining medals.         ';...
         '--> Place the coins only at the intersection of circular and radial lines (except at the center).         ';...
         '--> To get a medal you have to use 4 coins.                                                               ';...
         '--> SEQUENTIAL means 4 Coins in Radial, Arc or Spiral fashion in a consecutive manner.                    ';...
         '--> ALTERNATE means 4 Coins in Diametrical, Semi-Circular or Spiral fashion but in an alternative manner. ';...
         '--> At the end of specified time, the winner is decided upon:                                             ';...
         '    For Multi-player (2P) --> both Medals gained and Time of play (10 Points cut for every minute)        ';...
         '    For Single-player (1P) --> only Medals gained                                                         ';...
         '--> There is no hierarchy between the concentric circles in gaining points.                               ';...
         '--> 1P (default) is single player game playing against CPU. 2P is two individual players game.            ';...
         '--> Click "Easy" for 1P for easy level of play otherwise by default it is "Hard" level.                   ';...
         '--> The initial move is decided randomly and then it is an alternative players turn.                      ';...
         '--> The highlighted portion of player (either UUU (or) CPU) indicates the turn of the player.             ';...
         '--> Click "Pause" to pause the game and then directly select desired position to continue for further.    ';...
         '--> For every new medal that is gained, all the medals will be shown continuously highlighting each.      ';...
         '--> The orange color on the buttons is indication of selection either in terms of Level or # of Players.  ';...
         '--> For each players move, "Clock" numbers change which has nothing to do with the Game (it''s only GUI).  '];
   
    [helpdata helpmap]=imread('Help.jpg');
    MsgHand=msgbox(msg,'HELP','custom',helpdata,helpmap);
    set(MsgHand,'position',[scrsz(3)/4 scrsz(3)/4 scrsz(3)/2.5 scrsz(4)/2.75]);
    ChildHand= get(MsgHand,'children');
    set(findobj(ChildHand,'type','text'),'fontname','courier');
    set(ChildHand(3),'position',[225    7.0000   40.0000   17.0000]);
    HelpClose = waitforbuttonpress;
    if HelpClose==0,  close(Helpfig);  end
end
%--------------------------------------------------------------------------

Contact us at files@mathworks.com