Оценить:
 Рейтинг: 0

Справочник Жаркова по проектированию и программированию искусственного интеллекта. Том 7: Программирование на Visual C# искусственного интеллекта. Издание 2

Год написания книги
2023
Теги
<< 1 ... 20 21 22 23 24 25 26 27 28 ... 34 >>
На страницу:
24 из 34
Настройки чтения
Размер шрифта
Высота строк
Поля

Листинг 5.3. Метод для изменения координат и обнаружения столкновения объектов.

private void updatePositions()

{

if (goingRight)

{

cx += xSpeed;

}

else

{

cx -= xSpeed;

}

if ((cx + cheeseImage.Width) >= this.Width)

{

goingRight = false;

//At the time of collision, the signal Beep is given:

Microsoft.VisualBasic.Interaction.Beep();

}

if (cx <= 0)

{

goingRight = true;

//At the time of collision, the signal Beep is given:

Microsoft.VisualBasic.Interaction.Beep();

}

if (goingDown)

{

cy += ySpeed;

}

else

{

cy -= ySpeed;

}

//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 signal Beep is given:

Microsoft.VisualBasic.Interaction.Beep();

}

if (cy <= 0)

{

goingDown = true;

//At the time of collision, the signal Beep is given:

Microsoft.VisualBasic.Interaction.Beep();

}

//We check the collision of objects:

if (goingDown)

{

//If cheese moves down and there is the collision:

if (cheeseRectangle.IntersectsWith(breadRectangle))

{
<< 1 ... 20 21 22 23 24 25 26 27 28 ... 34 >>
На страницу:
24 из 34

Другие электронные книги автора Валерий Алексеевич Жарков