home *** CD-ROM | disk | FTP | other *** search
/ The CDPD Public Domain Collection for CDTV 3 / CDPDIII.bin / pd / commodities / superdark / blankers / line2.dark.c < prev    next >
C/C++ Source or Header  |  1993-03-10  |  3KB  |  161 lines

  1.  /* Fichier star.dark.c                */
  2. /* Module appele par le programme principal    */
  3. /* pour effectuer un effet defini..appele par    */
  4. /* loadseg                    */
  5.  
  6. #include <time.h>
  7. #include <math.h>
  8. #include <exec/types.h>
  9. #include <intuition/intuition.h>
  10. #include <intuition/gadgetclass.h>
  11. #include <graphics/gfx.h>
  12. #include <graphics/gfxbase.h>
  13. #include <graphics/gfxmacros.h>
  14. #include <graphics/rastport.h>
  15. #include <graphics/displayinfo.h>
  16. #include <clib/exec_protos.h>
  17. #include <clib/intuition_protos.h>
  18. #include "/includes/struct.h"
  19. #include "/includes/tom_gadget.h"
  20.  
  21. char    p_ver[]="$VER: Line2 v1.1 (28/02/93)";
  22.  
  23. char    *p_text_info="   Effect line\n\nJust show you lines moving\non your screen...\nYou can choose to add\nhorizontal or vertical\nsymetry\nV1.1 By Thomas Landspurg\n";
  24.  
  25. struct    RastPort    *rp;
  26. struct    Screen    *s;
  27.  
  28. #define    WIDTH    320
  29. #define    HEIGHT    256
  30.  
  31. #define    MAX_SPEED    20
  32. #define    MAX_NB    100
  33.  
  34. UWORD  ScreenColors[] = {
  35.     0x000,
  36.     0xF00,
  37.     0xF30,
  38.     0xF50,
  39.     0xF70,
  40.     0xF90,
  41.     0xFA0,
  42.     0xFB0,
  43.     0xFC0,
  44.     0xFD0,
  45.     0xFE0,
  46.     0xFF0,
  47.     0xBF0,
  48.     0x8F0,
  49.     0x7D0,
  50.     0x5B0,
  51.     0x000,
  52.     0x490,
  53.     0x340,
  54.     0x555,
  55.     0x777,
  56.     0x999,
  57.     0xBBB,
  58.     0xDDD,
  59.     0xEEE,
  60.     0xFFF,
  61.     0xFCC,
  62.     0xFAA,
  63.     0xF88,
  64.     0xF66,
  65.     0xF44,
  66.     0xF22,
  67.     0x000 };
  68.  
  69. struct NewScreen   Screen = {
  70.     0, 0, WIDTH,HEIGHT, 5,0,1,NULL,CUSTOMSCREEN,NULL,NULL,NULL,NULL};
  71.  
  72. struct tom_gadget my_gadg[]={
  73.     {"T_aille",SLIDER,    101,15,135,9,10, 10,MAX_NB-1,0,0},
  74.     {"_Speed",SLIDER,    101,28,135,9,10, 10,MAX_SPEED,0,0},
  75.     {"_Horizontal",CHECKBOX,272,39,135,9,0, 0,0,0,0},
  76.     {"_Vertical",CHECKBOX,    272,53,135,9,0, 0,0,0,0},
  77.         {0,        END_LISTE,  0,  0,   0, 0, 0,0,0,0,0}
  78. };
  79.  
  80. typedef    struct    pt{
  81.     int    x,y;
  82.     int    x2,y2;
  83. };
  84. struct    pt    tab_pt[MAX_NB];
  85. extern    struct    GfxBase    *GfxBase;
  86.  
  87. void    Aff_line(rp,n)
  88. struct    RastPort    *rp;
  89. int    n;
  90. {
  91.     Move(rp,160+tab_pt[n].x,128+tab_pt[n].y);
  92.     Draw(rp,160+tab_pt[n].x2,128+tab_pt[n].y2);
  93.  
  94.     if(my_gadg[3].value){
  95.         Move(rp,160-tab_pt[n].x,128+tab_pt[n].y);
  96.         Draw(rp,160-tab_pt[n].x2,128+tab_pt[n].y2);
  97.         if(my_gadg[2].value){
  98.             Move(rp,160-tab_pt[n].x,128-tab_pt[n].y);
  99.             Draw(rp,160-tab_pt[n].x2,128-tab_pt[n].y2);
  100.         }
  101.     }
  102.     if(my_gadg[2].value){
  103.         Move(rp,160+tab_pt[n].x,128-tab_pt[n].y);
  104.         Draw(rp,160+tab_pt[n].x2,128-tab_pt[n].y2);
  105.     }
  106. }
  107.  
  108. void    dark()
  109. {
  110.     int    d,i,n;
  111.  
  112.     if ( s = OpenScreen(&Screen)){
  113.  
  114.     FreeSprite (0);
  115.     GfxBase->SpriteReserved|=1;
  116.     rp = &(s->RastPort);
  117.     d=1<<(s->BitMap.Depth);
  118.     LoadRGB4(&s->ViewPort,ScreenColors,32);
  119.     SetRast(rp,0);
  120.  
  121.     for(n=0;n<my_gadg[0].value;n++){
  122.         tab_pt[n].x=0;
  123.         tab_pt[n].y=0;
  124.         tab_pt[n].x2=0;
  125.         tab_pt[n].y2=0;
  126.     }
  127.     n=0;
  128.     i=n;
  129.  
  130.     while(tst_end()==FALSE){
  131.         i=(i+my_gadg[1].value)%6400;
  132.         SetAPen(rp,0);
  133.         Aff_line(rp,n);
  134.  
  135.         tab_pt[n].x=(int)(159*sin(2*i*2*PI/6400));
  136.         tab_pt[n].y=(int)(127*cos(3*i*2*PI/6400));
  137.         tab_pt[n].x2=(int)(120*sin(5*i*2*PI/6400));
  138.         tab_pt[n].y2=(int)(108*cos(7*i*2*PI/6400));
  139.  
  140.         SetAPen(rp,(i/my_gadg[1].value)%31+1);
  141.         Aff_line(rp,n);
  142.  
  143.         n=(n+1)%my_gadg[0].value;
  144.     
  145.     }
  146.    CloseScreen(s);
  147.    }
  148.  
  149. }
  150.  
  151. void    proc_init()
  152. {
  153. }
  154. void    proc_save()
  155. {
  156. }
  157. void    proc_end()
  158. {
  159. }
  160.  
  161.