njDrawSprite2D | Japanese
    --|INDEX|->
Draws 2D sprite

### FORMAT

      #include  <Ninja.h>
      void   njDrawSprite2D( *sp, n, pri, attr )
      NJS_SPRITE  *sp
      Int         n
      Float       pri
      Uint32      attr

### PARAMETERS

*sp
  Pointer for Sprite structure
n
  Sprite number
pri
  Priority
attr
  Attribute

### RETURN VALUE

  None

### ERROR VALUE

  None

### FUNCTION

- Draws 2D sprite.
- Sprite can draw textures and its animations simply.
- Priority sets the Z value.
- Back is minus direction and its range is -1.0 thru -65535.0.
- The followings can be set as attribute:

  NJD_SPRITE_ANGLE | Validate texture rotation
  NJD_SPRITE_COLOR | Validate texture color operation The value set to njSetConstantMaterial() is used as color data
  NJD_SPRITE_HFLIP | Reverse texture horizontally (L<->R)
  NJD_SPRITE_VFLIP | Reverse texture vertically (Up<->Down)
  NJD_SPRITE_HVFLIP | Reverse texture horizontally and vertically.
  NJD_SPRITE_ALPHA | Set if translucent is used.

  ## Sprite sructure

      typedef struct {
        NJS_POINT3  p;       /* point            */
        NJS_VECTOR  v;       /* normal           */
        Float       sx,sy;   /* scale            */
        Angle       ang;     /* angle            */
        NJS_TEXLIST *tlist;  /* texture list     */
        NJS_TEXANIM *tanim;  /* animation list   */
      } NJS_SPRITE;

  p
    sets drawing point.
    p.x and p.y : set screen coordinate (upper left origin).
  v
    is not valid in the current version.
  sx,sy
    specify the magnifying rate in H and V.
  ang
    sets the rotate angle.
    It is valid only when NJD_SPRITE_ANGLE is set.
  tlist
    sets texture list of all textures used for Sprite.
    The texture list must be loaded by njLoadTexture() beforehand.
  tanim
    sets texture animation patterns.
    The order of this structure accommodates texture numbers.

  ## Texture animation structure

      typedef struct {
        Sint16      sx,sy;   /* size             */
        Sint16      cx,cy;   /* center           */
        Sint16      u1,v1;   /* tex1             */
        Sint16      u2,v2;   /* tex2             */
        Sint16      texid;   /* texture id       */
        Sint16      attr;    /* attribute        */
      } NJS_TEXANIM;

  sy,sy
    specify sprite size (irrelevant to texture size)
  cx,cy
    set the center coordinate for the texture.
    specify by relative point from upper left.
    This point corresponds to drawing point and the center of rotation.
  u1,v1
    set texture upper-left UV coordinate.
    0 - 255 must be specified irrelevant with texture size.
  u2,v2
    set texture bottom-right UV coordinate.
    0 - 255 must be specified irrelevant with texture size.
  texid
    specify which texture within the list is used.
  attr
    invalid at the current version.

### EXAMPLE

  Use two 256x256 textures.
  Divide each texture into four patterns and make 8 texture animation patterns.

      NJS_TEXANIM  anim[] = {
        { 128,128, 64, 64,  0,  0,127,127,  0, 0 },
        { 128,128, 64, 64,128,  0,255,127,  0, 0 },
        { 128,128, 64, 64,  0,128,127,255,  0, 0 },
        { 128,128, 64, 64,128,128,255,255,  0, 0 },
        { 128,128, 64, 64,  0,  0,127,127,  1, 0 },
        { 128,128, 64, 64,128,  0,255,127,  1, 0 },
        { 128,128, 64, 64,  0,128,127,255,  1, 0 },
        { 128,128, 64, 64,128,128,255,255,  1, 0 },
      };

      main() {
        NJS_SPRITE  sprite;

               :
        Initial settings
               :

        sprite.tlist = &texlist;
        sprite.tanim = anim;
        sprite.ang = 0x4000;
        sprite.sx = 1.0f;
        sprite.sy = 1.0f;
        sprite.p.x = 320.0f;
        sprite.p.y = 240.0f;

        njLoadTexture( &texlist );
        njDrawSprite2D( &sprite, 2, -150.f, NJD_SPRITE_ANGLE );

          ......

      }

### NOTES

### RELATED TOPICS

  njDrawSprite3D()
  njSetConstantMaterial()
  njLoadTexture()

njDrawSprite2D |
    --|INDEX|->