Advertisement
GTA5HelpDesk

Untitled

Feb 9th, 2024
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.44 KB | None | 0 0
  1. using LemonUI.Elements;
  2. using System.Windows.Forms;
  3. using System;
  4. using System.Drawing;
  5. using GTA;
  6. using GTA.Math;
  7.  
  8. namespace LemonUI.Menu1
  9. {
  10. public class YourScript : Script
  11. {
  12. ScaledRectangle rectangle;
  13. const int slidingDuration = 3000;
  14. bool isSlidingRight = true;
  15. int slidingStartTick;
  16. int startingPosition;
  17.  
  18. public YourScript()
  19. {
  20. Tick += OnTick;
  21. KeyDown += OnKeyDown;
  22.  
  23. rectangle = new ScaledRectangle(new PointF(10, 10), new SizeF(100, 200));
  24. startingPosition = (int)rectangle.Position.X;
  25. }
  26.  
  27. private float lerp(float a, float b, float t)
  28. {
  29. return a + (b - a) * t;
  30. }
  31.  
  32. private void OnTick(object sender, EventArgs e)
  33. {
  34. float progress = (Game.GameTime - slidingStartTick) / slidingDuration;
  35. float xPosition = lerp(startingPosition, isSlidingRight ? 10 : -200, progress);
  36. rectangle.Position = new PointF(xPosition, 10);
  37.  
  38. if (progress >= 1.0f)
  39. {
  40. //isAnimating = false;
  41. }
  42. }
  43.  
  44. private void OnKeyDown(object sender, KeyEventArgs e)
  45. {
  46. if (e.KeyCode == Keys.Y)
  47. {
  48. slidingStartTick = Game.GameTime;
  49. startingPosition = (int)rectangle.Position.X;
  50. }
  51. }
  52. }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement