Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //This script assumes Mega Man's x and y origins are centered in the sprite editor
- var x_check = objMegaman.x;
- var y_check = objMegaman.y;
- var dir = objMegaman.image_xscale;
- var block_up = noone;
- var block_over = noone;
- var block_down = noone;
- var depth_limit;
- if (objMegaman.weapon == RushJet)
- depth_limit = objMegaman.y;
- else
- depth_limit = (view_yview + view_hview);
- var found_landing_point = false;
- var utility = argument[0];
- //Check up
- for (var i = y_check ; i <= y_check - 32; i--;) {
- block_up = collision_rectangle(x_check - 4, i, x_check + 4, y_check, objSolid)) {
- if (instance_exists(block_up)) {
- y_check = (block_up.bbox_bottom + 1);
- break;
- }
- }
- if (!instance_exists(block_up))
- y_check -= 32;
- //Check over
- for (var i = x_check + (4 * -dir); i != x_check + (24 * dir); i += (1 * dir);) {
- if (dir > 0)
- block_over = collision_rectangle(x_check - 4, y_check, x_check + 4 + i, y_check + 8, objSolid);
- else
- block_over = collision_rectangle(x_check + 4 + i, y_check, x_check + 4, y_check + 8, objSolid);
- if (instance_exists(block_over)) {
- var box;
- if (dir > 0)
- box = (block_over.bbox_left - 1);
- else
- box = (block_over.bbox_right + 1);
- x_check = box;
- break;
- }
- }
- if (!instance_exists(block_over))
- x_check += (28 * dir);
- //Check down
- for (var i = y_check; i <= depth_limit; i++) {
- if (dir > 0)
- block_down = collision_rectangle(x_check - 8, y_check, x_check, i, objSolid);
- else
- block_down = collision_rectangle(x_check, y_check, x_check + 8, i, objSolid);
- if ((i >= depth_limit && global.weapon == Rush Jet) || (instance_exists(block_down))) {
- if (global.weapon != Rush Jet) {
- if (instance_exists(block_down))
- y_check = block_down.bbox_top;
- }
- else
- y_check = depth_limit;
- found_landing_point = true;
- break;
- }
- }
- if (found_landing_point) {
- instance_create(x_check, y_check, utility);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement