scr_toolset.gml 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. // Les actifs du script ont changé pour v2.3.0 Voir
  2. // https://help.yoyogames.com/hc/en-us/articles/360005277377 pour plus d’informations
  3. // @function array_loop();
  4. /// @param {Array} _arr The array to move into
  5. /// @param {real} _curr The current variable
  6. /// @param {real} _add Moving how many
  7. /// @description Move and loop into the different variables of an array
  8. function array_loop(_arr, _curr, _add){
  9. _curr += _add
  10. if (_curr >= array_length(_arr))
  11. {
  12. _curr = 0;
  13. }
  14. if (_curr < 0)
  15. {
  16. _curr = array_length(_arr) - 1;
  17. }
  18. return _curr
  19. }
  20. // @function progressbar();
  21. /// @param {real} _curr Current value
  22. /// @param {real} _max Max value
  23. /// @param {real} _width Max width (in pixels) of bar
  24. /// @description Draw current width of a progress bar
  25. function progressbar(_curr, _max, _width){
  26. return (_width / _max) * _curr
  27. }
  28. // @function draw_rect();
  29. /// @param {real} _x x pos
  30. /// @param {real} _y y pos
  31. /// @param {real} _width rect width
  32. /// @param {real} _height rect height
  33. /// @param {boolean} _outline With outline?
  34. /// @description Draw a rectangle from width and height
  35. function draw_rect(_x, _y, _width, _height, _outline){
  36. var _x2 = (_x + _width);
  37. var _y2 = (_y + _height);
  38. draw_rectangle(_x, _y, _x2, _y2, _outline);
  39. }
  40. // @function draw_rect_inset();
  41. /// @param {real} _x x pos
  42. /// @param {real} _y y pos
  43. /// @param {real} _width rect width
  44. /// @param {real} _height rect height
  45. /// @param {real} _inset how much of inset
  46. /// @description Draw a rectangle from width and height (and opt. inset)
  47. function draw_rect_inset(_x, _y, _width, _height, _inset = 0){
  48. var _x1 = _x + _inset;
  49. var _x2 = (_x + _width) - _inset;
  50. var _y1 = _y + _inset;
  51. var _y2 = (_y + _height) - _inset;
  52. draw_rectangle(_x1, _y1, _x2, _y2, false);
  53. }