image thumbnail
from Turning Locker by Krishna Lalith
Turn the Dials to 0000.

Locker(action)
function Locker(action)

global fig lhands LockerKey;
clc
%--------------------------------------------------------------------------
if nargin < 1,     
    fig=figure('Name','Game : Locker','NumberTitle','off','units','centimeters',...
               'Visible','off', 'BackingStore','off','position',[7 7 6 5]);

    %assigning the positions of Locks;
    for ii=1:4,   
        LockerKey(ii)=mod(fix(1000*rand(1,1)),10);
        cdata=imread([int2str(LockerKey(ii)),'.tif']);
        lhands(ii)=uicontrol('style','pushbutton','units','centimeters',...
                            'position',[ii 2 0.8 2],...
                            'callback',{@board,ii},'cdata',cdata); 
    end  
     
    figure(fig); 
    axis square;
    axis equal;   
    axis off;
    
    %creating default buttons
    uicontrol('units','centimeters','position',[1.0 1.0 0.8 0.6],...
                'string','New','callback','Locker(''New'')',...
                'interruptible','on','BackgroundColor','w');
            
    uicontrol('units','centimeters','position',[2.0 1.0 0.8 0.6],...
                'string','Intro','callback','Locker(''Intro'')',...
                'interruptible','on','BackgroundColor','w'); 
            
    uicontrol('units','centimeters','position',[3.0 1.0 0.8 0.6],...
                'string','Soln','callback','Locker(''Soln'')',...
                'interruptible','on','BackgroundColor','w');
            
    uicontrol('units','centimeters','position',[4.0 1.0 0.8 0.6],...
                'string','Exit','callback','delete(gcf)',...
                'interruptible','on','BackgroundColor','w');
            
    action='Intro';
end
%--------------------------------------------------------------------------
if strcmp(action,'Intro'),    
    msg={'Description of Game:                                          ',...
         '                                                              ',...
         'Objective: Turning the Dials to 0000.                         ',...
         '                                                              ',...
         'Move: Clicking on a Dial will Rotate its state to next number.',...
         '                                                              ',...
         'NOTE: Each Dial is connected to its adjacent Dials.           ',...
         '      Each Dial is a Circular Dial.                             '};
     
    msgbox(msg,'Locker Game : Intro','help');
end
%--------------------------------------------------------------------------
if strcmp(action,'Soln'),    
    msg={'Xi = 0 - initial value dial i (i = 1,2,3,4)    ',...
         '                                               ',... 
         '       Dial#1   Dial#2   Dial#3   Dial#4       ',...
         'Fix dial 1        X1        -      -X1       X1',...
         'Fix dial 2         -        -       X2      -X2',...
         'Fix dial 3       -X3       X3        -        -',...
         'Fix dial 4        X4      -X4        -       X4',...
         '-----------------------------------------------',...
         '            X1-X3+X4    X3-X4   -X1+X2 X1-X2+X4'};
     
    msgbox(msg,'Locker Game Solution','help');
end
%--------------------------------------------------------------------------
if strcmp(action,'New'),    
    for ii=1:4,   
        LockerKey(ii)=mod(fix(1000*rand(1,1)),10);
        cdata=imread([int2str(LockerKey(ii)),'.tif']);
        lhands(ii)=uicontrol('style','pushbutton','units','centimeters',...
                            'position',[ii 2 0.8 2],...
                            'callback',{@board,ii},'cdata',cdata); 
    end
end
%--------------------------------------------------------------------------

Contact us