NeoShade

player_collision SCRIPT

Jan 19th, 2020
345
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /// player_collision SCRIPT
  2.  
  3.  
  4. var _collision = false;
  5. var _bbox_x_side;
  6. var _bbox_y_side;
  7.  
  8. if (x_speed > 0) { _bbox_x_side = bbox_right; } else { _bbox_x_side = bbox_left; }
  9. if (y_speed > 0) { _bbox_y_side = bbox_bottom; } else { _bbox_y_side = bbox_top; }
  10.  
  11. if (tilemap_get_at_pixel(collision_map, _bbox_x_side + x_speed, bbox_top) != 0)
  12. or (tilemap_get_at_pixel(collision_map, _bbox_x_side + x_speed, bbox_bottom) != 0)
  13.     {
  14.     if (x_speed > 0) { x = x - (x mod tile_size) + (tile_size - 1) - (bbox_right - x); }
  15.     else { x = x - (x mod tile_size) - (bbox_left - x); }
  16.     x_speed = 0;
  17.     _collision = true;
  18.     }
  19.  
  20. if (tilemap_get_at_pixel(collision_map, bbox_left, _bbox_y_side + y_speed) != 0)
  21. or (tilemap_get_at_pixel(collision_map, bbox_right, _bbox_y_side + y_speed) != 0)
  22.     {
  23.     if (y_speed > 0) { y = y - (y mod tile_size) + (tile_size - 1) - (bbox_bottom - y); }
  24.     else { y = y - (y mod tile_size) - (bbox_top - y); }
  25.     y_speed = 0;
  26.     _collision = true;
  27.     }
  28.  
  29.  
  30. // Commit movements
  31. x += x_speed;
  32. y += y_speed;
  33.  
  34. return _collision;
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×