Advertisement
kevansevans

Untitled

Feb 11th, 2018
366
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.52 KB | None | 0 0
  1. package lr.rider.phys.anchors;
  2.  
  3. import openfl.utils.Object;
  4.  
  5. /**
  6. * ...
  7. * @author ...
  8. */
  9. class CPoint
  10. {
  11. public var lgrav:Object;
  12. public var x:Float;
  13. public var y:Float;
  14. public var vx:Float;
  15. public var vy:Float;
  16. public var dx:Float;
  17. public var dy:Float;
  18. public var nx:Float;
  19. public var ny:Float;
  20. public var fr:Float;
  21. public var ID:Int;
  22.  
  23. public var sx:Float;
  24. public var sy:Float;
  25. public var svx:Float;
  26. public var svy:Float;
  27. public var sdx:Float;
  28. public var sdy:Float;
  29.  
  30. public function new(_x:Float, _y:Float, _fr:Float, _id:Int)
  31. {
  32. this.x = _x;
  33. this.y = _y;
  34. this.dx = this.dy = 0;
  35. this.vx = this.vy = 0;
  36. this.fr = _fr;
  37. this.ID = _id;
  38. this.lgrav = new Object();
  39. this.lgrav.x = 0;
  40. this.lgrav.y = 0.175;
  41. }
  42. public function verlet(grav:Object) {
  43. this.dx = this.x - this.vx + grav.x;
  44. this.dy = this.y - this.vy + grav.y;
  45. this.vx = this.x;
  46. this.vy = this.y;
  47. this.x = this.x + this.dx;
  48. this.y = this.y + this.dy;
  49. this.lgrav = grav;
  50. this.get_n();
  51. }
  52. public function get_n()
  53. {
  54. var tdx = this.x - this.vx + lgrav.x;
  55. var tdy = this.y - this.vy + lgrav.y;
  56. this.nx = this.x + tdx;
  57. this.ny = this.y + tdy;
  58. }
  59. public function save() {
  60. this.sx = this.x;
  61. this.sy = this.y;
  62. this.svx = this.vx;
  63. this.svy = this.vy;
  64. this.sdx = this.dx;
  65. this.sdy = this.dy;
  66. }
  67. public function restore() {
  68. this.x = this.sx;
  69. this.y = this.sy;
  70. this.vx = this.svx;
  71. this.vy = this.svy;
  72. this.dx = this.sdx;
  73. this.dy = this.sdy;
  74. }
  75. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement