Предыдущая Следующая
Collisions();
}
base.Update(gameTime);
}
/// <summary>
/// Движение спрайта по вертикали
/// <summary>
public void MoveSprite()
{
for (int i = 0; sprite.Length > i;
{
sprite[i].spritePosition += sprite[i].speedSprite;
if (sprite[i].spritePosition.Y > Window.ClientBounds.Height)
{
sprite[i].spritePosition = new Vector2(rand.Next(10, Window.ClientBounds.Width -
300 - sprite[i].spriteTexture.Width / 12), -500);
} } }
162 Подсчет очков и вывод текста на экран
Работа с текстом 163
/// <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 - 400)
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;
}
}
// Столкновения
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 + 2, 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); score0 += 1;
}
if (bbplatform.Intersects(bb[1]))
{
sprite[1].spritePosition = new Vector2(rand.Next(10, Window.ClientBounds.Width -
300 - sprite[1].spriteTexture.Width / 12), -500); scorel += 1;
}
if (bbplatform.Intersects(bb[2]))
{
sprite[2].spritePosition = new Vector2(rand.Next(10, Window.ClientBounds.Width -
300 - sprite[2].spriteTexture.Width / 12), -500); 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); score3 += 1;
}
if (bbplatform.Intersects(bb[4])) Предыдущая Следующая
|