}
//That cheese did not come for the button3.Location.Y:
if ((cy + cheeseImage.Height) >= button3.Location.Y)
{
goingDown = false;
//At the time of collision, the Beep signal is given:
Microsoft.VisualBasic.Interaction.Beep();
}
if (cy <= 0)
{
goingDown = true;
//At the time of collision, the Beep signal is given:
Microsoft.VisualBasic.Interaction.Beep();
}
//We set to rectangles of coordinate of objects:
cheeseRectangle.X = cx;
cheeseRectangle.Y = cy;
breadRectangle.X = bx;
breadRectangle.Y = by;
// check for collisions.
if (goingDown)
{
// only bounce if the cheese is going down
if (cheeseRectangle.IntersectsWith(breadRectangle))
{
//At the time of collision,
//the Beep signal is given:
Microsoft.VisualBasic.Interaction.Beep();
// we have a collision
bool rightIn = breadRectangle.Contains(
cheeseRectangle.Right,
cheeseRectangle.Bottom);
bool leftIn = breadRectangle.Contains(
cheeseRectangle.Left,
cheeseRectangle.Bottom);
// now deal with the bounce
if (rightIn & leftIn)
{
// bounce up
goingDown = false;
}
else
{
// bounce up
goingDown = false;
// now sort out horizontal bounce
if (rightIn)
{
goingRight = false;
}