Advertisement
Guest User

Untitled

a guest
Apr 22nd, 2019
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.67 KB | None | 0 0
  1. //Get the absolute of DY
  2. r = abs(dy);
  3.  
  4. /*VERTICAL MOVEMENT*/
  5. while r > 0
  6. {
  7. //Get whether we are moving left or right, and store the sign in tx.
  8. if r >= 1 { ty = sign(dy); }
  9. //Also handle fractional values of r.
  10. else { ty = frac(dy); }
  11.  
  12. col = instance_place(x,y+ty,platforming_obj);
  13.  
  14. //If we do not encounter a collision, or that collision is not viable,
  15. // simply move the ourselves.
  16. if col == noone or (!p_solid or !col.p_solid)
  17. or (col.p_jumpthrough and bbox_bottom >= col.bbox_top)
  18. or (p_jumpthrough and col.bbox_bottom > bbox_top)
  19. {
  20.  
  21. y += ty;
  22.  
  23. }
  24. else
  25. {
  26. //If the object is pushable and we can push objects ourselves
  27. if p_push and col.p_pushable
  28. {
  29. //Move the object so we can see if it viabally collides with something.
  30. col.y += ty+sign(dy);
  31. with col { other.p_push_col = instance_place(x,y,platforming_obj); }
  32.  
  33. //If it doesn't, then move ourselves.
  34. if p_push_col == noone or p_push_col == id or !p_push_col.p_solid or (p_push_col.p_jumpthrough and dy < 0) {y += ty; }
  35. else
  36. {
  37. var colmask = -1+sign(dy);
  38. if col.mask_index != -1 colmask = col.mask_index else colmask = col.sprite_index;
  39.  
  40. col.y -= ty+sign(dy);
  41. dy = 0;
  42.  
  43. var cols = col.image_yscale;
  44. var s = image_yscale;
  45.  
  46. //make sure we and the pushed object are flat against the colliding object.
  47. if col.bbox_top > p_push_col.bbox_bottom
  48. {
  49. col.y = p_push_col.bbox_bottom+(sprite_get_yoffset(colmask)*cols)-(sprite_get_bbox_top(colmask)*cols)+s;
  50. }
  51. else if col.bbox_bottom < p_push_col.bbox_top
  52. {
  53. col.y = p_push_col.bbox_top-(sprite_get_yoffset(colmask)*cols)+((sprite_get_height(colmask)*cols)-(sprite_get_bbox_bottom(colmask)*cols))-cols;
  54. }
  55.  
  56.  
  57. if bbox_top > col.bbox_bottom
  58. {
  59. y = col.bbox_bottom+(sprite_get_yoffset(mask)*s)-(sprite_get_bbox_top(mask)*s)+s;
  60. }
  61. else if bbox_bottom < col.bbox_top
  62. {
  63. y = col.bbox_top-(sprite_get_yoffset(mask)*s)+((sprite_get_height(mask)*s)-(sprite_get_bbox_bottom(mask)*s))-s;
  64. }
  65.  
  66. //Stop our horizontal speed, and exit the loop.
  67. //p_vspd = 0;
  68. break;
  69. }
  70. }
  71. else
  72. {
  73. var s = image_yscale;
  74.  
  75. //Else, stop ourselves.
  76. //Round our x depending what side of the object we are on
  77. /*if bbox_top > col.bbox_bottom y = floor(y);
  78. else if bbox_bottom < col.bbox_top y = ceil(y);*/
  79. if !(p_pushable and col.p_push)
  80. {
  81. if bbox_top > col.bbox_bottom
  82. {
  83. y = col.bbox_bottom+(sprite_get_yoffset(mask)*s)-(sprite_get_bbox_top(mask)*s)+s;
  84. }
  85. else if bbox_bottom < col.bbox_top
  86. {
  87. y = col.bbox_top-(sprite_get_yoffset(mask)*s)+((sprite_get_height(mask)*s)-(sprite_get_bbox_bottom(mask)*s))-s;
  88. }
  89. }
  90.  
  91. if col != p_ground and col.p_vspd >= 0
  92. {
  93. p_vspd = 0;
  94. }
  95.  
  96. break;
  97. }
  98. }
  99.  
  100. r--;
  101. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement