Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //decimal fractions of hsp are stored in hsp_f
- //every frame this fraction is added back in and the new fraction removed again
- //this moves us in whole integers each frame that are still representative of decimal movement
- //for example, at a hsp of 0.1 you would move 1 pixel every 10 frames.
- //this resolves any issues of not detecting a collision at a fractional target (ie: no collision at 3.8, when there is at 4.0)
- //which sometimes caused the player after rounding, to be drawn overlapping walls by 1 pixel.
- hsp_final = hsp + hsp_f;
- hsp_f = hsp_final - floor(abs(hsp_final))*sign(hsp_final);
- hsp_final -= hsp_f;
- vsp_final = vsp + vsp_f;
- vsp_f = vsp_final - floor(abs(vsp_final))*sign(vsp_final);
- vsp_final -= vsp_f;
- //same old place_meeting collision code.
- if (place_meeting(x+hsp_final,y,par_collide))
- {
- var inc = sign(hsp_final);
- while (!place_meeting(x+inc,y,par_collide)) x+= inc;
- hsp_final = 0;
- hsp = 0;
- }
- x+=hsp_final;
- if (place_meeting(x,y+vsp_final,par_collide))
- {
- var inc = sign(vsp_final);
- while (!place_meeting(x,y+inc,par_collide)) y+= inc;
- vsp_final = 0;
- vsp = 0;
- }
- y+=vsp_final;
Advertisement
Add Comment
Please, Sign In to add comment