MichelVGameMaker

Untitled

Sep 4th, 2020
762
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.75 KB | None | 0 0
  1. ------------------------------------------------------------------------------------------------------------------
  2. /// @function notifications_process_system()
  3. /// @description update notifications every step
  4.  
  5. // Loop through notificationss
  6. var _y_target = y_notification;
  7.  
  8. var _size = ds_list_size(notifications_list);
  9. for (var i = 0; i < _size; i++)
  10. {
  11. var _notifications = notifications_list[| i];
  12.  
  13. // Move this notifications
  14. _y_target = _y_target - _new_notification[? "height"];
  15. _notifications[? "y"] = lerp(_notifications[? "y"], _y_target, 0.25);
  16. _notifications[? "timer"]-= 1 + i * 2;
  17. // Handle this notifications's exit
  18. if ( _notifications[? "timer"] <= 0 )
  19. {
  20. _notifications[? "alpha"] -= 0.05;
  21. if ( _notifications[? "alpha"] < 0.1 )
  22. {
  23.  
  24. // Destroy this notifications
  25. ds_list_delete(notifications_list, i);
  26. ds_map_destroy(_notifications);
  27.  
  28. // Adjust iteration
  29. --i;
  30. --_size;
  31. }
  32. }
  33. }
  34. ------------------------------------------------------------------------------------------------------------------
  35. ///@function notifications_add_item(text, timer)
  36. /// @description add a message to the list of notifications
  37. /// @param text
  38. /// @param timer
  39.  
  40. var _text = argument[0];
  41. if ( argument_count > 1 ) _timer = argument[1];
  42. else _timer = 240;
  43.  
  44. var _height = string_height_ext(_text, -1, _notifications_width);
  45.  
  46.  
  47. with ( NOTIFICATOR )
  48. {
  49. var _new_notification = ds_map_create();
  50. _new_notification[? "text"] = _text;
  51. _new_notification[? "height"] = _height;
  52. _new_notification[? "y"] = notifications_y + _height;
  53. _new_notification[? "alpha"] = 1;
  54. _new_notification[? "timer"] = _timer;
  55.  
  56. ds_list_insert(notifications_list, 0, _new_notification);
  57. }
  58.  
Advertisement
Add Comment
Please, Sign In to add comment