Advertisement
Guest User

Untitled

a guest
Mar 23rd, 2017
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.09 KB | None | 0 0
  1. var actor;
  2. actor = id;
  3.  
  4. if (argument_count > 0) {
  5. actor = argument_0;
  6. }
  7.  
  8. with (actor) {
  9.  
  10. var vBBox, vDir;
  11. vDir = sign(vspd);
  12.  
  13. if (vspd == 0) {
  14.  
  15. // Slope-Alignment
  16. // Check if a slope is below the player and if the distance is within our maximum allowed slope-height
  17. // and if it we move the player on top of the slope. This will make for smooth downwards-movement on slopes
  18.  
  19. var slopeCollision;
  20. slopeCollision = collision_line(bbox_left,bbox_bottom+global.maxSlopeHeight,bbox_right,bbox_bottom+global.maxSlopeHeight,parSlope,false,false);
  21.  
  22. if (slopeCollision != noone) {
  23.  
  24. // Continue with accurate / precise collision-detection
  25. var didPlaceOnTop;
  26. didPlaceOnTop = false;
  27.  
  28. var retries;
  29. retries = 1;
  30.  
  31. do {
  32.  
  33. slopeCollision = collision_line(bbox_left,bbox_bottom+1,bbox_right,bbox_bottom+1,parSlope,true,false);
  34.  
  35. if (slopeCollision == noone) {
  36. y+=1;
  37. }
  38. else {
  39. didPlaceOnTop = true;
  40. }
  41.  
  42. retries +=1;
  43. }
  44. until (didPlaceOnTop || retries > global.maxSlopeHeight);
  45. }
  46. }
  47. else {
  48.  
  49. repeat(abs(floor(vspd))) {
  50.  
  51. vBBox = noone;
  52.  
  53. if (vDir == -1) {
  54. vBBox = bbox_top;
  55. }
  56. else if (vDir == 1) {
  57. vBBox = bbox_bottom+1;
  58. }
  59.  
  60. var collision = collision_line(bbox_left,vBBox,bbox_right,vBBox,parBlock,true,false);
  61. var didCollide = false;
  62.  
  63. if (collision) {
  64.  
  65. if (collision.isSolid) {
  66.  
  67. // Check if landing on ground
  68. if (vDir == 1) {
  69. didLand = true;
  70. isOnGround = true;
  71.  
  72. if (jumpEffect) {
  73. instance_create_depth(x,y,depth-1,jumpEffect);
  74. }
  75. }
  76.  
  77. didCollide = true;
  78. vspd = 0;
  79. }
  80. else {
  81.  
  82. if (vDir == 1) {
  83.  
  84. if (collision.bbox_top == bbox_bottom+1) {
  85. didLand = true;
  86. isOnGround = true;
  87.  
  88. instance_create_depth(x,y,depth-1,objEffectLand);
  89. didCollide = true;
  90. }
  91. }
  92. }
  93. }
  94.  
  95. if (didCollide) {
  96. vspd = 0;
  97. }
  98. else {
  99. y += vDir;
  100. isOnGround = false;
  101. }
  102. }
  103. }
  104. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement