Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var actor;
- actor = id;
- if (argument_count > 0) {
- actor = argument_0;
- }
- with (actor) {
- var vBBox, vDir;
- vDir = sign(vspd);
- if (vspd == 0) {
- // Slope-Alignment
- // Check if a slope is below the player and if the distance is within our maximum allowed slope-height
- // and if it we move the player on top of the slope. This will make for smooth downwards-movement on slopes
- var slopeCollision;
- slopeCollision = collision_line(bbox_left,bbox_bottom+global.maxSlopeHeight,bbox_right,bbox_bottom+global.maxSlopeHeight,parSlope,false,false);
- if (slopeCollision != noone) {
- // Continue with accurate / precise collision-detection
- var didPlaceOnTop;
- didPlaceOnTop = false;
- var retries;
- retries = 1;
- do {
- slopeCollision = collision_line(bbox_left,bbox_bottom+1,bbox_right,bbox_bottom+1,parSlope,true,false);
- if (slopeCollision == noone) {
- y+=1;
- }
- else {
- didPlaceOnTop = true;
- }
- retries +=1;
- }
- until (didPlaceOnTop || retries > global.maxSlopeHeight);
- }
- }
- else {
- repeat(abs(floor(vspd))) {
- vBBox = noone;
- if (vDir == -1) {
- vBBox = bbox_top;
- }
- else if (vDir == 1) {
- vBBox = bbox_bottom+1;
- }
- var collision = collision_line(bbox_left,vBBox,bbox_right,vBBox,parBlock,true,false);
- var didCollide = false;
- if (collision) {
- if (collision.isSolid) {
- // Check if landing on ground
- if (vDir == 1) {
- didLand = true;
- isOnGround = true;
- if (jumpEffect) {
- instance_create_depth(x,y,depth-1,jumpEffect);
- }
- }
- didCollide = true;
- vspd = 0;
- }
- else {
- if (vDir == 1) {
- if (collision.bbox_top == bbox_bottom+1) {
- didLand = true;
- isOnGround = true;
- instance_create_depth(x,y,depth-1,objEffectLand);
- didCollide = true;
- }
- }
- }
- }
- if (didCollide) {
- vspd = 0;
- }
- else {
- y += vDir;
- isOnGround = false;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement