function gentil % % Two stupid games where you have to close an opened window % if you have time to waste % % Sorry for that % jeu = 0; while(jeu~=1 & jeu~=2) disp('Voulez vous jouer à attrape-mi attrape-moi (1)') jeu = input('ou préférez vous le jeu du tonneau (2) :'); end a = msgbox('Je suis une gentille fenêtre de Gilou : Attrapez-Moi'); pause(.5) set(a,'units','normalized') pos = get(a,'Position'); c = get(a,'children'); set(c(2),'String','Ici') set(c(2),'Callback','close(gcf)') set(c(2),'Interruptible','off') N = 32; n = 1; e = 1; if jeu == 2 while (ishandle(a)) xa = cos(2*pi*(0:N-1)/N)/4; ya = sin(2*pi*(0:N-1)/N)/4; n = rem(n,N)+1; posa = [ .5+xa(n) .5-ya(n) pos(3) pos(4) ]; set(a,'position',posa) pause(.1) end end if jeu == 1 set(0,'units','normalized') mpos = get(0,'PointerLocation'); while(ishandle(a)) if norm(pos(1:2)-mpos) <=.2 pos = [ max(rand-pos(3),0) max(rand-pos(4),0) pos(3) pos(4) ]; set(a,'position',pos) end mpos = get(0,'PointerLocation'); pause(.2) end end