home *** CD-ROM | disk | FTP | other *** search
/ GEMini Atari / GEMini_Atari_CD-ROM_Walnut_Creek_December_1993.iso / files / gnu / gchsrc31 / atarilib / easyspri.cc < prev    next >
C/C++ Source or Header  |  1992-04-27  |  2KB  |  58 lines

  1. //////////////////////////////////////////////////////////////////////////////
  2. //
  3. //  This file is part of the Atari Machine Specific Library,
  4. //  and is Copyright 1992 by Warwick W. Allison.
  5. //
  6. //  You are free to copy and modify these sources, provided you acknoledge
  7. //  the origin by retaining this notice, and adhere to the conditions
  8. //  described in the file COPYING.
  9. //
  10. //////////////////////////////////////////////////////////////////////////////
  11.  
  12. #include <EasySprite.h>
  13.  
  14. Incarnation* GetIncarnation(Screen& S,int x,int y,int h,int attr)
  15. {
  16.     Incarnation* Result;
  17.  
  18.     if (attr&SP_COLOUR) {
  19.         if (attr&SP_WIDE) Result=new WideColourIncarnation(h);
  20.         else if (attr&SP_FAST) Result=new PreshiftedColourIncarnation(h);
  21.         else Result=new ColourIncarnation(h);
  22.     } else {
  23.         if (attr&SP_WIDE) Result=new WideMonochromeIncarnation(h);
  24.         else if (attr&SP_FAST) Result=new PreshiftedMonochromeIncarnation(h);
  25.         else Result=new MonochromeIncarnation(h);
  26.     }
  27.  
  28.     Result->GetImage(S,x,y);
  29.  
  30.     if (attr&SP_HOTCENTRE) Result->SetHotSpot(Result->Width()/2,Result->Height()/2);
  31.  
  32.     return Result;
  33. }
  34.  
  35. Sprite* GetSprite(Screen& S,int x,int y,int h,int attr,int n=1,int dx=16,int dy=0)
  36. {
  37.     Sprite* Result=new Sprite(n);
  38.     for (int i=0; i<n; i++) {
  39.         Result->SetImage(i,GetIncarnation(S,x,y,h,attr));
  40.         x+=dx;
  41.         y+=dy;
  42.     }
  43.  
  44.     return Result;
  45. }
  46.  
  47. Sprite* GetMobileSprite(Screen& S,int x,int y,int h,int attr,int n=1,int dx=16,int dy=0)
  48. {
  49.     Sprite* Result=new MobileSprite(n);
  50.     for (int i=0; i<n; i++) {
  51.         Result->SetImage(i,GetIncarnation(S,x,y,h,attr));
  52.         x+=dx;
  53.         y+=dy;
  54.     }
  55.  
  56.     return Result;
  57. }
  58.