kemonologic

draw_sprite_tiled_area

Dec 1st, 2019
285
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /// @func draw_sprite_tiled_area
  2. /// @arg {sprite} sprite
  3. /// @arg {real} subimg
  4. /// @arg {real} x1
  5. /// @arg {real} y2
  6. /// @arg {real} x2
  7. /// @arg {real} y2
  8. /// @arg {color*} col
  9. /// @arg {real*} alpha
  10. /// @desc Fills a rectangular area with the given sprite, tiled.
  11.  
  12. var _sprite = argument[0],
  13.      _subimg = argument[1],
  14.      _x1 = argument[2],
  15.      _y1 = argument[3],
  16.      _x2 = argument[4],
  17.      _y2 = argument[5],
  18.      _col = c_white,
  19.      _alpha = 1;
  20.      
  21. if (argument_count > 6){
  22.      _col = argument[6];
  23. }
  24. if (argument_count > 7){
  25.      _alpha = argument[7];
  26. }
  27.      
  28. var _sprW = sprite_get_width(_sprite);
  29. var _sprH = sprite_get_height(_sprite);
  30.  
  31. for (var _y = _y1; _y < _y2; _y += _sprH){
  32.     for (var _x = _x1; _x < _x2; _x += _sprW){
  33.         var _w = min(_sprW, _x2 - _x);
  34.         var _h = min(_sprH, _y2 - _y);
  35.         draw_sprite_part_ext(_sprite,_subimg,0,0,_w,_h,_x,_y,1,1,_col,_alpha);
  36.     }
  37. }
Add Comment
Please, Sign In to add comment