T
trebor777
Guest
Hello.
I'm hunting bugs in my projects, and I struggling with some rounding issues and the bbox_left variable.
Somehow, bbox_left uses a float value as a reference point, despite my x being set as an integer value in my code.
here's a bit of logging I do every frame:
Anyone with a similar issue?
In the end should I use my x-4 or 'bbox_left' ??
This tiny issue basically f***s up my collision detection... :/ because it allows the bbox to be 1 pixel off.. and that messes up my 'movable' distance calculation.
:/
Since i'm fairly new to GMS, i'm wondering if i'm missing something...
I'm hunting bugs in my projects, and I struggling with some rounding issues and the bbox_left variable.
Somehow, bbox_left uses a float value as a reference point, despite my x being set as an integer value in my code.
here's a bit of logging I do every frame:
Code:
// Frame
X:313 DX:4 FX:4 // GOING To the right: current x, dx : desired speed, fx: final speed after collision.
A X:317 // After setting X with FX.
// Next frame
BBL: 313 | 313 X-4 // Still going to the right, everything's fine: my bbox_left is 'synced' with my x-4 value
X:317 DX:4 FX:4
A X:321
BBL: 317 | 317 X-4 // Still going to the right,
X:321 DX:4 FX:4
A X:325
BBL: 321 | 321 X-4 // Start going to the left here
X:325 DX:-4 FX:-4
A X:321
BBL: 316 | 317 X-4 // AND WTF ??? My X is 321, it's an Integer... and bbox_left seems floored to X-5
X:321 DX:-4 FX:-4
A X:317
BBL: 312 | 313 X-4
X:317 DX:-4 FX:-4
A X:313
Anyone with a similar issue?
In the end should I use my x-4 or 'bbox_left' ??
This tiny issue basically f***s up my collision detection... :/ because it allows the bbox to be 1 pixel off.. and that messes up my 'movable' distance calculation.
:/
Code:
var ndx = 0;
if direction_value != 0 {
dx = direction_value * move_speed + x_remainder * abs(sign(direction_value));
// DO X collision
was_on_slope = false;
ndx = scr_collisions_x(dx)
show_debug_message("X:" + string(x) + " DX:" + string(dx) + " FX:" + string(ndx > 0 ? floor(ndx) : ceil(ndx)));
x += ndx > 0 ? floor(ndx) : ceil(ndx);
show_debug_message("A X:" + string(x))
x_remainder = frac(ndx);
}
Since i'm fairly new to GMS, i'm wondering if i'm missing something...