Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Get the absolute of DY
- r = abs(dy);
- /*VERTICAL MOVEMENT*/
- while r > 0
- {
- //Get whether we are moving left or right, and store the sign in tx.
- if r >= 1 { ty = sign(dy); }
- //Also handle fractional values of r.
- else { ty = frac(dy); }
- col = instance_place(x,y+ty,platforming_obj);
- //If we do not encounter a collision, or that collision is not viable,
- // simply move the ourselves.
- if col == noone or (!p_solid or !col.p_solid)
- or (col.p_jumpthrough and bbox_bottom >= col.bbox_top)
- or (p_jumpthrough and col.bbox_bottom > bbox_top)
- {
- y += ty;
- }
- else
- {
- //If the object is pushable and we can push objects ourselves
- if p_push and col.p_pushable
- {
- //Move the object so we can see if it viabally collides with something.
- col.y += ty+sign(dy);
- with col { other.p_push_col = instance_place(x,y,platforming_obj); }
- //If it doesn't, then move ourselves.
- 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; }
- else
- {
- var colmask = -1+sign(dy);
- if col.mask_index != -1 colmask = col.mask_index else colmask = col.sprite_index;
- col.y -= ty+sign(dy);
- dy = 0;
- var cols = col.image_yscale;
- var s = image_yscale;
- //make sure we and the pushed object are flat against the colliding object.
- if col.bbox_top > p_push_col.bbox_bottom
- {
- col.y = p_push_col.bbox_bottom+(sprite_get_yoffset(colmask)*cols)-(sprite_get_bbox_top(colmask)*cols)+s;
- }
- else if col.bbox_bottom < p_push_col.bbox_top
- {
- col.y = p_push_col.bbox_top-(sprite_get_yoffset(colmask)*cols)+((sprite_get_height(colmask)*cols)-(sprite_get_bbox_bottom(colmask)*cols))-cols;
- }
- if bbox_top > col.bbox_bottom
- {
- y = col.bbox_bottom+(sprite_get_yoffset(mask)*s)-(sprite_get_bbox_top(mask)*s)+s;
- }
- else if bbox_bottom < col.bbox_top
- {
- y = col.bbox_top-(sprite_get_yoffset(mask)*s)+((sprite_get_height(mask)*s)-(sprite_get_bbox_bottom(mask)*s))-s;
- }
- //Stop our horizontal speed, and exit the loop.
- //p_vspd = 0;
- break;
- }
- }
- else
- {
- var s = image_yscale;
- //Else, stop ourselves.
- //Round our x depending what side of the object we are on
- /*if bbox_top > col.bbox_bottom y = floor(y);
- else if bbox_bottom < col.bbox_top y = ceil(y);*/
- if !(p_pushable and col.p_push)
- {
- if bbox_top > col.bbox_bottom
- {
- y = col.bbox_bottom+(sprite_get_yoffset(mask)*s)-(sprite_get_bbox_top(mask)*s)+s;
- }
- else if bbox_bottom < col.bbox_top
- {
- y = col.bbox_top-(sprite_get_yoffset(mask)*s)+((sprite_get_height(mask)*s)-(sprite_get_bbox_bottom(mask)*s))-s;
- }
- }
- if col != p_ground and col.p_vspd >= 0
- {
- p_vspd = 0;
- }
- break;
- }
- }
- r--;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement