home *** CD-ROM | disk | FTP | other *** search
/ Nebula 1995 August / NEBULA.mdf / Apps / Games / How / How_1.5 / Source / How.m < prev    next >
Encoding:
Text File  |  1994-05-07  |  9.1 KB  |  394 lines

  1.  
  2. /* Generated by Interface Builder */
  3. /* Modified by Eric Tremblay April 18 , 1992 */
  4. /* Updated May 8, 1994 */
  5.  
  6. #import "How.h"
  7. #import <appkit/Button.h> /* Needed to change the image in an Icon */
  8.  
  9. @implementation How
  10.  
  11.       int TOTAL = 0;
  12.       int i; /* dummy variable */
  13.       int X; /* X screen coordinate */
  14.       int Y; /* Y screen  coordinate */
  15.  
  16. - init
  17. {
  18.    [super init];
  19.    return self;
  20.  }
  21.  
  22. - StartHow:sender
  23. /* This is used by the menu item How */
  24. {
  25.      [Result close]; /* close the Result panel */
  26.      [Select orderFront:sender]; /* Selection panel "Let's start" */
  27.      return self;
  28. }
  29.  
  30.  
  31. - Chosen:sender
  32. /* This is for the button is the Select panel
  33.  * once the user has chosen a number
  34.  * he will click on this button
  35.  */
  36. {
  37.     TOTAL =0;
  38.     
  39.  
  40. /* Drop Select window at the bottom of the screen. */
  41.      
  42.       X= 247;
  43.       Y= 177;
  44.  
  45.       [Select makeKeyWindow]; /* Selects the window */
  46.       [Select orderFront:sender]; /* Places the window in front */
  47.         
  48.       for (i = Y; i > -435; i=i-10) {
  49.             [Select moveTo:(X):(i)];
  50.         }
  51.       
  52.       [Select close]; /* Closes the window (Even if theres no close button on the window) */
  53.       [Select moveTo:(247):(177)]; /* re-position the Select panel at original XY on the screen */
  54.       
  55. /* end of Drop Select panel */
  56.     
  57.     [CardOne orderFront:sender]; /* display CardOne panel */
  58.     return self;
  59. }
  60.  
  61. - OneYes:sender
  62. /* CardOne answer yes */
  63. {
  64.     [self DropCardOne:sender]; /* Drop the card method */
  65.     TOTAL=TOTAL + 1;
  66.     [CardTwo orderFront:sender];
  67.     return self;
  68. }
  69.  
  70. - OneNo:sender
  71. /* CardOne answer no */
  72. {
  73.     [self DropCardOne:sender]; /* Drop the card method */
  74.     [CardTwo orderFront:sender];
  75.     return self;
  76. }
  77.  
  78. -DropCardOne:sender
  79. /* drop CardOne */
  80. {
  81. /* Drop CardOne window at the bottom of the screen. */
  82.      
  83.       X= 260;
  84.       Y= 329;
  85.  
  86.       [CardOne makeKeyWindow]; /* Selects the window */
  87.       [CardOne orderFront:sender]; /* Places the window in front */
  88.         
  89.       for (i = X; i > -440; i=i-10) {
  90.             [CardOne moveTo:(i):(Y)];}
  91. /* Move window to the left */
  92.        
  93.       
  94.       [CardOne close]; /* Closes the window (Even if theres no close button on the window) */
  95.       [CardOne moveTo:(311):(350)]; /* re-position the Select panel at original XY on the screen */
  96.       
  97. /* end of Drop CardOne panel */
  98.  
  99.        return self;
  100. }
  101.  
  102. - TwoYes:sender
  103. /* CardTwo answer yes */
  104. {
  105.     [self DropCardTwo:sender]; /* Drop the card method */
  106.     TOTAL=TOTAL + 2;
  107.     [CardThree orderFront:sender];
  108.     return self;
  109. }
  110.  
  111. - TwoNo:sender
  112. /* CardTwo answer no */
  113. {
  114.     [self DropCardTwo:sender]; /* Drop the card method */
  115.     [CardThree orderFront:sender];
  116.     return self;
  117. }
  118.  
  119. -DropCardTwo:sender
  120. /* drop CardTwo */
  121. {
  122. /* Drop CardTwo window at the bottom of the screen. */
  123.      
  124.       X= 260;
  125.       Y= 319;
  126.  
  127.       [CardTwo makeKeyWindow]; /* Selects the window */
  128.       [CardTwo orderFront:sender]; /* Places the window in front */
  129.         
  130.        for (i = Y; i > -435; i=i-15) {
  131.             [CardTwo moveTo:(X):(i)];}
  132. /* Move window down */
  133.        
  134.  
  135.         Y = -435; /* window is at buttom of screen */
  136.         for (i = Y; i <700; i=i+9) {
  137.             [CardTwo moveTo:(X):(i)];}
  138. /* Move window upwards */
  139.        
  140.   
  141.         for (i = X; i > -440; i=i-10) {
  142.             [CardTwo moveTo:(i):(700)];}
  143.  /* Move window to the left 
  144. */
  145.     
  146.       [CardTwo close]; /* Closes the window (Even if theres no close button on the window) */
  147.       [CardTwo moveTo:(260):(319)]; /* re-position the Select panel at original XY on the screen */
  148.       
  149. /* end of Drop CardTwo panel */
  150.  
  151.        return self;
  152. }
  153.  
  154. - ThreeYes:sender
  155. /* CardThree answer yes */
  156. {
  157.     [self DropCardThree:sender]; /* Drop the card method */
  158.     TOTAL=TOTAL + 4;
  159.     [CardFour orderFront:sender];
  160.     return self;
  161. }
  162.  
  163. - ThreeNo:sender
  164. /* CardOne answer no */
  165. {
  166.     [self DropCardThree:sender]; /* Drop the card method */
  167.     [CardFour orderFront:sender];
  168.     return self;
  169. }
  170.  
  171. -DropCardThree:sender
  172. /* drop CardThree */
  173. {
  174. /* Drop CardThree window at the bottom of the screen. */
  175.      
  176.       X= 260;
  177.       Y= 319;
  178.  
  179.       [CardThree makeKeyWindow]; /* Selects the window */
  180.       [CardThree orderFront:sender]; /* Places the window in front */
  181.         
  182.       for (i = X; i < 1300; i=i+20) {
  183.             [CardThree moveTo:(i):(Y)];} /* move window to the right */
  184.         
  185.       
  186.      [CardThree close];  /* Closes the window (Even if theres no close button on the window) */
  187.      [CardThree moveTo:(260):(319)]; /* re-position the Select panel at original XY on the screen */
  188.       
  189. /* end of Drop CardThree panel */
  190.  
  191.        return self;
  192. }
  193.  
  194.  
  195. - FourYes:sender
  196. /* CardFour answer yes */
  197. {
  198.     [self DropCardFour:sender]; /* Drop the card method */
  199.     TOTAL=TOTAL + 8;
  200.     [self WhichImage:sender];
  201.     return self;
  202. }
  203.  
  204. - FourNo:sender
  205. /* CardFour answer no */
  206. {
  207.     [self DropCardFour:sender]; /* Drop the card method */
  208.     [self WhichImage:sender];
  209.     return self;
  210. }
  211.  
  212. -DropCardFour:sender
  213. /* drop CardFour */
  214. {
  215. /* Drop CardFour window at the bottom of the screen. */
  216.      
  217.       X= 260;
  218.       Y= 319;
  219.  
  220.       [CardFour makeKeyWindow]; /* Selects the window */
  221.       [CardFour orderFront:sender]; /* Places the window in front */
  222.         
  223.       for (i = Y; i > -435; i=i-10) 
  224.       {
  225.  [CardFour moveTo:(X):(i)];  /* move window down */
  226.          [CardFour moveTo:(X=X-10):(i)]; }
  227.  /* Move window to the left 
  228. */
  229.         
  230.             
  231.          [CardFour close]; /* Closes the window (Even if theres no close button on the window) */
  232.          [CardFour moveTo:(260):(319)]; /* re-position the Select panel at original XY on the screen */
  233.       
  234. /* end of Drop CardFour panel */
  235.  
  236.        return self;
  237. }
  238.  
  239.  
  240.  
  241. - WhichImage:sender
  242. /* assigns the number total with the proper image */
  243. {
  244.      
  245.       X= 370;
  246.       Y= 330;
  247.  
  248.       [Result makeKeyWindow]; /* Selects the window */
  249.       [Result orderFront:sender]; /* Places the window in front */
  250.         
  251.        [ResultImage setIcon:"Wizard.tiff"];
  252.        
  253.       for (i = Y; i > 4; i=i-10) {
  254.             [Result moveTo:(X):(i)];
  255. } /* moves window down */
  256.     
  257.        [ResultImage setIcon:"Safe.tiff"];
  258.        
  259.       for (i = X; i > 5; i=i-10) {
  260.             [Result moveTo:(i):(4)];}
  261.  /* Move window to the left 
  262. */
  263.  
  264.     [self ResultAnimation:sender];
  265.  
  266.      for (i = 5; i < 370; i=i+10) {
  267.             [Result moveTo:(i):(4)];} /* move window to the right */
  268.  
  269.       Y = 4; /* window is at buttom of screen */
  270.       for (i = Y; i <330; i=i+10) {
  271.             [Result moveTo:(370):(i)];}
  272. /* Move window upwards */
  273.  
  274.      
  275.    switch (TOTAL)  { /* start switch */
  276.    
  277.    case 1:
  278.           [ResultImage setIcon:"Wizard.tiff"];
  279.       break;
  280.       
  281.    case 2:
  282.           [ResultImage setIcon:"Dino.tiff"];
  283.           break;
  284.       
  285.    case 3:
  286.            [ResultImage setIcon:"Karate.tiff"];
  287.         break;
  288.  
  289.    case 4:
  290.            [ResultImage setIcon:"Light.tiff"];
  291.         break;
  292.  
  293.    case 5:
  294.            [ResultImage setIcon:"Safe.tiff"];
  295.         break;
  296.  
  297.    case 6:
  298.            [ResultImage setIcon:"PC.tiff"];
  299.         break;
  300.  
  301.    case 7:
  302.            [ResultImage setIcon:"Moto.tiff"];
  303.         break;
  304.  
  305.    case 8:
  306.            [ResultImage setIcon:"Boat.tiff"];
  307.         break;
  308.  
  309.    case 9:
  310.            [ResultImage setIcon:"Flag.tiff"];
  311.         break;
  312.  
  313.    case 10:
  314.            [ResultImage setIcon:"Cow.tiff"];
  315.         break;
  316.  
  317.    case 11:
  318.            [ResultImage setIcon:"Ghost.tiff"];
  319.         break;
  320.  
  321.    case 12:
  322.            [ResultImage setIcon:"Jolly.tiff"];
  323.         break;
  324.  
  325.    case 13:
  326.            [ResultImage setIcon:"Porshe.tiff"];
  327.         break;
  328.  
  329.    case 14:
  330.            [ResultImage setIcon:"Juptier.tiff"];
  331.         break;
  332.  
  333.    case 15:
  334.            [ResultImage setIcon:"Elvis.tiff"];
  335.         break;
  336.  
  337.    default:
  338.            [ResultImage setIcon:"MindLess.tiff"]; /* if the user does not answer properly */
  339.        break;
  340.  
  341.                             } /* end switch */
  342.  
  343.     
  344.     
  345.     
  346.     return self;
  347. }
  348.  
  349.  
  350. - ResultButton:sender
  351. /* Secret button in the result panel */
  352. {
  353.           if (TOTAL == 1) /* Wizard selected, display the MoreInfo panel */
  354.       [MoreInfo orderFront:sender];
  355.       
  356.       
  357.       if (TOTAL == 15) /* Elvis select, do the result animation one more time. */
  358.       [self WhichImage:sender];
  359.       
  360.       return self;
  361. }
  362.  
  363. - ResultAnimation:sender
  364. /* This is the amimation for the Result panel */
  365. {
  366.  
  367.        [ResultImage setIcon:"Dino.tiff"];
  368.   
  369.         Y = 4; /* window is at buttom of screen */
  370.         for (i = Y; i <620; i=i+10) {
  371.             [Result moveTo:(5):(i)];}
  372. /* Move window upwards */
  373.      
  374.        [ResultImage setIcon:"Jolly.tiff"];
  375.  
  376.         for (i = 5; i < 770; i=i+10) {
  377.             [Result moveTo:(i):(620)];} /* move window to the right */
  378.  
  379.        [ResultImage setIcon:"Porshe.tiff"];
  380.     
  381.         Y=620; /* window is at the top of the screen */
  382.         for (i = Y; i > 4; i=i-10) {
  383.             [Result moveTo:(770):(i)];
  384. } /* moves window down */
  385.  
  386.         [ResultImage setIcon:"Wizard.tiff"];
  387.     
  388.         for (i = 770; i > 5; i=i-10) {
  389.             [Result moveTo:(i):(4)];}
  390.  /* Move window to the left 
  391. */
  392.       
  393.         [ResultImage setIcon:"Boat.tiff"];
  394.     
  395.          return self;
  396. }
  397.   
  398.  
  399.  
  400. - closeInfo:sender
  401. /* This method closes the Info panel and opens and displays the MoreInfo panel */
  402. {
  403.       [Info performClose:sender]; /* This closes the Info panel */
  404.       [MoreInfo orderFront:sender]; /* This displays the MoreInfo panel */
  405.       return self; /* End of closeInfo method */
  406.  }
  407.  
  408.  
  409. @end
  410.