Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.87 KB | None | 0 0
  1. /* Platform Collapse code port from Sonic MAX Engine. (With Permission) */
  2.  
  3. timer = 1;
  4. height = (ceil(sprite_height/block_height)*block_height);
  5. blockheight2 = block_height-(height-sprite_height);
  6.  
  7. if(image_xscale == -1){
  8. for(i=block_width;i<=abs(sprite_width);i+=block_width;)
  9. {
  10. for(i2=height-block_height;i2>=0;i2-=block_height;)
  11. {
  12.  
  13. ins = instance_create(x-abs(sprite_width)+i, (y-sprite_yoffset)+i2, par_collapsing_terrain_tiles);
  14. with(ins)
  15. {
  16.  
  17. /* Get _x/_y Position: */
  18. _x = abs(other.sprite_width)-other.i;
  19. _y = other.i2;
  20. _solid = true;
  21. _w = other.block_width;
  22.  
  23. if(other.i2 == other.height-other.block_height)
  24. {
  25. _h = other.blockheight2;
  26. };
  27. else
  28. {
  29. _h = other.block_height;
  30. };
  31.  
  32. sprite_index = other.sprite_index;
  33. image_xscale = other.image_xscale;
  34.  
  35. /* Set Gravitation and Speed: */
  36. _gravity = 0;
  37. _speed = 0;
  38. _gravity_active = false;
  39.  
  40. /* Get Mask Sprite: */
  41. if(sprite_exists(other.mask_index))
  42. {
  43. mask = sprite_duplicate(other.mask_index)
  44. };
  45. else
  46. {
  47. mask = sprite_duplicate(other.sprite_index)
  48. }
  49.  
  50. sprite_collision_mask(mask, true, 2, _x, _x+_w, _y, _y+_h, 0, 0);
  51. mask_index = mask;
  52. }
  53.  
  54. i3 = i+block_width;
  55.  
  56. ins.alarm[0] = timer;
  57. timer += 2;
  58. }
  59. }
  60. }
  61. else if(image_xscale == 1)
  62. {
  63. for(i=sprite_width-block_width;i>=0;i-=block_width;)
  64. {
  65. for(i2=height-block_height;i2>=0;i2-=block_height;)
  66. {
  67.  
  68. ins = instance_create(x+i, (y-sprite_yoffset)+i2, par_collapsing_terrain_tiles);
  69. with(ins)
  70. {
  71.  
  72. /* Get _x/_y Position: */
  73. _x = other.i
  74. _y = other.i2;
  75. _solid = true;
  76. _w = other.block_width;
  77.  
  78. if(other.i2 == other.height-other.block_height)
  79. {
  80. _h = other.blockheight2;
  81. };
  82. else
  83. {
  84. _h = other.block_height;
  85. };
  86.  
  87. sprite_index = other.sprite_index;
  88. image_xscale = other.image_xscale;
  89.  
  90. /* Set Gravitation and Speed: */
  91. _gravity = 0;
  92. _speed = 0;
  93. _gravity_active = false;
  94.  
  95. /* Get Mask Sprite: */
  96. if(sprite_exists(other.mask_index))
  97. {
  98. mask = sprite_duplicate(other.mask_index)
  99. };
  100. else
  101. {
  102. mask = sprite_duplicate(other.sprite_index)
  103. };
  104.  
  105. sprite_collision_mask(mask, true, 2, _x, _y, _x+_w, _y+_h, 0, 0);
  106. mask_index = mask;
  107. }
  108.  
  109. i3 = (abs(sprite_width)-i)+block_width;
  110.  
  111. ins.alarm[0] = timer;
  112. timer += 2;
  113. };
  114. };
  115. };
  116.  
  117. //Collapse Sound:
  118. sound_stop(snd_sfx_collapse);
  119. sound_play(snd_sfx_collapse);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement