clear; clc; x=[-2.5 2.5 5 2.5 -2.5 -5]; y=[(5*sqrt(3))/2 (5*sqrt(3))/2 0 (-5*sqrt(3))/2 (-5*sqrt(3))/2 0]; % x1=[5 6 7]; % y1=[5 3 8]; fig1=figure; set(fig1,'Color','g','Position',[100 100 500 500]) plot(x,y,'ks','MarkerSize',12,'MarkerFaceColor','k'); axis([-6 6 -6 6]); axis off text(-2.8,5.2,'\bf 1','fontsize',16) text(2.2,5.2,'\bf 2','fontsize',16) text(5.3,0,'\bf 3','fontsize',16) text(2.2,-5.2,' \bf4','fontsize',16) text(-2.8,-5.2,' \bf5','fontsize',16) text(-5.8,0,'\bf 6','fontsize',16) grid on; hold on; FirstPlayerLines=[]; SecondPlayerLines=[]; while 1 % if triangle disp('First player to draw a line') a1=input('player 1, first point '); a2=input('player 1, second point '); FirstPlayerLines=[FirstPlayerLines; a1 a2]; plot([x(a1) x(a2)],[y(a1) y(a2)],'Color','r','LineWidth',3); waitforbuttonpress FirstPlayerLines disp('Second player to draw a line') b1=input('player 2, first point '); b2=input('player 2, second point '); SecondPlayerLines=[SecondPlayerLines; b1 b2]; plot([x(b1) x(b2)],[y(b1) y(b2)],'Color','b','LineWidth',3); waitforbuttonpress end