Code covered by the BSD License  

Highlights from
Boggle (V2.0)

image thumbnail

Boggle (V2.0)

by

 

08 Aug 2011 (Updated )

The traditional Boggle Master Game from Hasbro

gridImage(G,rot)
function I = gridImage(G,rot)
%Function to return an image corresponding to the letter grid
%SCd 08/03/2011
%
%Inputs: 
%   -G: grid of letters from makeGrid
%   -rot: logical, rotation.  If true letters can rotate.
%
%Outputs:
%   -I: image of grid
%
%See Also: makeGrid
%

    %Blank Image, load letter images, find corresponding letters
    I = false(512); %preallocate 100x100 letters with 2 layer of black
    the_letters = importdata('the_letters.mat');
    letter_vec = 'A':'Z';
    
    %rotations?
    if rot
        angles = [0 90 180 270];
        rotfun = @(x)imrotate(x,angles(ceil(rand*4)),'nearest','crop');
    else
        rotfun = @(x)x;
    end
        
    %Engine
    row = 0;
    for ii = 3:102:510
        row = row+1;
        col = 0;
        for jj = 3:102:510
            col = col+1;
            I(ii:ii+99,jj:jj+99) = rotfun(the_letters(:,:,G(row,col)==letter_vec));
        end
    end

end

Contact us