home *** CD-ROM | disk | FTP | other *** search
/ Enter 1999 April - Disc 1 / enter_04_1999_1.iso / OS2 / OSMULTI / ANIME.C < prev    next >
Encoding:
C/C++ Source or Header  |  1998-12-09  |  3.6 KB  |  185 lines

  1. /*
  2.  * anime.c - animate multi
  3.  */
  4.  
  5. #include <stdio.h>
  6. #include <stdlib.h>
  7.  
  8. #define INCL_PM
  9. #include <os2.h>
  10.  
  11. #include "shapewin.h"
  12.  
  13. #include "osmulti2.h"
  14. #include "osmulres.h"
  15.  
  16. /*
  17.  * Animation Modes
  18.  */
  19.  
  20. #define ANIME_NORM  0
  21. #define ANIME_URUR  1
  22. #define ANIME_OHNO  2
  23. #define ANIME_PSYU  3
  24.  
  25. static  int     modeAnime = ANIME_NORM ;
  26.  
  27. /*
  28.  * timers for each modes - UNIT of mili-seconds
  29.  */
  30.  
  31. static  int     ururInit =   8000 ;
  32. static  int     ururTime =      0 ;
  33. static  int     ohnoInit =   8000 ;
  34. static  int     ohnoTime =      0 ;
  35. static  int     psyuInit =  16000 ;
  36. static  int     psyuTime =      0 ;
  37. static  int     psyuClear = 10000 ;
  38.  
  39. /*
  40.  * counters controls PSYU/BLINK
  41.  */
  42.  
  43. static  int     funiLimit = 20 ;    /* Win : 25, X : 40 */
  44. static  int     funiCount =  0 ;
  45.  
  46. static  ULONG   blinkCount = 0 ;
  47.  
  48. #define BLINKCYCLE1     20
  49. #define BLINKCYCLE2     24
  50.  
  51. /*
  52.  * animeNade - action 'nadenade'
  53.  */
  54.  
  55. static  int     nadeReduce = 0 ;
  56.  
  57. void    animeNade(void)
  58. {
  59.     if (modeAnime == ANIME_PSYU) {
  60.         return ;
  61.     }
  62.     if (nadeReduce > 0) {
  63.         nadeReduce -= 1 ;
  64.     return ;
  65.     }
  66.  
  67.     balloonNade() ;
  68.  
  69.     if (modeAnime != ANIME_URUR) {
  70.         bitmapDrawBody(hbmMulUru1) ;
  71.         modeAnime = ANIME_URUR ;
  72.     }
  73.     ururTime = ururInit ;
  74.     nadeReduce = 3 ;
  75. }
  76.  
  77. /*
  78.  * animeFuni - action 'funifuni'
  79.  */
  80.  
  81. void    animeFuni(void)
  82. {
  83.     if (modeAnime == ANIME_PSYU) {
  84.         return ;
  85.     }
  86.     if (modeAnime == ANIME_OHNO) {
  87.         if ((funiCount += 1) > funiLimit) {
  88.         balloonPsyu() ;
  89.         funiCount = 0 ;
  90.             bitmapDrawBody(hbmMulPsyu) ;
  91.             modeAnime = ANIME_PSYU ;
  92.         psyuTime = psyuInit    ;
  93.         return ;
  94.     }
  95.     }
  96.  
  97.     balloonFuni() ;
  98.  
  99.     if (modeAnime != ANIME_OHNO) {
  100.         bitmapDrawBody(hbmMulOhno) ;
  101.     modeAnime = ANIME_OHNO ;
  102.     funiCount += 1 ;
  103.     }
  104.     ohnoTime = ohnoInit ;
  105. }
  106.  
  107. /*
  108.  * animeTimer - timer processing
  109.  */
  110.  
  111. void    animeTimer(void)
  112. {
  113.     HBITMAP hbm = NULLHANDLE ;
  114.     ULONG   blink1, blink2   ;
  115.     BOOL    body = FALSE ;
  116.     BOOL    face = FALSE ;
  117.     
  118.     blink1 = blinkCount % BLINKCYCLE1 ;
  119.     blink2 = blinkCount % BLINKCYCLE2 ;
  120.     blinkCount += 1 ;
  121.  
  122.     TRACE("animeTimer mode %d, count %d (%d, %d)\n",
  123.                         modeAnime, blinkCount, blink1, blink2) ;
  124.  
  125.     switch (modeAnime) {
  126.     
  127.     case ANIME_NORM :
  128.     if (blink1 == 0 || blink2 == 0) {
  129.         hbm = hbmMulClos ;
  130.         face = TRUE ;
  131.     } else if (blink1 == 1 || blink2 == 1) {
  132.         hbm = hbmMulNorm ;
  133.         face = TRUE ;
  134.     }
  135.     break ;
  136.         
  137.     case ANIME_URUR :
  138.         if ((ururTime -= TIMER_MS) < 0) {
  139.         balloonClear() ;
  140.         modeAnime = ANIME_NORM ;
  141.         hbm = hbmMulNorm ;
  142.         body = TRUE ;
  143.     } else if ((blinkCount & 0x01) == 0) {
  144.         hbm = hbmMulUru1 ;
  145.         face = TRUE ;
  146.         } else {
  147.         hbm = hbmMulUru2 ;
  148.         face = TRUE ;
  149.         }
  150.     break ;
  151.     
  152.     case ANIME_OHNO :
  153.         if ((ohnoTime -= TIMER_MS) < 0) {
  154.         balloonClear() ;
  155.         modeAnime = ANIME_NORM ;
  156.         hbm = hbmMulNorm ;
  157.         body = TRUE ;
  158.     } else if (blink1 == 0 || blink2 == 0) {
  159.         hbm = hbmMulPsyu ;
  160.         face = TRUE ;
  161.     } else if (blink1 == 1 || blink2 == 1) {
  162.         hbm = hbmMulOhno ;
  163.         face = TRUE ;
  164.     }
  165.     break ;
  166.     
  167.     case ANIME_PSYU :
  168.         if ((psyuTime -= TIMER_MS) < 0) {
  169.         modeAnime = ANIME_NORM ;
  170.         hbm = hbmMulNorm ;
  171.         body = TRUE ;
  172.         }
  173.     if (psyuTime < psyuClear) {
  174.         balloonClear() ;
  175.     }
  176.     break ;
  177.     }
  178.     
  179.     if (body && hbm != NULLHANDLE) {
  180.         bitmapDrawBody(hbm) ;
  181.     } else if (face && hbm != NULLHANDLE) {
  182.         bitmapDrawFace(hbm) ;
  183.     }
  184. }
  185.