clc
clear all
close all
x2=randi([0,10],1,1);
y2=randi([0,10],1,1);
fprintf("This game has a grid of 10x10 where x and y can vary between 0 and 10 in which you need to guess the exact location\n\n");
dp=20;
while(1)
x1=input("Enter guess of yours for x coordinate: ");
y1=input("Enter guess of yours for y coordinate: ");
d=sqrt((x2-x1)^2+(y2-y1)^2);
if(x2==x1&&y2==y1)
disp("Congratulations you cleared");
break;
end
if(dp>d)
disp("you;re getting closer");
else
disp("you;re getting further away");
end
dp=d;
end
Comments
Leave a comment