home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1995 January / macformat-020.iso / Shareware City / Developers / ACL / Examples / ACL-World / Sources / Intro.cp < prev    next >
Encoding:
Text File  |  1994-10-01  |  4.2 KB  |  186 lines  |  [TEXT/MMCC]

  1.  
  2. /********************************************
  3.  **** ACL-World
  4.  ****
  5.  **** dialogs.cp
  6.  ****
  7.  **** Created:      24 August 1994
  8.  **** Modified:     30 August 1994
  9.  **** Version:      0
  10.  **** Compatible:   C++, Mac System 7
  11.  ****
  12.  **** Description:    Intro
  13.  ****
  14.  *******************/
  15.  
  16. #include "ACL-World.h"
  17.  
  18. //*************************************
  19.  
  20. static const short PICT_PERS         = 130;
  21. static const short PICT_SHOCKPERS     = 139;
  22.  
  23. static const short PICT_BACKGROUND     = 142;
  24. static const short PICT_BACKGROUND2    = 143;
  25.  
  26.  
  27. //*************************************
  28.  
  29. #define    TEXTSTEP1    "\pACL is an object-oriented animation framework which defines various kind of moveable and/or animated objects. The most important object is the Anim. You can see four simple Anim objects above."
  30.  
  31. #define    TEXTSTEP2    "\pACL uses an offscreen buffer that prevents display flickering. This is how your animation would look without an offscreen buffer."
  32.  
  33. #define    TEXTSTEP3    "\pWith an offscreen buffer there is no display flickering. To achieve the best speed results ACL will refresh only the parts that have been modified."
  34.  
  35. #define    TEXTSTEP4    "\pYou can add a background picture to your animation without suffering any loss in speed."
  36.  
  37. #define    TEXTSTEP5    "\pAn Anim Object is made out of several differents frames in sequence. In this example you can see an Anim object which has two different sequences. The first sequence has five frames and the second three."
  38.  
  39. #define    TEXTSTEP6    "\pAn Anim object can have as many sequences as needed and there is no limit to the number of frames that a sequence can own. At any time you can change the current sequence. Press the space bar of your keyboard."
  40.                          
  41.                     
  42. //*************************************
  43.  
  44. static AnimGfx    *background;
  45. static short    backwidth,backheight;
  46. static Anim        *anims[4];
  47.  
  48. //*************************************
  49.  
  50. Boolean ACLWorld::intro_advance(void)
  51. {
  52.     short     i;
  53.     Handle     ha;
  54.     Rect    rect;
  55.     
  56.     static short w,h;
  57.  
  58.     step++;
  59.     
  60.     GetDItem(dialog,1,&i,&ha,&rect);
  61.     
  62.     switch(step)
  63.     {
  64.         case 1:
  65.         SetIText(ha,TEXTSTEP1);
  66.         
  67.         for(i=0;i<4;i++) anims[i] = animbase->createanim(animpers);
  68.  
  69.         anims[0]->setsequence(1);
  70.         anims[1]->setsequence(1);
  71.  
  72.         anims[0]->place(10,10);
  73.         anims[1]->place(310,80);
  74.         anims[2]->place(180,24);
  75.         anims[3]->place(100,100);
  76.         return FALSE;
  77.  
  78.         case 2:
  79.         SetIText(ha,TEXTSTEP2);
  80.         animbase->removebuffer();        
  81.         return FALSE;
  82.  
  83.         case 3:
  84.         SetIText(ha,TEXTSTEP3);
  85.         animbase->buildbuffer(460,217);
  86.         for(i=0;i<3;i++) delete anims[i];
  87.         anims[0] = anims[3];
  88.         anims[0]->findmaxsize(&w,&h);
  89.         anims[0]->place((backwidth/2)-(w/2), 110);        
  90.         return FALSE;
  91.  
  92.         case 4:
  93.         SetIText(ha,TEXTSTEP4);
  94.         animbase->installbackground(background);        
  95.         return FALSE;
  96.  
  97.         case 5:
  98.         SetIText(ha,TEXTSTEP5);
  99.         animbase->installbackground(PICT_BACKGROUND2);
  100.         anims[1] = animbase->createanim(animpers);
  101.         anims[1]->setsequence(1);
  102.         anims[0]->place(372,6);
  103.         anims[1]->place(357,104);
  104.         return FALSE;
  105.  
  106.         case 6:
  107.         SetIText(ha,TEXTSTEP6);
  108.         animbase->removebackground();
  109.         delete anims[1];
  110.         anims[0]->findmaxsize(&w,&h);
  111.         anims[0]->place((backwidth/2)-(w/2), (backheight/2)-(h/2) );                
  112.         return FALSE;
  113.  
  114.     }
  115.     
  116.     
  117.     return TRUE;
  118. }
  119.  
  120.  
  121.  
  122. //*************************************
  123.  
  124. Boolean ACLWorld::do_intro(void)
  125. {
  126.     Point p;
  127.     char  key;
  128.     short res;
  129.     Boolean done = FALSE;
  130.  
  131.     pleasewait(TRUE);
  132.  
  133.     animbase = new AnimBase();
  134.     
  135.     background = animbase->newgfx(PICT_BACKGROUND);
  136.     animbase->newgfx(PICT_BACKGROUND2);
  137.  
  138.     animbase->preload_framedef(animpers);
  139.  
  140.     backwidth = background->getwidth();
  141.     backheight = background->getheight();
  142.         
  143.     animbase->buildbuffer(460,217);
  144.     animbase->setbasex(17);
  145.     animbase->setbasey(8);
  146.  
  147.  
  148.     pleasewait(FALSE);
  149.  
  150.     step = 0;
  151.     openbasedialog();
  152.     SetWTitle(dialog,"\pIntro");
  153.     intro_advance();
  154.  
  155.     
  156.     for(;;)
  157.     {
  158.         res = processbasedialog(key,p);
  159.         
  160.         if         (res==DO_QUIT) {done=TRUE; break;}
  161.         else if (res==DO_MENU) break;
  162.         else if (res==DO_CONTINUE && intro_advance()) break;
  163.         else if (res==DO_KEY && step==6 && key==' ')
  164.         {
  165.             if (anims[0]->getcurrentsequence()==0) 
  166.             {
  167.                 anims[0]->setsequence(1);
  168.                 anims[0]->move(-10,-10);
  169.             }
  170.             else 
  171.             {
  172.                 anims[0]->setsequence(0);
  173.                 anims[0]->move(10,10);
  174.             }
  175.         } 
  176.     }
  177.     
  178.     closebasedialog();
  179.     
  180.     delete animbase;
  181.  
  182.     return done;
  183. }
  184.  
  185. //*************************************
  186.