% Nom du fichier: WinkingEyes.sim % Description: Exemple d'animation d'yeux a l'aide de la % classe Simulation % Auteur: JPH % Date: Le 28 juillet 1997 % Version: 1.1 (conversion pour les pictures) % % Pour plus de details sur la classe SIMULATION, voir: % % URL: http://www.jsp/~dift1010/Simula/Simula.intro.html#s16 % Simulation BEGIN EXTERNAL CLASS WindowTools; EXTERNAL CLASS Unix; Process CLASS Eyes(X, Y); INTEGER X, Y; BEGIN PROCEDURE WinkIn; BEGIN INTEGER i; FOR I := 5 STEP -1 UNTIL 0 DO BEGIN TW.DrawPicture( LeftEye( Mod(i, 6) ), X, Y ); TW.DrawPicture( RightEye( Mod(i, 6) ), X+25, Y ); TW.Sleep(WinkTimeLapse); !Hold(WinkTimeLapse); END; END; PROCEDURE WinkOut; BEGIN INTEGER i; FOR I := 0 STEP 1 UNTIL 5 DO BEGIN TW.DrawPicture( LeftEye( Mod(i, 6) ), X, Y ); TW.DrawPicture( RightEye( Mod(i, 6) ), X+25, Y ); TW.Sleep(WinkTimeLapse); !Hold(WinkTimeLapse); END; END; INTEGER i; WHILE TRUE DO BEGIN WinkIn; Hold(WinkTimeLapse); WinkOut; Hold( Uniform(0.01, 1, U) ); END; END; MainWindow CLASS MyMainWindow; BEGIN REF(Button) Quit, NewPair; INTEGER i; TEXT PictDir; PROCEDURE ClickInButton(b); REF(button) B; BEGIN IF B == NewPair THEN ACTIVATE NEW Eyes(RandInt(0, TW.width-45, U), RandInt(0, TW.height-10, U)) ELSE IF B == Quit THEN ACTIVATE Main; END; PROCEDURE ActivateEyes; BEGIN ACTIVATE NEW Eyes(RandInt(0, TW.width-45, U), RandInt(0, TW.height-10, U)); ACTIVATE NEW Eyes(RandInt(0, TW.width-45, U), RandInt(0, TW.height-10, U)); ACTIVATE NEW Eyes(RandInt(0, TW.width-45, U), RandInt(0, TW.height-10, U)); END; PictDir :- Home_of("simula") & "/www/wt/Picture/WinkingEyes/"; FOR i := 0 STEP 1 UNTIL 5 DO BEGIN LeftEye(i) :- GetPicture(PictDir & "L" & int_as_text(i)&".xbm"); RightEye(i) :- GetPicture(PictDir & "R" & int_as_text(i)&".xbm"); END; SetSize(300, 300); Quit :- MakeButton("Quit").PlaceDownRight; NewPair :- MakeButton("More Eyes").PlaceLeftOf(Quit); Show; END; REF(Picture) ARRAY LeftEye(0:5), RightEye(0:5); REAL WinkTimeLapse = 0.02; BOOLEAN Finished; INTEGER U; REF(MyMainWindow) TW; u := ClockTime; TW :- NEW MyMainWindow("Main"); TW.ActivateEyes; Passivate; Outline("End of program..."); END;