So the past couple months I've been spending what time and patience I could muster trying to figure out how I should handle my movement, specifically in regards to real numbers, angles and collisions. Ideally I would like to program a collision system that would enable me to have real value or floating numbers for the player's position, without issues. However, as you can imagine, things haven't really been working out in practice. Specifically in regard to corner collisions. Currently the movement I have is the basic Spalding code (H. Collisions, Apply Hspeed, V. Collisions, Apply Vspeed).
Now what I want to know is first, whether I could reasonably program what I want with my limited skillset, and second, whether or not it's actually worth it. If there is a better option around this, I'm willing to look into it. The main reason I want to have non-integer compatible collisions is for the sake of angular movement and accuracy, however, if I should be going about this another way, I'd like to know.
I appreciate any help I can get!
//Collision Functions (object in this is just oSolid)
Player Step Event
So this is my main collision code. For context Indigo Physics is just a name for this group of functions. The function RoundFromZero(x) ceils positive numbers and floors negative numbers, RoundTowardsZero(x) does the opposite. Those functions are used to accuratly handle real value positions and velocities prior to them being floored through the place_meeting function. The //Grounding part is just to tell when I can jump.
Now what I want to know is first, whether I could reasonably program what I want with my limited skillset, and second, whether or not it's actually worth it. If there is a better option around this, I'm willing to look into it. The main reason I want to have non-integer compatible collisions is for the sake of angular movement and accuracy, however, if I should be going about this another way, I'd like to know.
I appreciate any help I can get!
//Collision Functions (object in this is just oSolid)
GML:
function IndigoPhysics_HorizontalCollision(Object) {
//Collision
if (place_meeting(RoundTowardsZero(x) + RoundFromZero(xVelocity),y,Object)) {
x = RoundTowardsZero(x);
while (!place_meeting(x + sign(xVelocity),y + sign(yVelocity),Object)) {
x += sign(xVelocity);
}
xVelocity = 0;
}
}
function IndigoPhysics_VerticalCollision(Object) {
//Collision
if (place_meeting(x,RoundTowardsZero(y) + RoundFromZero(yVelocity),Object)) {
y = RoundTowardsZero(y);
while (!place_meeting(x,y + sign(yVelocity),Object)) {
y += sign(yVelocity);
}
yVelocity = 0;
}
//Grounding
if (place_meeting(x,y + 1,Object) && yVelocity == 0) Grounded = true else if (yVelocity > 0) Grounded = false;
}
GML:
IndigoPhysics_HorizontalCollision(oSolid);
x += xVelocity;
IndigoPhysics_VerticalCollision(oSolid);
y += yVelocity;
Last edited: