Game-Matlab

Read Complete Research Material

GAME-MATLAB

Online Game-Matlab [Name of the Programmer]

Matlab Project 1

Guess the Number Game

Game Instructions

Open the file guesssing_game_gui.m using matlab.

Press the green button on the top of the editor window to start the execution of code.

you will be prompted to the game GUI(Graphical User Interface).

Press the button start over.

You will be shown the number of attempts remaining in the text box.

Enter the number in the box and click you have eight chances.

If you are able to guess the correct number you will unlock the moderate level.

Same rules do unlock the third level.

In case you are unable to guess the number after eight tries the game will over and you will lost!

When you want to exit from the game window press the exit button below. The GUI will prompt you to matlab workspace asking are you sure?

Reply with yes to quit the game.

Reply with Andrew to know the sequence of answer. It is sort of a cheat to impress your friend by guessing the correct number.

Code

function varargout = guessing_game_gui(varargin)

% GUESSING_GAME_GUI MATLAB code for guessing_game_gui.fig

% GUESSING_GAME_GUI, by itself, creates a new GUESSING_GAME_GUI or raises the existing

% singleton*.

%

% H = GUESSING_GAME_GUI returns the handle to a new GUESSING_GAME_GUI or the handle to

% the existing singleton*.

%

% GUESSING_GAME_GUI('CALLBACK',hObject,eventData,handles,...) calls the local

% function named CALLBACK in GUESSING_GAME_GUI.M with the given input arguments.

%

% GUESSING_GAME_GUI('Property','Value',...) creates a new GUESSING_GAME_GUI or raises the

% existing singleton*. Starting from the left, property value pairs are

% applied to the GUI before guessing_game_gui_OpeningFcn gets called. An

% unrecognized property name or invalid value makes property application

% stop. All inputs are passed to guessing_game_gui_OpeningFcn via varargin.

%

% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one

% instance to run (singleton)".

%

% See also: GUIDE, GUIDATA, GUIHANDLES



% Edit the above text to modify the response to help guessing_game_gui



% Last Modified by GUIDE v2.5 25-Nov-2012 07:39:03



% Begin initialization code - DO NOT EDIT

gui_Singleton = 1;

gui_State = struct('gui_Name', mfilename, ...

'gui_Singleton', gui_Singleton, ...

'gui_OpeningFcn', @guessing_game_gui_OpeningFcn, ...

'gui_OutputFcn', @guessing_game_gui_OutputFcn, ...

'gui_LayoutFcn', [] , ...

'gui_Callback', []);

if nargin && ischar(varargin{1})

gui_State.gui_Callback = str2func(varargin{1});

end



if nargout

[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});

else

gui_mainfcn(gui_State, varargin{:});

end

% End initialization code - DO NOT EDIT

end



% --- Executes just before guessing_game_gui is made visible.

function guessing_game_gui_OpeningFcn(hObject, eventdata, handles, varargin)

% This function has no output args, see OutputFcn.

% hObject handle to figure

% eventdata reserved - to be defined in a future version of MATLAB

% handles structure with handles and user data (see GUIDATA)

% varargin command line arguments to guessing_game_gui (see VARARGIN)



% Choose default command line output for guessing_game_gui



handles.output = hObject;

value=round(100.*rand(1,1));

handles.value=value;

beginner_count=8;

moderate_count=7;

hard_count=5;

handles.beginner_count=beginner_count;

handles.moderate_count=moderate_count;

handles.hard_count=hard_count;

set(handles.moderate_find,'Visible','off');

set(handles.moderate_attempts,'Visible','off');

set(handles.moderate_result,'Visible','off');

set(handles.moderate_text,'Visible','off');

set(handles.moderate_input,'Visible','off');

set(handles.moderate_attempts_input,'Visible','off');



set(handles.hard_find,'Visible','off');

set(handles.hard_attempts,'Visible','off');

set(handles.hard_result,'Visible','off');

set(handles.hard_text,'Visible','off');

set(handles.hard_input,'Visible','off');

set(handles.hard_attempts_input,'Visible','off');

Image1= imread('Numbers.jpg');

imshow(Image1,'Parent', handles.axes3);

% Update handles structure

guidata(hObject, handles);



% UIWAIT makes guessing_game_gui wait for user response (see UIRESUME)

% uiwait(handles.figure1);

end



% --- Outputs from this function are returned to the command line.

function varargout = guessing_game_gui_OutputFcn(hObject, eventdata, handles)

% varargout cell array for returning output args (see VARARGOUT);

% hObject handle to figure

% eventdata reserved - to be defined in a future version of MATLAB

% handles structure with handles and user data (see GUIDATA)



% Get default command line output from handles structure

varargout{1} = ...