Skip to main content
added 513 characters in body
Source Link
Jon
  • 3.7k
  • 1
  • 14
  • 23

The easiest way to side-step this is:

x = (int)x;
y = (int)y;

or

x = round(x);
y = round(y);

Are either of these acceptable, visually?

Edit:

Diagram of modified SuperDoggy "Method 1" using floats:
Precise overlap amount given by colliders
enter image description here

Since you have so many cases, it may be helpful to make a helper for jiggling the rect:

class CollisionHelper
{
   CollisionHelper(Collider1,Collider2);
   RECT original;
   RECT test;
   void MoveUp();
   void MoveDown();
   void MoveLeft();
   void MoveRight();
   void ResetRect();
   void Test();
   bool wasValid[4];
   ...
}

This would also encapsulate any flags needed to make multiple tests in one frame and any frame-to-frame flags that might be useful. It should make the if/switch more manageable.

The easiest way to side-step this is:

x = (int)x;
y = (int)y;

or

x = round(x);
y = round(y);

Are either of these acceptable, visually?

Edit:

Diagram of modified SuperDoggy "Method 1" using floats:
Precise overlap amount given by colliders
enter image description here

The easiest way to side-step this is:

x = (int)x;
y = (int)y;

or

x = round(x);
y = round(y);

Are either of these acceptable, visually?

Edit:

Diagram of modified SuperDoggy "Method 1" using floats:
Precise overlap amount given by colliders
enter image description here

Since you have so many cases, it may be helpful to make a helper for jiggling the rect:

class CollisionHelper
{
   CollisionHelper(Collider1,Collider2);
   RECT original;
   RECT test;
   void MoveUp();
   void MoveDown();
   void MoveLeft();
   void MoveRight();
   void ResetRect();
   void Test();
   bool wasValid[4];
   ...
}

This would also encapsulate any flags needed to make multiple tests in one frame and any frame-to-frame flags that might be useful. It should make the if/switch more manageable.

added 92 characters in body
Source Link
Jon
  • 3.7k
  • 1
  • 14
  • 23

The easiest way to side-step this is:

x = (int)x;
y = (int)y;

or

x = round(x);
y = round(y);

Are either of these acceptable, visually?

Edit:

Diagram of modified SuperDoggy "Method 1" using floats:
Precise overlap amount given by colliders
enter image description here

The easiest way to side-step this is:

x = (int)x;
y = (int)y;

or

x = round(x);
y = round(y);

Are either of these acceptable, visually?

Edit: enter image description here

The easiest way to side-step this is:

x = (int)x;
y = (int)y;

or

x = round(x);
y = round(y);

Are either of these acceptable, visually?

Edit:

Diagram of modified SuperDoggy "Method 1" using floats:
Precise overlap amount given by colliders
enter image description here

added 92 characters in body
Source Link
Jon
  • 3.7k
  • 1
  • 14
  • 23

The easiest way to side-step this is:

x = (int)x;
y = (int)y;

or

x = round(x);
y = round(y);

Are either of these acceptable, visually?

Edit: enter image description here

The easiest way to side-step this is:

x = (int)x;
y = (int)y;

or

x = round(x);
y = round(y);

Are either of these acceptable, visually?

The easiest way to side-step this is:

x = (int)x;
y = (int)y;

or

x = round(x);
y = round(y);

Are either of these acceptable, visually?

Edit: enter image description here

Source Link
Jon
  • 3.7k
  • 1
  • 14
  • 23
Loading