Предыдущая Следующая
12), -500);
sprite[i].speedSprite.Y = rand.Next(5, 9);
} }
}
/// <summary>
/// Движение платформы по экрану
/// <summary>
public void MovePlatform()
{
if (keyboardState.IsKeyDown(Keys.Left))
platform.spritePosition.X -= 10; else if (keyboardState.IsKeyDown(Keys.Right)) platform.spritePosition.X += 10;
if (platform.spritePosition.X < 10)
platform.spritePosition.X = 10; else if (platform.spritePosition.X > Window.ClientBounds.Width-4 0 0)
platform.spritePosition.X = Window.ClientBounds.Width- 4 0 0;
}
/// <summary> /// Пауза в игре /// <summary> public void Pause()
{
if (keyboardState.IsKeyDown(Keys.P))
{
pauseKeyDown = true;
}
else if (pauseKeyDown)
{
pauseKeyDown = false; paused = Ipaused;
}
}
/// <summary>
/// Столкновения
/// <summary>
public void Collisions()
{
bbplatform.Min = new Vector3(platform.spritePosition.X, platform.spritePosition.Y + 25, 0);
bbplatform.Max = new Vector3(platform.spritePosition.X + platform.spriteTexture.Width,
platform.spritePosition.Y + 25 + platform.spriteTexture.Height, 0); for (int i = 0; bb.Length > i;
{
bb[i].Min = new Vector3(sprite[i].spritePosition.X, sprite[i].spritePosition.Y, 0);
bb[i].Max = new Vector3(sprite[i].spritePosition.X + sprite[i].spriteTexture.Width / 12,
sprite[i].spritePosition.Y + sprite[i].spriteTexture.Height, 0);
}
if (bbplatform.Intersects(bb[0]))
{
sprite[0].spritePosition = new Vector2(rand.Next(10, Window.ClientBounds.Width -
300 - sprite[0].spriteTexture.Width / 12), -500); sprite[0].speedSprite.Y = rand.Next(5, 9);
score0 += 1;
192 Создаем игровое меню
Проект MenuCursor 193
}
if (bbplatform.Intersects(bb[1]))
{
sprite[1].spritePosition = new Vector2(rand.Next(10, Window.ClientBounds.Width -
300 - sprite[1].spriteTexture.Width / 12), -500); sprite[1].speedSprite.Y = rand.Next(5, 9);
score1 += 1;
}
if (bbplatform.Intersects(bb[2]))
{
sprite[2].spritePosition = new Vector2(rand.Next(10, Window.ClientBounds.Width -
300 - sprite[2].spriteTexture.Width / 12), -500); sprite[2].speedSprite.Y = rand.Next(5, 9);
score2 += 1;
}
if (bbplatform.Intersects(bb[3]))
{
sprite[3].spritePosition = new Vector2(rand.Next(10, Window.ClientBounds.Width -
300 - sprite[3].spriteTexture.Width / 12), -500); sprite[3].speedSprite.Y = rand.Next(5, 9);
score3 += 1;
}
if (bbplatform.Intersects(bb[4]))
{
sprite[4].spritePosition = new Vector2(rand.Next(10, Window.ClientBounds.Width -
300 - sprite[4].spriteTexture.Width / 12), -500); sprite[4].speedSprite.Y = rand.Next(5, 9); Предыдущая Следующая
|