Code covered by the BSD License  

Highlights from
Cribbage Suite

image thumbnail
from Cribbage Suite by Bryan
Cribbage Suite is a GUI interface designed to help teach and play the game of cribbage.

cribScoreBoard.m
% cribScoreBoard.m

newGame; %Run the script file

S = figure; %Open a new figure.

set(S,...
    'Menubar','none',...
    'NumberTitle','off',...
    'Name','Cribbage Scoreboard',...
    'Position',[413   813   400   115]);

SmenuFile = uimenu('Label','&File');
    SmenuFile0 = uimenu('Parent',SmenuFile,'Label','Mode');
        SmenuFile01 = uimenu('Parent',SmenuFile0,'Label','Score my hand','Callback','choose4');
        SmenuFile02 = uimenu('Parent',SmenuFile0,'Label','Which 4 cards should I pick?','Callback','choose6');
    SmenuFile1 = uimenu('Parent',SmenuFile,'Label','&Help','Callback','cribHelpGui');
    SmenuFile2 = uimenu('Parent',SmenuFile,'Label','&Close','Callback','close gcf');
    
%% Player 1 (left side of GUI)
Splayer1 = uipanel(...
    'Position',[0 0 0.5 1],...
    'Title',get(player1,'name'),...'
    'Parent',S,...
    'FontWeight','bold');

Splayer1Text1 = uicontrol(...
    'Style','text',...
    'Parent',Splayer1,...
    'String','Previous Score:',...
    'Position',[5 35 80 10],...
    'HorizontalAlignment','left');
Splayer1PrevScore = uicontrol(...
    'Style','text',...
    'Parent',Splayer1,...
    'String',num2str(get(player1,'prevScore')),...
    'Position',[95 35 20 10]);

Splayer1Text2 = uicontrol(...
    'Style','text',...
    'Parent',Splayer1,...
    'String','Just Added:',...
    'Position',[5 20 80 10],...
    'HorizontalAlignment','left');
Splayer1JustAdded = uicontrol(...
    'Style','text',...
    'Parent',Splayer1,...
    'String',num2str(get(player1,'toAdd')),...
    'Position',[95 20 20 10]);

Splayer1Text3 = uicontrol(...
    'Style','text',...
    'Parent',Splayer1,...
    'String','Current Score:',...
    'Position', [5 5 90 10],...
    'HorizontalAlignment','left',...
    'FontWeight','bold');

Splayer1Score =uicontrol(...
    'Parent',Splayer1,...
    'Style','text',...
    'Position',[95 5 20 10],...
    'String', num2str(get(player1,'score')),...
    'FontWeight','bold');

Splayer1Input = uicontrol(...
    'Style','edit',...
    'Position',[5 50 100 25],...
    'String',num2str(1),...
    'Parent',Splayer1);

Splayer1Add = uicontrol(...
    'Style','pushbutton',...
    'String','Add',...
    'Position',[115 50 80 45],...
    'Callback','addPoints1',...
    'Parent',Splayer1,...
    'FontWeight','bold');

Splayer1Undo = uicontrol(...
    'Style','pushbutton',...
    'String','Oops!',...
    'Position',[155 5 40 25],...
    'Callback','undo1',...
    'Parent',Splayer1);

%% Player 2 (right side of GUI)
Splayer2 = uipanel(...
    'Position',[0.5 0 .5 1],...
    'Title',get(player2,'name'),...
    'Parent',S,...
    'FontWeight','bold');

Splayer2Text1 = uicontrol(...
    'Style','text',...
    'Parent',Splayer2,...
    'String','Previous Score:',...
    'Position',[5 35 90 10],...
    'HorizontalAlignment','left');
Splayer2PrevScore = uicontrol(...
    'Style','text',...
    'Parent',Splayer2,...
    'String',num2str(get(player2,'prevScore')),...
    'Position',[95 35 20 10]);

Splayer2Text2 = uicontrol(...
    'Style','text',...
    'Parent',Splayer2,...
    'String','Just Added:',...
    'Position',[5 20 95 10],...
    'HorizontalAlignment','left');
Splayer2JustAdded = uicontrol(...
    'Style','text',...
    'Parent',Splayer2,...
    'String',num2str(get(player2,'toAdd')),...
    'Position',[95 20 20 10]);

Splayer1Text3 = uicontrol(...
    'Parent',Splayer2,...
    'String','Current Score:',...
    'Position',[5 5 90 10],...
    'Style','text',...
    'HorizontalAlignment','left',...
    'FontWeight','bold');
Splayer2Score =uicontrol(...
    'Parent',Splayer2,...
    'Style','text',...
    'Position',[95 5 20 10],...
    'String', num2str(get(player2,'score')),...
    'Parent',Splayer2,...
    'FontWeight','bold');

Splayer2Input = uicontrol(...
    'Style','edit',...
    'Position',[5 50 100 25],...
    'String',num2str(1),...
    'Parent',Splayer2);

Splayer2Add = uicontrol(...
    'Style','pushbutton',...
    'Parent',Splayer2,...
    'String','Add',...
    'Position',[115 50 80 45],...
    'Callback','addPoints2',...
    'FontWeight','bold');

Splayer2Undo = uicontrol(...
    'Style','pushbutton',...
    'String','Oops!',...
    'Position',[155 5 40 25],...
    'Callback','undo2',...
    'Parent',Splayer2);

Contact us at files@mathworks.com