i have a bouncing ball, and i tried to make so when it bounces once, the speed gets higher.
In my ball class, i have a float speed;
and i initialize
The speed needs to be float. If you want to keep the speed as a float, you could create your own rectangle structure. You could do something like this:
public struct RectangleF
{
float w = 0;
float h = 0;
float x = 0;
float y = 0;
public float Height
{
get { return h; }
set { h = value; }
}
//put Width, X, and Y properties here
public RectangleF(float width, float height, float X, float Y)
{
w = width;
h = height;
x = X;
y = Y;
}
public bool Intersects(Rectangle refRectangle)
{
Rectangle rec = new Rectangle((int)x, (int)y, (int)w, (int)h);
if (rec.Intersects(refRectangle)) return true;
else return false;
}
}
The intersection checking won't be absolutely perfect, but at least your rectangle's X and Y could have 0.5 added on to them. HTH