Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /// player_collision SCRIPT
- var _collision = false;
- var _bbox_x_side;
- var _bbox_y_side;
- if (x_speed > 0) { _bbox_x_side = bbox_right; } else { _bbox_x_side = bbox_left; }
- if (y_speed > 0) { _bbox_y_side = bbox_bottom; } else { _bbox_y_side = bbox_top; }
- if (tilemap_get_at_pixel(collision_map, _bbox_x_side + x_speed, bbox_top) != 0)
- or (tilemap_get_at_pixel(collision_map, _bbox_x_side + x_speed, bbox_bottom) != 0)
- {
- if (x_speed > 0) { x = x - (x mod tile_size) + (tile_size - 1) - (bbox_right - x); }
- else { x = x - (x mod tile_size) - (bbox_left - x); }
- x_speed = 0;
- _collision = true;
- }
- if (tilemap_get_at_pixel(collision_map, bbox_left, _bbox_y_side + y_speed) != 0)
- or (tilemap_get_at_pixel(collision_map, bbox_right, _bbox_y_side + y_speed) != 0)
- {
- if (y_speed > 0) { y = y - (y mod tile_size) + (tile_size - 1) - (bbox_bottom - y); }
- else { y = y - (y mod tile_size) - (bbox_top - y); }
- y_speed = 0;
- _collision = true;
- }
- // Commit movements
- x += x_speed;
- y += y_speed;
- return _collision;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement