home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1997 January / macformat46.iso / Shareware Plus / Developers / Library / NGL 2.0 Demo / NGL2.0.0(E)Demo / Button Sample / Button_Sample(PPC).c < prev   
Encoding:
C/C++ Source or Header  |  1996-10-03  |  2.7 KB  |  85 lines

  1. /*============================================================
  2.  
  3.                     N_Button sample program
  4.                     
  5. ============================================================*/
  6. #include        "N_Library.h"
  7.  
  8. short        Data_Rsrc = 0;
  9. short        Snd_List0[]     = {1000,1001,0};                                        
  10. long            counter1         = 2000;                                                
  11. long            counter2         = 2000;
  12. long            counter3         = 2000;
  13.  
  14. void main(void)
  15. {
  16.     WindowPtr    window;
  17.     short        bt;
  18.  
  19.     ToolboxInit();
  20.     ColorCheck();
  21.     HideMenuBar();
  22.     window = GetNewWindow (128,nil,(WindowPtr)-1L );
  23.     N_Window_Set(window,-(window->portBits.bounds.left),-(window->portBits.bounds.top),640,480);
  24.     Open_Resource_File(128,1,&Data_Rsrc);
  25.     N_Sp_Make(640,480);                                                        
  26.     N_Cel_Make(50000);                                                        
  27.     N_Pict_Draw(128,0,0,(GrafPtr)SP_off,true);
  28.     N_Button_Init();                                                        
  29.     N_Font_Init();
  30.     N_Sprite_Set(129,0,14,24,1,11,1,0);                                            
  31.     N_Sprite_Set(130,11,32,32,1,6,1,0);                                            
  32.     N_Sprite_Set(131,20,12,16,0,1,1,0);                                            
  33.     N_Sound_Load(&Snd_List0[0]);                                                    
  34.     N_Font_Set(0,0,0,0,0);                                                        
  35.     Close_Resource_File(&Data_Rsrc);
  36.  
  37.     N_Button_Set(0,0,1,40,410,0,0x80000000+11,0x80000000+12,1000,1001);        
  38.     N_Button_Set(0,1,1,80,410,0,0x80000000+13,0x80000000+14,1000,1001);
  39.     N_Button_Set(0,2,1,160,410,40,0x80000000+11,0x80000000+12,1000,1001);        
  40.     N_Button_Set(0,3,1,200,410,40,0x80000000+13,0x80000000+14,1000,1001);
  41.     N_Button_Set(0,4,1,280,410,512,0x80000000+11,0x80000000+12,1000,1001);        
  42.     N_Button_Set(0,5,1,320,410,512,0x80000000+13,0x80000000+14,1000,1001);
  43.     N_Button_Set(0,6,1,410,410,513,0x80000000+15,0x80000000+16,1000,1001);        
  44.     N_Button_Set(0,7,1,470,410,514,0x80000000+15,0x80000000+16,1000,1001);
  45.     N_Button_Set(0,8,1,562,410,512,0x80000000+15,0x80000000+16,1000,1001);        
  46.     N_Button_Put(0);
  47.     N_Num_Put(counter1,30,320,5,16,0,2,0);                                        
  48.     N_Num_Put(counter2,150,320,5,16,0,2,0);
  49.     N_Num_Put(counter3,270,320,5,16,0,2,0);
  50.     N_Cel_Loop(0,0);
  51.     
  52.     do
  53.     {
  54.         GetMouse(&mp);
  55.         N_Cel_Put(2040,0x80000000+20,mp.h,mp.v);
  56.         bt = N_Button_Check(0);
  57.         if (bt == 1) counter1++;                                                    
  58.         if (bt == 3) counter2++;
  59.         if (bt == 5) counter3++;
  60.         if (counter1 == 10000) counter1 = 0;                                        
  61.         if (counter2 == 10000) counter2 = 0;
  62.         if (counter3 == 10000) counter3 = 0;
  63.         if (bt == 0) counter1--;                                                    
  64.         if (bt == 2) counter2--;
  65.         if (bt == 4) counter3--;
  66.         if (counter1 == -1) counter1 = 9999;                                        
  67.         if (counter2 == -1) counter2 = 9999;
  68.         if (counter3 == -1) counter3 = 9999;
  69.         if(bt != -1)                                                            
  70.         {
  71.             N_Num_Put(counter1,30,320,5,16,0,2,0);                                
  72.             N_Num_Put(counter2,150,320,5,16,0,2,0);
  73.             N_Num_Put(counter3,270,320,5,16,0,2,0);
  74.         }
  75.         N_Cel_Loop(0,0);
  76.     }
  77.     while (bt != 8);                                                                
  78.     N_Sound_Close();                                                            
  79.     FlushEvents( everyEvent, 0 ); 
  80.     ShowMenuBar();
  81.     ShowCursor();
  82.     ColorRevert();
  83. }
  84.  
  85.