% Script hideAndSeek
% Seeker looks through a window to spot a target hiding behind a wall.

% Set up the figure
close all % Close all previous figure windows
figure % Start a new figure window
hold on % Keep the same set of axes (multiple plots on same axes)
axis equal % unit lengths on x- and y-axis are equal
axis([-1 1 -1 1]) % x-axis limits [-1,1], y-axis limits [-1,1]

% Extent of window in wall
windowTop = 1/3;
windowBottom = -1/4;

% Draw the wall
plot([0 0], [windowTop, 1], 'k-')
plot([0 0], [windowBottom, -1], 'k-')

%%% Do not change the code above %%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% Modify the code below %%%%%%%%%%

% Target
xTarget = 0.5;
yTarget = 0.5;
plot(xTarget, yTarget, 'r+') % format Red cross

% User-clicked point
title('Click to the left of the window')
[xSeeker, ySeeker] = ginput(1);
plot(xSeeker, ySeeker, 'b*') % format Blue asterisk
messageToShow= sprintf('You clicked at (%.1f,%.1f)', xSeeker, ySeeker);
title(messageToShow)

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% Do not change the code below %%%

hold off