BulbNormalMapDrawSpriteExt.gml 946 B

1234567891011121314151617181920212223242526
  1. // Feather disable all
  2. /// @param sprite
  3. /// @param image
  4. /// @param x
  5. /// @param y
  6. /// @param xScale
  7. /// @param yScale
  8. /// @param angle
  9. function BulbNormalMapDrawSpriteExt(_sprite, _image, _x, _y, _xScale, _yScale, _angle)
  10. {
  11. var _color = ((frac(_angle/360)*256*256*64) << 2)
  12. | (((1000000*_xScale) >> 63) & 0x1)
  13. | (((1000000*_yScale) >> 62) & 0x2);
  14. //The upper 22 bits in the 24-bit color are used to enough the rotation angle.
  15. //
  16. //We pack whether the xscale any yscale are negative into the two lowest significant bits of
  17. //the red component of the color. We do this with a binary hack for extra speed.
  18. //
  19. //The multiplication by 1,000,000 is to ensure that scales less than 1 don't get rounded to
  20. //0 when converted to an integer (which happens implicitly by the left shift operator).
  21. draw_sprite_ext(_sprite, _image, _x, _y, _xScale, _yScale, _angle, _color, 1);
  22. }